@@ -61,6 +61,24 @@ QT_BEGIN_NAMESPACE
61
61
#define NULLTIMER_PRIORITY CActive::EPriorityLow
62
62
#define COMPLETE_DEFERRED_ACTIVE_OBJECTS_PRIORITY CActive::EPriorityIdle
63
63
64
+ class Incrementer {
65
+ int &variable;
66
+ public:
67
+ inline Incrementer (int &variable) : variable(variable)
68
+ { ++variable; }
69
+ inline ~Incrementer ()
70
+ { --variable; }
71
+ };
72
+
73
+ class Decrementer {
74
+ int &variable;
75
+ public:
76
+ inline Decrementer (int &variable) : variable(variable)
77
+ { --variable; }
78
+ inline ~Decrementer ()
79
+ { ++variable; }
80
+ };
81
+
64
82
static inline int qt_pipe_write (int socket, const char *data, qint64 len)
65
83
{
66
84
return ::write (socket, data, len);
@@ -830,6 +848,8 @@ bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags fla
830
848
#endif
831
849
832
850
while (1 ) {
851
+ // native active object callbacks are logically part of the event loop, so inc nesting level
852
+ Incrementer inc (d->threadData ->loopLevel );
833
853
if (block) {
834
854
// This is where Qt will spend most of its time.
835
855
CActiveScheduler::Current ()->WaitForAnyRequest ();
@@ -894,6 +914,7 @@ bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags fla
894
914
895
915
void QEventDispatcherSymbian::timerFired (int timerId)
896
916
{
917
+ Q_D (QAbstractEventDispatcher);
897
918
QHash<int , SymbianTimerInfoPtr>::iterator i = m_timerList.find (timerId);
898
919
if (i == m_timerList.end ()) {
899
920
// The timer has been deleted. Ignore this event.
@@ -912,6 +933,8 @@ void QEventDispatcherSymbian::timerFired(int timerId)
912
933
m_insideTimerEvent = true ;
913
934
914
935
QTimerEvent event (timerInfo->timerId );
936
+ // undo the added nesting level around RunIfReady, since Qt's event system also nests
937
+ Decrementer dec (d->threadData ->loopLevel );
915
938
QCoreApplication::sendEvent (timerInfo->receiver , &event);
916
939
917
940
m_insideTimerEvent = oldInsideTimerEventValue;
@@ -922,13 +945,16 @@ void QEventDispatcherSymbian::timerFired(int timerId)
922
945
923
946
void QEventDispatcherSymbian::socketFired (QSocketActiveObject *socketAO)
924
947
{
948
+ Q_D (QAbstractEventDispatcher);
925
949
if (m_noSocketEvents) {
926
950
m_deferredSocketEvents.append (socketAO);
927
951
return ;
928
952
}
929
953
930
954
QEvent e (QEvent::SockAct);
931
955
socketAO->m_inSocketEvent = true ;
956
+ // undo the added nesting level around RunIfReady, since Qt's event system also nests
957
+ Decrementer dec (d->threadData ->loopLevel );
932
958
QCoreApplication::sendEvent (socketAO->m_notifier , &e);
933
959
socketAO->m_inSocketEvent = false ;
934
960
@@ -943,6 +969,7 @@ void QEventDispatcherSymbian::socketFired(QSocketActiveObject *socketAO)
943
969
944
970
void QEventDispatcherSymbian::wakeUpWasCalled ()
945
971
{
972
+ Q_D (QAbstractEventDispatcher);
946
973
// The reactivation should happen in RunL, right before the call to this function.
947
974
// This is because m_wakeUpDone is the "signal" that the object can be completed
948
975
// once more.
@@ -952,6 +979,8 @@ void QEventDispatcherSymbian::wakeUpWasCalled()
952
979
// the sendPostedEvents was done, but before the object was ready to be completed
953
980
// again. This could deadlock the application if there are no other posted events.
954
981
m_wakeUpDone.fetchAndStoreOrdered (0 );
982
+ // undo the added nesting level around RunIfReady, since Qt's event system also nests
983
+ Decrementer dec (d->threadData ->loopLevel );
955
984
sendPostedEvents ();
956
985
}
957
986
0 commit comments