Skip to content

Commit

Permalink
Make sure the message handlers block
Browse files Browse the repository at this point in the history
  • Loading branch information
cantabile committed Jan 26, 2016
1 parent ee88793 commit 1269d08
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/wibbly/WibblyWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ SOFTWARE.
#include <QScrollArea>
#include <QShortcut>
#include <QStatusBar>
#include <QThread>

#include <QHBoxLayout>
#include <QVBoxLayout>
Expand Down Expand Up @@ -92,7 +93,13 @@ WibblyWindow::WibblyWindow()
void VS_CC messageHandler(int msgType, const char *msg, void *userData) {
WibblyWindow *window = (WibblyWindow *)userData;

QMetaObject::invokeMethod(window, "vsLogPopup", Qt::QueuedConnection, Q_ARG(int, msgType), Q_ARG(void *, (void *)msg));
Qt::ConnectionType type;
if (QThread::currentThread() == window->thread())
type = Qt::DirectConnection;
else
type = Qt::BlockingQueuedConnection;

QMetaObject::invokeMethod(window, "vsLogPopup", type, Q_ARG(int, msgType), Q_ARG(void *, (void *)msg));
}


Expand Down
9 changes: 8 additions & 1 deletion src/wobbly/WobblyWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ SOFTWARE.
#include <QSpinBox>
#include <QStatusBar>
#include <QTabWidget>
#include <QThread>

#include <QHBoxLayout>
#include <QVBoxLayout>
Expand Down Expand Up @@ -2388,7 +2389,13 @@ void WobblyWindow::createUI() {
void VS_CC messageHandler(int msgType, const char *msg, void *userData) {
WobblyWindow *window = (WobblyWindow *)userData;

QMetaObject::invokeMethod(window, "vsLogPopup", Qt::QueuedConnection, Q_ARG(int, msgType), Q_ARG(void *, (void *)msg));
Qt::ConnectionType type;
if (QThread::currentThread() == window->thread())
type = Qt::DirectConnection;
else
type = Qt::BlockingQueuedConnection;

QMetaObject::invokeMethod(window, "vsLogPopup", type, Q_ARG(int, msgType), Q_ARG(void *, (void *)msg));
}


Expand Down

0 comments on commit 1269d08

Please sign in to comment.