Commit bd0a86da authored by Christoffer Ackelman's avatar Christoffer Ackelman

QT: Fixed a segmentation fault that only occured if you auto-scrolled in one...

QT: Fixed a segmentation fault that only occured if you auto-scrolled in one direction for a very long time, it eventually messed up the stack.
parent 1423e127
......@@ -187,6 +187,7 @@ FlowDrawQt::FlowDrawQt(QWidget* x_toplevel, void** flow_ctx,
: toplevel(x_toplevel), closing_down(0)
{
timer_id = new QTimer(this);
draw_timer_id = new QTimer(this);
if (type == flow_eCtxType_Brow) {
ctx = (FlowCtx*)new BrowCtx("Claes context", 20);
......@@ -1029,13 +1030,9 @@ void FlowDrawQt::set_window_size(DrawWind *wind, int width, int height)
bool FlowDrawQt::draw_timer_cb()
{
FlowDrawQt* draw_ctx = (FlowDrawQt*)timer_cb->ctx->fdraw;
(timer_cb->callback_func)(timer_cb->ctx);
draw_ctx->toplevel->update();
delete timer_cb->timer_id;
delete timer_cb;
draw_timer_id->stop();
(draw_timer_callback_func)(ctx);
toplevel->update();
return FALSE;
}
......@@ -1070,21 +1067,16 @@ void FlowDrawQt::event_timer(FlowCtx* ctx, QMouseEvent* event, QWidget *target)
void FlowDrawQt::set_timer(FlowCtx* ctx, int time_ms,
void (*callback_func)(FlowCtx* ctx), void** id)
{
timer_cb = new flow_draw_sTimerCb();
timer_cb->ctx = ctx;
timer_cb->callback_func = callback_func;
timer_cb->timer_id = new QTimer(this);
initOneShotTimer(timer_cb->timer_id, SLOT(draw_timer_cb()), time_ms);
*id = (void*)timer_cb;
draw_timer_callback_func = callback_func;
initOneShotTimer(draw_timer_id, SLOT(draw_timer_cb()), time_ms);
*id = (void*)draw_timer_id;
}
void FlowDrawQt::cancel_timer(void* id)
void FlowDrawQt::cancel_timer(void* ctx)
{
delete (((flow_draw_sTimerCb*)id)->timer_id);
delete ((char*)id);
if (draw_timer_id) {
draw_timer_id->stop();
}
}
void FlowDrawQt::set_cursor(DrawWind *wind, draw_eCursor cursor)
......
......@@ -52,12 +52,6 @@ public:
QImage* buffer = NULL;
};
typedef struct {
FlowCtx* ctx;
void (*callback_func)(FlowCtx* ctx);
QTimer* timer_id;
} flow_draw_sTimerCb;
class FlowDrawQt : private QObject, public FlowDraw {
Q_OBJECT
......@@ -148,11 +142,12 @@ private:
void event_timer(FlowCtx* ctx, QMouseEvent *event, QWidget *target);
void cancel_event_timer(FlowCtx* ctx);
flow_draw_sTimerCb* timer_cb;
void (*draw_timer_callback_func)(FlowCtx* ctx);
QTimer* draw_timer_id;
public slots:
bool event_timer_cb();
bool draw_timer_cb();
};
#endif
\ No newline at end of file
#endif
......@@ -256,6 +256,7 @@ GlowDrawQt::GlowDrawQt(QWidget* toplevel, void** glow_ctx,
: click_sensitivity(0), closing_down(0), customcolors_cnt(0)
{
timer_id = new QTimer(this);
draw_timer_id = new QTimer(this);
memset(customcolors, 0, sizeof(customcolors));
......@@ -1169,13 +1170,9 @@ void GlowDrawQt::set_window_size(DrawWind* wind, int width, int height)
bool GlowDrawQt::draw_timer_cb()
{
GlowDrawQt* draw_ctx = (GlowDrawQt*)timer_cb->ctx->gdraw;
(timer_cb->callback_func)(timer_cb->ctx);
draw_ctx->m_wind.window->update();
delete timer_cb->timer_id;
delete timer_cb;
draw_timer_id->stop();
(draw_timer_callback_func)(ctx);
m_wind.window->update();
return FALSE;
}
......@@ -1208,21 +1205,16 @@ void GlowDrawQt::event_timer(QMouseEvent* event, QWidget *target)
void GlowDrawQt::set_timer(GlowCtx* paintertx, int time_ms,
void (*callback_func)(GlowCtx* ctx), void** id)
{
timer_cb = new glow_draw_sTimerCb();
timer_cb->ctx = paintertx;
timer_cb->callback_func = callback_func;
timer_cb->timer_id = new QTimer(this);
initOneShotTimer(timer_cb->timer_id, SLOT(draw_timer_cb()), time_ms);
*id = (void*)timer_cb;
draw_timer_callback_func = callback_func;
initOneShotTimer(draw_timer_id, SLOT(draw_timer_cb()), time_ms);
*id = (void*)draw_timer_id;
}
void GlowDrawQt::remove_timer(void* id)
{
delete (((glow_draw_sTimerCb*)id)->timer_id);
delete ((char*)id);
if (draw_timer_id) {
draw_timer_id->stop();
}
}
void GlowDrawQt::set_cursor(DrawWind* wind, glow_eDrawCursor cursor)
......
......@@ -69,12 +69,6 @@ public:
QPixmap* background_pixmap = NULL;
};
typedef struct {
GlowCtx* ctx;
void (*callback_func)(GlowCtx* ctx);
QTimer* timer_id;
} glow_draw_sTimerCb;
class GlowCustomColorsQt;
class GlowDrawQt : private QObject, public GlowDraw {
......@@ -196,7 +190,8 @@ private:
void event_timer(QMouseEvent *event, QWidget *target);
void cancel_event_timer();
glow_draw_sTimerCb* timer_cb;
void (*draw_timer_callback_func)(GlowCtx* ctx);
QTimer* draw_timer_id;
public slots:
bool event_timer_cb();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment