Title: [101131] trunk/Source/_javascript_Core
- Revision
- 101131
- Author
- [email protected]
- Date
- 2011-11-24 03:37:30 -0800 (Thu, 24 Nov 2011)
Log Message
[Qt] Use QEvent for dispatchFunctionsFromMainThread()
https://bugs.webkit.org/show_bug.cgi?id=72704
Reviewed by Simon Hausmann.
Replace QMetaObject::invokeMethod with QCoreApplication::postEvent.
This is the same as what invokeMethod does internally, but reduces
the dependency on some internal QThread stuff.
* wtf/qt/MainThreadQt.cpp:
(WTF::MainThreadInvoker::MainThreadInvoker):
(WTF::MainThreadInvoker::event):
(WTF::scheduleDispatchFunctionsOnMainThread):
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (101130 => 101131)
--- trunk/Source/_javascript_Core/ChangeLog 2011-11-24 09:47:02 UTC (rev 101130)
+++ trunk/Source/_javascript_Core/ChangeLog 2011-11-24 11:37:30 UTC (rev 101131)
@@ -1,3 +1,19 @@
+2011-11-24 Patrick Gansterer <[email protected]>
+
+ [Qt] Use QEvent for dispatchFunctionsFromMainThread()
+ https://bugs.webkit.org/show_bug.cgi?id=72704
+
+ Reviewed by Simon Hausmann.
+
+ Replace QMetaObject::invokeMethod with QCoreApplication::postEvent.
+ This is the same as what invokeMethod does internally, but reduces
+ the dependency on some internal QThread stuff.
+
+ * wtf/qt/MainThreadQt.cpp:
+ (WTF::MainThreadInvoker::MainThreadInvoker):
+ (WTF::MainThreadInvoker::event):
+ (WTF::scheduleDispatchFunctionsOnMainThread):
+
2011-11-23 George Staikos <[email protected]>
Remove BlackBerry OS support from RandomNumberSeed, making QNX=UNIX.
Modified: trunk/Source/_javascript_Core/wtf/qt/MainThreadQt.cpp (101130 => 101131)
--- trunk/Source/_javascript_Core/wtf/qt/MainThreadQt.cpp 2011-11-24 09:47:02 UTC (rev 101130)
+++ trunk/Source/_javascript_Core/wtf/qt/MainThreadQt.cpp 2011-11-24 11:37:30 UTC (rev 101131)
@@ -31,29 +31,34 @@
#include "config.h"
#include "MainThread.h"
-#include <QtCore/QObject>
-#include <QtCore/QCoreApplication>
+#include <QCoreApplication>
+#include <QEvent>
+#include <QObject>
#include <QThread>
namespace WTF {
+static int s_mainThreadInvokerEventType;
+
class MainThreadInvoker : public QObject {
Q_OBJECT
public:
MainThreadInvoker();
-
-private Q_SLOTS:
- void dispatch();
+ virtual bool event(QEvent*);
};
MainThreadInvoker::MainThreadInvoker()
{
- moveToThread(QCoreApplication::instance()->thread());
+ s_mainThreadInvokerEventType = QEvent::registerEventType();
}
-void MainThreadInvoker::dispatch()
+bool MainThreadInvoker::event(QEvent* e)
{
+ if (e->type() != s_mainThreadInvokerEventType)
+ return QObject::event(e);
+
dispatchFunctionsFromMainThread();
+ return true;
}
Q_GLOBAL_STATIC(MainThreadInvoker, webkit_main_thread_invoker)
@@ -64,7 +69,7 @@
void scheduleDispatchFunctionsOnMainThread()
{
- QMetaObject::invokeMethod(webkit_main_thread_invoker(), "dispatch", Qt::QueuedConnection);
+ QCoreApplication::postEvent(webkit_main_thread_invoker(), new QEvent(static_cast<QEvent::Type>(s_mainThreadInvokerEventType)));
}
bool isMainThread()
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes