summaryrefslogtreecommitdiffstats
path: root/src/kernel
diff options
context:
space:
mode:
authorTimothy Pearson <[email protected]>2012-12-07 15:01:56 -0600
committerTimothy Pearson <[email protected]>2012-12-07 15:01:56 -0600
commit9bff9eeefc262c8509b2db7c1120f6001d65e64c (patch)
tree3e837032fb29614f059d2b29b18e3210d6e8c8a8 /src/kernel
parent85b3c5d0ec2280393e1c5ac7af6a56abf9fc2e9a (diff)
downloadqt3-9bff9eeefc262c8509b2db7c1120f6001d65e64c.tar.gz
qt3-9bff9eeefc262c8509b2db7c1120f6001d65e64c.zip
Add level method to recursive mutex
Enhance thread safety when making event calls Minor cleanup of whitespace in glib event loop
Diffstat (limited to 'src/kernel')
-rw-r--r--src/kernel/qapplication.cpp17
-rw-r--r--src/kernel/qeventloop_unix_glib.cpp18
-rw-r--r--src/kernel/qeventloop_x11_glib.cpp74
3 files changed, 59 insertions, 50 deletions
diff --git a/src/kernel/qapplication.cpp b/src/kernel/qapplication.cpp
index f3b0119..5b43301 100644
--- a/src/kernel/qapplication.cpp
+++ b/src/kernel/qapplication.cpp
@@ -2767,18 +2767,21 @@ bool QApplication::internalNotify( QObject *receiver, QEvent * e)
if (!handled) {
#if defined(QT_THREAD_SUPPORT)
- bool locked = false;
+ int locklevel = 0;
+ int llcount;
if (QApplication::qt_mutex) {
- locked = QApplication::qt_mutex->locked();
- }
- if (locked) {
- QApplication::qt_mutex->unlock();
+ QApplication::qt_mutex->lock(); // 1 of 2
+ locklevel = qt_mutex->level() - 1;
+ for (llcount=0; llcount<locklevel; llcount++) {
+ QApplication::qt_mutex->unlock();
+ }
+ QApplication::qt_mutex->unlock(); // 2 of 2
}
#endif
consumed = receiver->event( e );
#if defined(QT_THREAD_SUPPORT)
- if (locked) {
- if (QApplication::qt_mutex) {
+ if (QApplication::qt_mutex) {
+ for (llcount=0; llcount<locklevel; llcount++) {
QApplication::qt_mutex->lock();
}
}
diff --git a/src/kernel/qeventloop_unix_glib.cpp b/src/kernel/qeventloop_unix_glib.cpp
index 9d3ce27..6a890ce 100644
--- a/src/kernel/qeventloop_unix_glib.cpp
+++ b/src/kernel/qeventloop_unix_glib.cpp
@@ -370,9 +370,9 @@ void QEventLoop::registerSocketNotifier( QSocketNotifier *notifier )
return;
}
- #ifdef DEBUG_QT_GLIBMAINLOOP
- printf("register socket notifier %d\n", sockfd);
- #endif
+#ifdef DEBUG_QT_GLIBMAINLOOP
+ printf("register socket notifier %d\n", sockfd);
+#endif
QPtrList<QSockNotGPollFD> *list = &d->sn_list;
QSockNotGPollFD *sn;
@@ -425,9 +425,9 @@ void QEventLoop::unregisterSocketNotifier( QSocketNotifier *notifier )
return;
}
- #ifdef DEBUG_QT_GLIBMAINLOOP
- printf("unregister socket notifier %d\n", sockfd);
- #endif
+#ifdef DEBUG_QT_GLIBMAINLOOP
+ printf("unregister socket notifier %d\n", sockfd);
+#endif
QPtrList<QSockNotGPollFD> *list = &d->sn_list;
QSockNotGPollFD *sn;
@@ -458,9 +458,9 @@ void QEventLoop::setSocketNotifierPending( QSocketNotifier *notifier )
return;
}
- #ifdef DEBUG_QT_GLIBMAINLOOP
- printf("set socket notifier pending %d\n", sockfd);
- #endif
+#ifdef DEBUG_QT_GLIBMAINLOOP
+ printf("set socket notifier pending %d\n", sockfd);
+#endif
QPtrList<QSockNotGPollFD> *list = &d->sn_list;
QSockNotGPollFD *sn;
diff --git a/src/kernel/qeventloop_x11_glib.cpp b/src/kernel/qeventloop_x11_glib.cpp
index b3d881a..0d2275e 100644
--- a/src/kernel/qeventloop_x11_glib.cpp
+++ b/src/kernel/qeventloop_x11_glib.cpp
@@ -54,6 +54,8 @@
#include <glib.h>
+// #define DEBUG_QT_GLIBMAINLOOP 1
+
// Qt-GSource Structure and Callbacks
typedef struct {
@@ -249,7 +251,7 @@ bool QEventLoop::processEvents( ProcessEventsFlags flags )
d->pev_flags = flags;
- rval = g_main_context_iteration(NULL, flags & WaitForMore ? TRUE : FALSE);
+ rval = g_main_context_iteration(NULL, flags & WaitForMore ? TRUE : FALSE);
d->pev_flags = save_flags;
@@ -288,38 +290,38 @@ bool QEventLoop::processX11Events()
XNextEvent( QPaintDevice::x11AppDisplay(), &event );
if ( flags & ExcludeUserInput ) {
- switch ( event.type ) {
- case ButtonPress:
- case ButtonRelease:
- case MotionNotify:
- case XKeyPress:
- case XKeyRelease:
- case EnterNotify:
- case LeaveNotify:
- continue;
-
- case ClientMessage:
- {
- // from qapplication_x11.cpp
- extern Atom qt_wm_protocols;
- extern Atom qt_wm_take_focus;
- extern Atom qt_qt_scrolldone;
-
- // only keep the wm_take_focus and
- // qt_qt_scrolldone protocols, discard all
- // other client messages
- if ( event.xclient.format != 32 )
+ switch ( event.type ) {
+ case ButtonPress:
+ case ButtonRelease:
+ case MotionNotify:
+ case XKeyPress:
+ case XKeyRelease:
+ case EnterNotify:
+ case LeaveNotify:
continue;
-
- if ( event.xclient.message_type == qt_wm_protocols ||
- (Atom) event.xclient.data.l[0] == qt_wm_take_focus )
- break;
- if ( event.xclient.message_type == qt_qt_scrolldone )
- break;
+
+ case ClientMessage:
+ {
+ // from qapplication_x11.cpp
+ extern Atom qt_wm_protocols;
+ extern Atom qt_wm_take_focus;
+ extern Atom qt_qt_scrolldone;
+
+ // only keep the wm_take_focus and
+ // qt_qt_scrolldone protocols, discard all
+ // other client messages
+ if ( event.xclient.format != 32 )
+ continue;
+
+ if ( event.xclient.message_type == qt_wm_protocols ||
+ (Atom) event.xclient.data.l[0] == qt_wm_take_focus )
+ break;
+ if ( event.xclient.message_type == qt_qt_scrolldone )
+ break;
+ }
+
+ default: break;
}
-
- default: break;
- }
}
nevents++;
@@ -333,7 +335,7 @@ bool QEventLoop::processX11Events()
if ( d->shortcut ) {
return FALSE;
}
-
+
QApplication::sendPostedEvents();
const uint exclude_all = ExcludeSocketNotifiers | 0x08;
@@ -595,12 +597,16 @@ bool QEventLoop::gsourceDispatch(GSource *gs) {
// color approx. optimization - only on X11
qt_reset_color_avail();
+#if defined(QT_THREAD_SUPPORT)
+ locker.mutex()->unlock();
+#endif
processX11Events();
}
-
+ else {
#if defined(QT_THREAD_SUPPORT)
- locker.mutex()->unlock();
+ locker.mutex()->unlock();
#endif
+ }
if (d->singletoolkit) {
return TRUE; // Eat the event