Commit 2299fc12 authored by Christoffer Ackelman's avatar Christoffer Ackelman

Fixed QT double event issue

parent ef00f675
...@@ -77,9 +77,16 @@ void dbg_print(const char *file, int line, const char *fmt, ...) ...@@ -77,9 +77,16 @@ void dbg_print(const char *file, int line, const char *fmt, ...)
} }
} }
void dbg_print(QString str) void dbg_print(const char *file, int line, QString str)
{ {
if (DEBUG) { if (DEBUG) {
// 1. print timestamp
print_time(stderr);
// 2. print filename only, without path
const char *file2 = strrchr(file, '/');
file2 = file2 ? (file2 + 1) : file;
fprintf(stderr, " %s:%d: ", file2, line);
// 3. print the actual debug message
QByteArray ba = str.toLocal8Bit(); QByteArray ba = str.toLocal8Bit();
const char *c_str = ba.data(); const char *c_str = ba.data();
fprintf(stderr, "%s\n", c_str); fprintf(stderr, "%s\n", c_str);
......
...@@ -50,11 +50,14 @@ void print_time(FILE *stream, int fulldate = 0); ...@@ -50,11 +50,14 @@ void print_time(FILE *stream, int fulldate = 0);
void dbg_print(const char *file, int line, const char *fmt, ...); void dbg_print(const char *file, int line, const char *fmt, ...);
void dbg_print(QString str); void dbg_print(const char *file, int line, QString str);
#define debug_print(fmt, args...) \ #define debug_print(fmt, args...) \
do { if (DEBUG) { dbg_print(__FILE__, __LINE__, fmt, ##args); } } while (0) do { if (DEBUG) { dbg_print(__FILE__, __LINE__, fmt, ##args); } } while (0)
#define debug_print2(qstr) \
do { if (DEBUG) { dbg_print(__FILE__, __LINE__, qstr); } } while (0)
/* /*
* Qt Helper functions * Qt Helper functions
*/ */
......
...@@ -93,7 +93,11 @@ QWidget *QtScrollWidgetFlow::initScroll( ...@@ -93,7 +93,11 @@ QWidget *QtScrollWidgetFlow::initScroll(
bool QScrollAreaFlow::event(QEvent *event) bool QScrollAreaFlow::event(QEvent *event)
{ {
QtScrollWidgetFlow *child = ((QtScrollWidgetFlow *) widget()); QtScrollWidgetFlow *child = ((QtScrollWidgetFlow *) widget());
child->handleEvent(event); time_t t;
time(&t);
if (event->type() != child->lastEvent->type() || difftime(t, child->t) > 0.000001) {
child->handleEvent(event);
}
return QScrollArea::event(event); return QScrollArea::event(event);
} }
...@@ -263,6 +267,8 @@ bool QtScrollWidgetFlow::event(QEvent *event) ...@@ -263,6 +267,8 @@ bool QtScrollWidgetFlow::event(QEvent *event)
is_realized = true; is_realized = true;
} }
handleEvent(event); handleEvent(event);
lastEvent = event;
time(&t);
return QWidget::event(event); return QWidget::event(event);
} }
......
...@@ -105,6 +105,9 @@ public: ...@@ -105,6 +105,9 @@ public:
QImage image; QImage image;
QEvent *lastEvent;
time_t t;
virtual void handleEvent(QEvent *event); virtual void handleEvent(QEvent *event);
protected: protected:
......
...@@ -93,7 +93,11 @@ QWidget *QtScrollWidgetGlow::initScroll( ...@@ -93,7 +93,11 @@ QWidget *QtScrollWidgetGlow::initScroll(
bool QScrollAreaGlow::event(QEvent *event) bool QScrollAreaGlow::event(QEvent *event)
{ {
QtScrollWidgetGlow *child = ((QtScrollWidgetGlow *) widget()); QtScrollWidgetGlow *child = ((QtScrollWidgetGlow *) widget());
child->handleEvent(event); time_t t;
time(&t);
if (event->type() != child->lastEvent->type() || difftime(t, child->t) > 0.000001) {
child->handleEvent(event);
}
return QScrollArea::event(event); return QScrollArea::event(event);
} }
...@@ -263,6 +267,8 @@ bool QtScrollWidgetGlow::event(QEvent *event) ...@@ -263,6 +267,8 @@ bool QtScrollWidgetGlow::event(QEvent *event)
is_realized = true; is_realized = true;
} }
handleEvent(event); handleEvent(event);
lastEvent = event;
time(&t);
return QWidget::event(event); return QWidget::event(event);
} }
......
...@@ -105,6 +105,9 @@ public: ...@@ -105,6 +105,9 @@ public:
QImage image; QImage image;
QEvent *lastEvent;
time_t t;
virtual void handleEvent(QEvent *event); virtual void handleEvent(QEvent *event);
protected: protected:
......
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