summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qeventdispatcher_blackberry_p.h
diff options
context:
space:
mode:
authorJonathan Hoffmann <jhoffmann@blackberry.com>2013-09-13 14:05:35 -0400
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-23 19:09:54 +0200
commit5cc76dae7e985a7a39d839524dc8ad6475e597f3 (patch)
tree0c8aee04b5dc593338bf9d51e8ef7151364c74b2 /src/corelib/kernel/qeventdispatcher_blackberry_p.h
parentfe61f2d6b29cca87b46dc37c7968b2f765f670ef (diff)
BlackBerry: improve BPS event lifetime management
In QEventDispatcherBlackberry::select(), if an event handler called through filterEvent() starts a nested event loop by creating a new QEventLoop, we will recursively enter the select() method again. However, each time bps_get_event() is called, it destroys the last event it handed out before returning the next event. We don't want it to destroy the event that triggered the nested event loop, since there may still be more handlers that need to get that event, once the nested event loop is done and control returns to the outer event loop. So we move an event to a holding channel, which takes ownership of the event. Putting the event on our own channel allows us to manage when it is destroyed, keeping it alive until we know we are done with it. Each recursive call of this function needs to have it's own holding channel, since a channel is a queue, not a stack. However, a recursive call into the select() method happens very rarely compared to the many times this method is called. We don't want to create a holding channel for each time this method is called, only when it is called recursively. Thus we have the instance variable d->holding_channel to use in the common case. We keep track of recursive calls with d->loop_level. If we are in a recursive call, then we create a new holding channel for this run. Change-Id: Ib3584676d2db5a9a3754a1535d5fb6c9e14f5dbb Reviewed-by: Thomas McGuire <thomas.mcguire@kdab.com>
Diffstat (limited to 'src/corelib/kernel/qeventdispatcher_blackberry_p.h')
-rw-r--r--src/corelib/kernel/qeventdispatcher_blackberry_p.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/corelib/kernel/qeventdispatcher_blackberry_p.h b/src/corelib/kernel/qeventdispatcher_blackberry_p.h
index 5a4c3a9dcd..1764c244d8 100644
--- a/src/corelib/kernel/qeventdispatcher_blackberry_p.h
+++ b/src/corelib/kernel/qeventdispatcher_blackberry_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2012 Research In Motion
+** Copyright (C) 2012 - 2013 BlackBerry Limited. All rights reserved.
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -95,6 +95,8 @@ public:
int processThreadWakeUp(int nsel);
int bps_channel;
+ int holding_channel;
+ int loop_level;
QScopedPointer<bpsIOHandlerData> ioData;
};