author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 03 May 2010 13:17:34 +0300 | |
changeset 19 | fcece45ef507 |
parent 18 | 2f34d5167611 |
child 9 | 740e5562c97f |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the QtCore module of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#include "qeventdispatcher_symbian_p.h" |
|
43 |
#include <private/qthread_p.h> |
|
44 |
#include <qcoreapplication.h> |
|
45 |
#include <private/qcoreapplication_p.h> |
|
46 |
#include <qdatetime.h> |
|
47 |
||
48 |
#include <unistd.h> |
|
49 |
#include <errno.h> |
|
50 |
||
51 |
QT_BEGIN_NAMESPACE |
|
52 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
53 |
#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
54 |
// when the system UI is Qt based, priority drop is not needed as CPU starved processes will not be killed. |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
55 |
#undef QT_SYMBIAN_PRIORITY_DROP |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
56 |
#else |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
57 |
#define QT_SYMBIAN_PRIORITY_DROP |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
58 |
#endif |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
59 |
|
0 | 60 |
#define WAKE_UP_PRIORITY CActive::EPriorityStandard |
61 |
#define TIMER_PRIORITY CActive::EPriorityHigh |
|
62 |
#define NULLTIMER_PRIORITY CActive::EPriorityLow |
|
63 |
#define COMPLETE_DEFERRED_ACTIVE_OBJECTS_PRIORITY CActive::EPriorityIdle |
|
64 |
||
65 |
static inline int qt_pipe_write(int socket, const char *data, qint64 len) |
|
66 |
{ |
|
67 |
return ::write(socket, data, len); |
|
68 |
} |
|
69 |
#if defined(write) |
|
70 |
# undef write |
|
71 |
#endif |
|
72 |
||
73 |
static inline int qt_pipe_close(int socket) |
|
74 |
{ |
|
75 |
return ::close(socket); |
|
76 |
} |
|
77 |
#if defined(close) |
|
78 |
# undef close |
|
79 |
#endif |
|
80 |
||
81 |
static inline int qt_pipe_fcntl(int socket, int command) |
|
82 |
{ |
|
83 |
return ::fcntl(socket, command); |
|
84 |
} |
|
85 |
static inline int qt_pipe2_fcntl(int socket, int command, int option) |
|
86 |
{ |
|
87 |
return ::fcntl(socket, command, option); |
|
88 |
} |
|
89 |
#if defined(fcntl) |
|
90 |
# undef fcntl |
|
91 |
#endif |
|
92 |
||
93 |
static inline int qt_socket_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) |
|
94 |
{ |
|
95 |
return ::select(nfds, readfds, writefds, exceptfds, timeout); |
|
96 |
} |
|
97 |
||
98 |
// This simply interrupts the select and locks the mutex until destroyed. |
|
99 |
class QSelectMutexGrabber |
|
100 |
{ |
|
101 |
public: |
|
102 |
QSelectMutexGrabber(int fd, QMutex *mutex) |
|
103 |
: m_mutex(mutex) |
|
104 |
{ |
|
105 |
if (m_mutex->tryLock()) |
|
106 |
return; |
|
107 |
||
108 |
char dummy = 0; |
|
109 |
qt_pipe_write(fd, &dummy, 1); |
|
110 |
||
111 |
m_mutex->lock(); |
|
112 |
} |
|
113 |
||
114 |
~QSelectMutexGrabber() |
|
115 |
{ |
|
116 |
m_mutex->unlock(); |
|
117 |
} |
|
118 |
||
119 |
private: |
|
120 |
QMutex *m_mutex; |
|
121 |
}; |
|
122 |
||
123 |
/* |
|
124 |
* This class is designed to aid in implementing event handling in a more round robin fashion. We |
|
125 |
* cannot change active objects that we do not own, but the active objects that Qt owns will use |
|
126 |
* this as a base class with convenience functions. |
|
127 |
* |
|
128 |
* Here is how it works: On every RunL, the deriving class should call okToRun(). This will allow |
|
129 |
* exactly one run of the active object, and mark it as such. If it is called again, it will return |
|
130 |
* false, and add the object to a queue so it can be run later. |
|
131 |
* |
|
132 |
* The QCompleteDeferredAOs class is a special object that runs after all others, which will |
|
133 |
* reactivate the objects that were previously not run. |
|
134 |
*/ |
|
135 |
inline QActiveObject::QActiveObject(TInt priority, QEventDispatcherSymbian *dispatcher) |
|
136 |
: CActive(priority), |
|
137 |
m_dispatcher(dispatcher), |
|
138 |
m_hasAlreadyRun(false), |
|
139 |
m_hasRunAgain(false), |
|
140 |
m_iterationCount(1) |
|
141 |
{ |
|
142 |
} |
|
143 |
||
144 |
QActiveObject::~QActiveObject() |
|
145 |
{ |
|
146 |
if (m_hasRunAgain) |
|
147 |
m_dispatcher->removeDeferredActiveObject(this); |
|
148 |
} |
|
149 |
||
150 |
bool QActiveObject::okToRun() |
|
151 |
{ |
|
152 |
Q_ASSERT(!m_hasRunAgain); |
|
153 |
||
154 |
if (!m_hasAlreadyRun || m_dispatcher->iterationCount() != m_iterationCount) { |
|
155 |
// First occurrence of this event in this iteration. |
|
156 |
m_hasAlreadyRun = true; |
|
157 |
m_iterationCount = m_dispatcher->iterationCount(); |
|
158 |
return true; |
|
159 |
} else { |
|
160 |
// The event has already occurred. |
|
161 |
m_dispatcher->addDeferredActiveObject(this); |
|
162 |
m_hasRunAgain = true; |
|
163 |
return false; |
|
164 |
} |
|
165 |
} |
|
166 |
||
167 |
void QActiveObject::reactivateAndComplete() |
|
168 |
{ |
|
169 |
iStatus = KRequestPending; |
|
170 |
SetActive(); |
|
171 |
TRequestStatus *status = &iStatus; |
|
172 |
QEventDispatcherSymbian::RequestComplete(status, KErrNone); |
|
173 |
||
174 |
m_hasRunAgain = false; |
|
175 |
m_hasAlreadyRun = false; |
|
176 |
} |
|
177 |
||
178 |
QWakeUpActiveObject::QWakeUpActiveObject(QEventDispatcherSymbian *dispatcher) |
|
179 |
: CActive(WAKE_UP_PRIORITY), |
|
180 |
m_dispatcher(dispatcher) |
|
181 |
{ |
|
182 |
CActiveScheduler::Add(this); |
|
183 |
iStatus = KRequestPending; |
|
184 |
SetActive(); |
|
185 |
} |
|
186 |
||
187 |
QWakeUpActiveObject::~QWakeUpActiveObject() |
|
188 |
{ |
|
189 |
Cancel(); |
|
190 |
} |
|
191 |
||
192 |
void QWakeUpActiveObject::DoCancel() |
|
193 |
{ |
|
194 |
if (iStatus.Int() == KRequestPending) { |
|
195 |
TRequestStatus *status = &iStatus; |
|
196 |
QEventDispatcherSymbian::RequestComplete(status, KErrNone); |
|
197 |
} |
|
198 |
} |
|
199 |
||
200 |
void QWakeUpActiveObject::RunL() |
|
201 |
{ |
|
202 |
iStatus = KRequestPending; |
|
203 |
SetActive(); |
|
204 |
QT_TRYCATCH_LEAVING(m_dispatcher->wakeUpWasCalled()); |
|
205 |
} |
|
206 |
||
207 |
QTimerActiveObject::QTimerActiveObject(QEventDispatcherSymbian *dispatcher, SymbianTimerInfo *timerInfo) |
|
208 |
: QActiveObject((timerInfo->interval) ? TIMER_PRIORITY : NULLTIMER_PRIORITY , dispatcher), |
|
209 |
m_timerInfo(timerInfo) |
|
210 |
{ |
|
211 |
} |
|
212 |
||
213 |
QTimerActiveObject::~QTimerActiveObject() |
|
214 |
{ |
|
215 |
Cancel(); |
|
216 |
} |
|
217 |
||
218 |
void QTimerActiveObject::DoCancel() |
|
219 |
{ |
|
220 |
if (m_timerInfo->interval > 0) { |
|
221 |
m_rTimer.Cancel(); |
|
222 |
m_rTimer.Close(); |
|
223 |
} else { |
|
224 |
if (iStatus.Int() == KRequestPending) { |
|
225 |
TRequestStatus *status = &iStatus; |
|
226 |
QEventDispatcherSymbian::RequestComplete(status, KErrNone); |
|
227 |
} |
|
228 |
} |
|
229 |
} |
|
230 |
||
231 |
void QTimerActiveObject::RunL() |
|
232 |
{ |
|
233 |
int error; |
|
234 |
QT_TRYCATCH_ERROR(error, Run()); |
|
235 |
// All Symbian error codes are negative. |
|
236 |
if (error < 0) { |
|
237 |
CActiveScheduler::Current()->Error(error); // stop and report here, as this timer will be deleted on scope exit |
|
238 |
} |
|
239 |
} |
|
240 |
||
241 |
#define MAX_SYMBIAN_TIMEOUT_MS 2000000 |
|
242 |
void QTimerActiveObject::StartTimer() |
|
243 |
{ |
|
244 |
if (m_timerInfo->msLeft > MAX_SYMBIAN_TIMEOUT_MS) { |
|
245 |
//There is loss of accuracy anyway due to needing to restart the timer every 33 minutes, |
|
246 |
//so the 1/64s res of After() is acceptable for these very long timers. |
|
247 |
m_rTimer.After(iStatus, MAX_SYMBIAN_TIMEOUT_MS * 1000); |
|
248 |
m_timerInfo->msLeft -= MAX_SYMBIAN_TIMEOUT_MS; |
|
249 |
} else { |
|
250 |
//HighRes gives the 1ms accuracy expected by Qt, the +1 is to ensure that |
|
251 |
//"Timers will never time out earlier than the specified timeout value" |
|
252 |
//condition is always met. |
|
253 |
m_rTimer.HighRes(iStatus, (m_timerInfo->msLeft + 1) * 1000); |
|
254 |
m_timerInfo->msLeft = 0; |
|
255 |
} |
|
256 |
SetActive(); |
|
257 |
} |
|
258 |
||
259 |
void QTimerActiveObject::Run() |
|
260 |
{ |
|
261 |
//restart timer immediately, if the timeout has been split because it overflows max for platform. |
|
262 |
if (m_timerInfo->msLeft > 0) { |
|
263 |
StartTimer(); |
|
264 |
return; |
|
265 |
} |
|
266 |
||
267 |
if (!okToRun()) |
|
268 |
return; |
|
269 |
||
270 |
if (m_timerInfo->interval > 0) { |
|
271 |
// Start a new timer immediately so that we don't lose time. |
|
272 |
m_timerInfo->msLeft = m_timerInfo->interval; |
|
273 |
StartTimer(); |
|
274 |
||
275 |
m_timerInfo->dispatcher->timerFired(m_timerInfo->timerId); |
|
276 |
} else { |
|
277 |
// However, we only complete zero timers after the event has finished, |
|
278 |
// in order to prevent busy looping when doing nested loops. |
|
279 |
||
280 |
// Keep the refpointer around in order to avoid deletion until the end of this function. |
|
281 |
SymbianTimerInfoPtr timerInfoPtr(m_timerInfo); |
|
282 |
||
283 |
m_timerInfo->dispatcher->timerFired(m_timerInfo->timerId); |
|
284 |
||
285 |
iStatus = KRequestPending; |
|
286 |
SetActive(); |
|
287 |
TRequestStatus *status = &iStatus; |
|
288 |
QEventDispatcherSymbian::RequestComplete(status, KErrNone); |
|
289 |
} |
|
290 |
} |
|
291 |
||
292 |
void QTimerActiveObject::Start() |
|
293 |
{ |
|
294 |
CActiveScheduler::Add(this); |
|
295 |
m_timerInfo->msLeft = m_timerInfo->interval; |
|
296 |
if (m_timerInfo->interval > 0) { |
|
297 |
m_rTimer.CreateLocal(); |
|
298 |
StartTimer(); |
|
299 |
} else { |
|
300 |
iStatus = KRequestPending; |
|
301 |
SetActive(); |
|
302 |
TRequestStatus *status = &iStatus; |
|
303 |
QEventDispatcherSymbian::RequestComplete(status, KErrNone); |
|
304 |
} |
|
305 |
} |
|
306 |
||
307 |
SymbianTimerInfo::SymbianTimerInfo() |
|
308 |
: timerAO(0) |
|
309 |
{ |
|
310 |
} |
|
311 |
||
312 |
SymbianTimerInfo::~SymbianTimerInfo() |
|
313 |
{ |
|
314 |
delete timerAO; |
|
315 |
} |
|
316 |
||
317 |
QCompleteDeferredAOs::QCompleteDeferredAOs(QEventDispatcherSymbian *dispatcher) |
|
318 |
: CActive(COMPLETE_DEFERRED_ACTIVE_OBJECTS_PRIORITY), |
|
319 |
m_dispatcher(dispatcher) |
|
320 |
{ |
|
321 |
CActiveScheduler::Add(this); |
|
322 |
iStatus = KRequestPending; |
|
323 |
SetActive(); |
|
324 |
} |
|
325 |
||
326 |
QCompleteDeferredAOs::~QCompleteDeferredAOs() |
|
327 |
{ |
|
328 |
Cancel(); |
|
329 |
} |
|
330 |
||
331 |
void QCompleteDeferredAOs::complete() |
|
332 |
{ |
|
333 |
if (iStatus.Int() == KRequestPending) { |
|
334 |
TRequestStatus *status = &iStatus; |
|
335 |
QEventDispatcherSymbian::RequestComplete(status, KErrNone); |
|
336 |
} |
|
337 |
} |
|
338 |
||
339 |
void QCompleteDeferredAOs::DoCancel() |
|
340 |
{ |
|
341 |
if (iStatus.Int() == KRequestPending) { |
|
342 |
TRequestStatus *status = &iStatus; |
|
343 |
QEventDispatcherSymbian::RequestComplete(status, KErrNone); |
|
344 |
} |
|
345 |
} |
|
346 |
||
347 |
void QCompleteDeferredAOs::RunL() |
|
348 |
{ |
|
349 |
iStatus = KRequestPending; |
|
350 |
SetActive(); |
|
351 |
||
352 |
QT_TRYCATCH_LEAVING(m_dispatcher->reactivateDeferredActiveObjects()); |
|
353 |
} |
|
354 |
||
355 |
QSelectThread::QSelectThread() |
|
356 |
: m_quit(false) |
|
357 |
{ |
|
358 |
if (::pipe(m_pipeEnds) != 0) { |
|
359 |
qWarning("Select thread was unable to open a pipe, errno: %i", errno); |
|
360 |
} else { |
|
361 |
int flags0 = qt_pipe_fcntl(m_pipeEnds[0], F_GETFL); |
|
362 |
int flags1 = qt_pipe_fcntl(m_pipeEnds[1], F_GETFL); |
|
363 |
// We should check the error code here, but Open C has a bug that returns |
|
364 |
// failure even though the operation was successful. |
|
365 |
qt_pipe2_fcntl(m_pipeEnds[0], F_SETFL, flags0 | O_NONBLOCK); |
|
366 |
qt_pipe2_fcntl(m_pipeEnds[1], F_SETFL, flags1 | O_NONBLOCK); |
|
367 |
} |
|
368 |
} |
|
369 |
||
370 |
QSelectThread::~QSelectThread() |
|
371 |
{ |
|
372 |
qt_pipe_close(m_pipeEnds[1]); |
|
373 |
qt_pipe_close(m_pipeEnds[0]); |
|
374 |
} |
|
375 |
||
376 |
void QSelectThread::run() |
|
377 |
{ |
|
378 |
Q_D(QThread); |
|
379 |
||
380 |
m_mutex.lock(); |
|
381 |
||
382 |
while (!m_quit) { |
|
383 |
fd_set readfds; |
|
384 |
fd_set writefds; |
|
385 |
fd_set exceptionfds; |
|
386 |
||
387 |
FD_ZERO(&readfds); |
|
388 |
FD_ZERO(&writefds); |
|
389 |
FD_ZERO(&exceptionfds); |
|
390 |
||
391 |
int maxfd = 0; |
|
392 |
maxfd = qMax(maxfd, updateSocketSet(QSocketNotifier::Read, &readfds)); |
|
393 |
maxfd = qMax(maxfd, updateSocketSet(QSocketNotifier::Write, &writefds)); |
|
394 |
maxfd = qMax(maxfd, updateSocketSet(QSocketNotifier::Exception, &exceptionfds)); |
|
395 |
maxfd = qMax(maxfd, m_pipeEnds[0]); |
|
396 |
maxfd++; |
|
397 |
||
398 |
FD_SET(m_pipeEnds[0], &readfds); |
|
399 |
||
400 |
int ret; |
|
401 |
int savedSelectErrno; |
|
402 |
ret = qt_socket_select(maxfd, &readfds, &writefds, &exceptionfds, 0); |
|
403 |
savedSelectErrno = errno; |
|
404 |
||
405 |
char buffer; |
|
406 |
||
407 |
while (::read(m_pipeEnds[0], &buffer, 1) > 0) {} |
|
408 |
||
409 |
if(ret == 0) { |
|
410 |
// do nothing |
|
411 |
} else if (ret < 0) { |
|
412 |
switch (savedSelectErrno) { |
|
413 |
case EBADF: |
|
414 |
case EINVAL: |
|
415 |
case ENOMEM: |
|
416 |
case EFAULT: |
|
417 |
qWarning("::select() returned an error: %i", savedSelectErrno); |
|
418 |
break; |
|
419 |
case ECONNREFUSED: |
|
420 |
case EPIPE: |
|
421 |
qWarning("::select() returned an error: %i (go through sockets)", savedSelectErrno); |
|
422 |
// prepare to go through all sockets |
|
423 |
// mark in fd sets both: |
|
424 |
// good ones |
|
425 |
// ones that return -1 in select |
|
426 |
// after loop update notifiers for all of them |
|
427 |
||
428 |
// as we dont have "exception" notifier type |
|
429 |
// we should force monitoring fd_set of this |
|
430 |
// type as well |
|
431 |
||
432 |
// clean @ start |
|
433 |
FD_ZERO(&readfds); |
|
434 |
FD_ZERO(&writefds); |
|
435 |
FD_ZERO(&exceptionfds); |
|
436 |
for (QHash<QSocketNotifier *, TRequestStatus *>::const_iterator i = m_AOStatuses.begin(); |
|
437 |
i != m_AOStatuses.end(); ++i) { |
|
438 |
||
439 |
fd_set onefds; |
|
440 |
FD_ZERO(&onefds); |
|
441 |
FD_SET(i.key()->socket(), &onefds); |
|
442 |
||
443 |
fd_set excfds; |
|
444 |
FD_ZERO(&excfds); |
|
445 |
FD_SET(i.key()->socket(), &excfds); |
|
446 |
||
447 |
maxfd = i.key()->socket() + 1; |
|
448 |
||
449 |
struct timeval timeout; |
|
450 |
timeout.tv_sec = 0; |
|
451 |
timeout.tv_usec = 0; |
|
452 |
||
453 |
ret = 0; |
|
454 |
||
455 |
if(i.key()->type() == QSocketNotifier::Read) { |
|
456 |
ret = ::select(maxfd, &onefds, 0, &excfds, &timeout); |
|
457 |
if(ret != 0) FD_SET(i.key()->socket(), &readfds); |
|
458 |
} else if(i.key()->type() == QSocketNotifier::Write) { |
|
459 |
ret = ::select(maxfd, 0, &onefds, &excfds, &timeout); |
|
460 |
if(ret != 0) FD_SET(i.key()->socket(), &writefds); |
|
461 |
} |
|
462 |
||
463 |
} // end for |
|
464 |
||
465 |
// traversed all, so update |
|
466 |
updateActivatedNotifiers(QSocketNotifier::Read, &readfds); |
|
467 |
updateActivatedNotifiers(QSocketNotifier::Write, &writefds); |
|
468 |
updateActivatedNotifiers(QSocketNotifier::Exception, &exceptionfds); |
|
469 |
||
470 |
break; |
|
471 |
case EINTR: // Should never occur on Symbian, but this is future proof! |
|
472 |
default: |
|
473 |
qWarning("::select() returned an unknown error: %i", savedSelectErrno); |
|
474 |
||
475 |
break; |
|
476 |
} |
|
477 |
} else { |
|
478 |
updateActivatedNotifiers(QSocketNotifier::Read, &readfds); |
|
479 |
updateActivatedNotifiers(QSocketNotifier::Write, &writefds); |
|
480 |
updateActivatedNotifiers(QSocketNotifier::Exception, &exceptionfds); |
|
481 |
} |
|
482 |
||
483 |
m_waitCond.wait(&m_mutex); |
|
484 |
} |
|
485 |
||
486 |
m_mutex.unlock(); |
|
487 |
} |
|
488 |
||
489 |
void QSelectThread::requestSocketEvents ( QSocketNotifier *notifier, TRequestStatus *status ) |
|
490 |
{ |
|
491 |
Q_D(QThread); |
|
492 |
||
493 |
if (!isRunning()) { |
|
494 |
start(); |
|
495 |
} |
|
496 |
||
497 |
QSelectMutexGrabber lock(m_pipeEnds[1], &m_mutex); |
|
498 |
||
499 |
Q_ASSERT(!m_AOStatuses.contains(notifier)); |
|
500 |
||
501 |
m_AOStatuses.insert(notifier, status); |
|
502 |
||
503 |
m_waitCond.wakeAll(); |
|
504 |
} |
|
505 |
||
506 |
void QSelectThread::cancelSocketEvents ( QSocketNotifier *notifier ) |
|
507 |
{ |
|
508 |
QSelectMutexGrabber lock(m_pipeEnds[1], &m_mutex); |
|
509 |
||
510 |
m_AOStatuses.remove(notifier); |
|
511 |
||
512 |
m_waitCond.wakeAll(); |
|
513 |
} |
|
514 |
||
515 |
void QSelectThread::restart() |
|
516 |
{ |
|
517 |
QSelectMutexGrabber lock(m_pipeEnds[1], &m_mutex); |
|
518 |
||
519 |
m_waitCond.wakeAll(); |
|
520 |
} |
|
521 |
||
522 |
int QSelectThread::updateSocketSet(QSocketNotifier::Type type, fd_set *fds) |
|
523 |
{ |
|
524 |
int maxfd = 0; |
|
525 |
if(m_AOStatuses.isEmpty()) { |
|
526 |
/* |
|
527 |
* Wonder if should return -1 |
|
528 |
* to signal that no descriptors |
|
529 |
* added to fds |
|
530 |
*/ |
|
531 |
return maxfd; |
|
532 |
} |
|
533 |
for ( QHash<QSocketNotifier *, TRequestStatus *>::const_iterator i = m_AOStatuses.begin(); |
|
534 |
i != m_AOStatuses.end(); ++i) { |
|
535 |
if (i.key()->type() == type) { |
|
536 |
FD_SET(i.key()->socket(), fds); |
|
537 |
maxfd = qMax(maxfd, i.key()->socket()); |
|
538 |
} else if(type == QSocketNotifier::Exception) { |
|
539 |
/* |
|
540 |
* We are registering existing sockets |
|
541 |
* always to exception set |
|
542 |
* |
|
543 |
* Doing double FD_SET shouldn't |
|
544 |
* matter |
|
545 |
*/ |
|
546 |
FD_SET(i.key()->socket(), fds); |
|
547 |
maxfd = qMax(maxfd, i.key()->socket()); |
|
548 |
} |
|
549 |
} |
|
550 |
||
551 |
return maxfd; |
|
552 |
} |
|
553 |
||
554 |
void QSelectThread::updateActivatedNotifiers(QSocketNotifier::Type type, fd_set *fds) |
|
555 |
{ |
|
556 |
Q_D(QThread); |
|
557 |
if(m_AOStatuses.isEmpty()) { |
|
558 |
return; |
|
559 |
} |
|
560 |
QList<QSocketNotifier *> toRemove; |
|
561 |
for (QHash<QSocketNotifier *, TRequestStatus *>::const_iterator i = m_AOStatuses.begin(); |
|
562 |
i != m_AOStatuses.end(); ++i) { |
|
563 |
if (i.key()->type() == type && FD_ISSET(i.key()->socket(), fds)) { |
|
564 |
toRemove.append(i.key()); |
|
565 |
TRequestStatus *status = i.value(); |
|
566 |
// Thread data is still owned by the main thread. |
|
567 |
QEventDispatcherSymbian::RequestComplete(d->threadData->symbian_thread_handle, status, KErrNone); |
|
568 |
} else if(type == QSocketNotifier::Exception && FD_ISSET(i.key()->socket(), fds)) { |
|
569 |
/* |
|
570 |
* check if socket is in exception set |
|
571 |
* then signal RequestComplete for it |
|
572 |
*/ |
|
573 |
qWarning("exception on %d", i.key()->socket()); |
|
574 |
toRemove.append(i.key()); |
|
575 |
TRequestStatus *status = i.value(); |
|
576 |
QEventDispatcherSymbian::RequestComplete(d->threadData->symbian_thread_handle, status, KErrNone); |
|
577 |
} |
|
578 |
} |
|
579 |
||
580 |
for (int c = 0; c < toRemove.size(); ++c) { |
|
581 |
m_AOStatuses.remove(toRemove[c]); |
|
582 |
} |
|
583 |
} |
|
584 |
||
585 |
void QSelectThread::stop() |
|
586 |
{ |
|
587 |
m_quit = true; |
|
588 |
restart(); |
|
589 |
wait(); |
|
590 |
} |
|
591 |
||
592 |
QSocketActiveObject::QSocketActiveObject(QEventDispatcherSymbian *dispatcher, QSocketNotifier *notifier) |
|
593 |
: QActiveObject(CActive::EPriorityStandard, dispatcher), |
|
594 |
m_notifier(notifier), |
|
595 |
m_inSocketEvent(false), |
|
596 |
m_deleteLater(false) |
|
597 |
{ |
|
598 |
CActiveScheduler::Add(this); |
|
599 |
iStatus = KRequestPending; |
|
600 |
SetActive(); |
|
601 |
} |
|
602 |
||
603 |
QSocketActiveObject::~QSocketActiveObject() |
|
604 |
{ |
|
605 |
Cancel(); |
|
606 |
} |
|
607 |
||
608 |
void QSocketActiveObject::DoCancel() |
|
609 |
{ |
|
610 |
if (iStatus.Int() == KRequestPending) { |
|
611 |
TRequestStatus *status = &iStatus; |
|
612 |
QEventDispatcherSymbian::RequestComplete(status, KErrNone); |
|
613 |
} |
|
614 |
} |
|
615 |
||
616 |
void QSocketActiveObject::RunL() |
|
617 |
{ |
|
618 |
if (!okToRun()) |
|
619 |
return; |
|
620 |
||
621 |
QT_TRYCATCH_LEAVING(m_dispatcher->socketFired(this)); |
|
622 |
} |
|
623 |
||
624 |
void QSocketActiveObject::deleteLater() |
|
625 |
{ |
|
626 |
if (m_inSocketEvent) { |
|
627 |
m_deleteLater = true; |
|
628 |
} else { |
|
629 |
delete this; |
|
630 |
} |
|
631 |
} |
|
632 |
||
633 |
QEventDispatcherSymbian::QEventDispatcherSymbian(QObject *parent) |
|
634 |
: QAbstractEventDispatcher(parent), |
|
635 |
m_activeScheduler(0), |
|
636 |
m_wakeUpAO(0), |
|
637 |
m_completeDeferredAOs(0), |
|
638 |
m_interrupt(false), |
|
639 |
m_wakeUpDone(0), |
|
640 |
m_iterationCount(0), |
|
641 |
m_noSocketEvents(false) |
|
642 |
{ |
|
643 |
} |
|
644 |
||
645 |
QEventDispatcherSymbian::~QEventDispatcherSymbian() |
|
646 |
{ |
|
647 |
m_processHandle.Close(); |
|
648 |
} |
|
649 |
||
650 |
void QEventDispatcherSymbian::startingUp() |
|
651 |
{ |
|
652 |
if( !CActiveScheduler::Current() ) { |
|
653 |
m_activeScheduler = q_check_ptr(new CQtActiveScheduler()); // CBase derived class needs to be checked on new |
|
654 |
CActiveScheduler::Install(m_activeScheduler); |
|
655 |
} |
|
656 |
m_wakeUpAO = q_check_ptr(new QWakeUpActiveObject(this)); |
|
657 |
m_completeDeferredAOs = q_check_ptr(new QCompleteDeferredAOs(this)); |
|
658 |
// We already might have posted events, wakeup once to process them |
|
659 |
wakeUp(); |
|
660 |
} |
|
661 |
||
662 |
void QEventDispatcherSymbian::closingDown() |
|
663 |
{ |
|
664 |
if (m_selectThread.isRunning()) { |
|
665 |
m_selectThread.stop(); |
|
666 |
} |
|
667 |
||
668 |
delete m_completeDeferredAOs; |
|
669 |
delete m_wakeUpAO; |
|
670 |
if (m_activeScheduler) { |
|
671 |
delete m_activeScheduler; |
|
672 |
} |
|
673 |
} |
|
674 |
||
675 |
bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags flags ) |
|
676 |
{ |
|
677 |
bool handledAnyEvent = false; |
|
678 |
bool oldNoSocketEventsValue = m_noSocketEvents; |
|
679 |
||
680 |
QT_TRY { |
|
681 |
Q_D(QAbstractEventDispatcher); |
|
682 |
||
683 |
// It is safe if this counter overflows. The main importance is that each |
|
684 |
// iteration count is different from the last. |
|
685 |
m_iterationCount++; |
|
686 |
||
687 |
RThread &thread = d->threadData->symbian_thread_handle; |
|
688 |
||
689 |
bool block; |
|
690 |
if (flags & QEventLoop::WaitForMoreEvents) { |
|
691 |
block = true; |
|
692 |
emit aboutToBlock(); |
|
693 |
} else { |
|
694 |
block = false; |
|
695 |
} |
|
696 |
||
697 |
if (flags & QEventLoop::ExcludeSocketNotifiers) { |
|
698 |
m_noSocketEvents = true; |
|
699 |
} else { |
|
700 |
m_noSocketEvents = false; |
|
701 |
handledAnyEvent = sendDeferredSocketEvents(); |
|
702 |
} |
|
703 |
||
704 |
bool handledSymbianEvent = false; |
|
705 |
m_interrupt = false; |
|
706 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
707 |
#ifdef QT_SYMBIAN_PRIORITY_DROP |
0 | 708 |
/* |
709 |
* This QTime variable is used to measure the time it takes to finish |
|
710 |
* the event loop. If we take too long in the loop, other processes |
|
711 |
* may be starved and killed. After the first event has completed, we |
|
712 |
* take the current time, and if the remaining events take longer than |
|
713 |
* a preset time, we temporarily lower the priority to force a context |
|
714 |
* switch. For applications that do not take unecessarily long in the |
|
715 |
* event loop, the priority will not be altered. |
|
716 |
*/ |
|
717 |
QTime time; |
|
718 |
enum { |
|
719 |
FirstRun, |
|
720 |
SubsequentRun, |
|
721 |
TimeStarted |
|
722 |
} timeState = FirstRun; |
|
723 |
||
724 |
TProcessPriority priority; |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
725 |
#endif |
0 | 726 |
|
727 |
while (1) { |
|
728 |
if (block) { |
|
729 |
// This is where Qt will spend most of its time. |
|
730 |
CActiveScheduler::Current()->WaitForAnyRequest(); |
|
731 |
} else { |
|
732 |
if (thread.RequestCount() == 0) { |
|
733 |
break; |
|
734 |
} |
|
735 |
// This one should return without delay. |
|
736 |
CActiveScheduler::Current()->WaitForAnyRequest(); |
|
737 |
} |
|
738 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
739 |
#ifdef QT_SYMBIAN_PRIORITY_DROP |
0 | 740 |
if (timeState == SubsequentRun) { |
741 |
time.start(); |
|
742 |
timeState = TimeStarted; |
|
743 |
} |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
744 |
#endif |
0 | 745 |
|
746 |
TInt error; |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
747 |
handledSymbianEvent = CActiveScheduler::RunIfReady(error, KMinTInt); |
0 | 748 |
if (error) { |
749 |
qWarning("CActiveScheduler::RunIfReady() returned error: %i\n", error); |
|
750 |
CActiveScheduler::Current()->Error(error); |
|
751 |
} |
|
752 |
||
753 |
if (!handledSymbianEvent) { |
|
754 |
qFatal("QEventDispatcherSymbian::processEvents(): Caught Symbian stray signal"); |
|
755 |
} |
|
756 |
handledAnyEvent = true; |
|
757 |
if (m_interrupt) { |
|
758 |
break; |
|
759 |
} |
|
760 |
block = false; |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
761 |
#ifdef QT_SYMBIAN_PRIORITY_DROP |
0 | 762 |
if (timeState == TimeStarted && time.elapsed() > 100) { |
763 |
priority = m_processHandle.Priority(); |
|
764 |
m_processHandle.SetPriority(EPriorityBackground); |
|
765 |
time.start(); |
|
766 |
// Slight chance of race condition in the next lines, but nothing fatal |
|
767 |
// will happen, just wrong priority. |
|
768 |
if (m_processHandle.Priority() == EPriorityBackground) { |
|
769 |
m_processHandle.SetPriority(priority); |
|
770 |
} |
|
771 |
} |
|
772 |
if (timeState == FirstRun) |
|
773 |
timeState = SubsequentRun; |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
774 |
#endif |
0 | 775 |
}; |
776 |
||
777 |
emit awake(); |
|
778 |
} QT_CATCH (const std::exception& ex) { |
|
779 |
#ifndef QT_NO_EXCEPTIONS |
|
780 |
CActiveScheduler::Current()->Error(qt_symbian_exception2Error(ex)); |
|
781 |
#endif |
|
782 |
} |
|
783 |
||
784 |
m_noSocketEvents = oldNoSocketEventsValue; |
|
785 |
||
786 |
return handledAnyEvent; |
|
787 |
} |
|
788 |
||
789 |
void QEventDispatcherSymbian::timerFired(int timerId) |
|
790 |
{ |
|
791 |
QHash<int, SymbianTimerInfoPtr>::iterator i = m_timerList.find(timerId); |
|
792 |
if (i == m_timerList.end()) { |
|
793 |
// The timer has been deleted. Ignore this event. |
|
794 |
return; |
|
795 |
} |
|
796 |
||
797 |
SymbianTimerInfoPtr timerInfo = *i; |
|
798 |
||
799 |
// Prevent infinite timer recursion. |
|
800 |
if (timerInfo->inTimerEvent) { |
|
801 |
return; |
|
802 |
} |
|
803 |
||
804 |
timerInfo->inTimerEvent = true; |
|
805 |
||
806 |
QTimerEvent event(timerInfo->timerId); |
|
807 |
QCoreApplication::sendEvent(timerInfo->receiver, &event); |
|
808 |
||
809 |
timerInfo->inTimerEvent = false; |
|
810 |
||
811 |
return; |
|
812 |
} |
|
813 |
||
814 |
void QEventDispatcherSymbian::socketFired(QSocketActiveObject *socketAO) |
|
815 |
{ |
|
816 |
if (m_noSocketEvents) { |
|
817 |
m_deferredSocketEvents.append(socketAO); |
|
818 |
return; |
|
819 |
} |
|
820 |
||
821 |
QEvent e(QEvent::SockAct); |
|
822 |
socketAO->m_inSocketEvent = true; |
|
823 |
QCoreApplication::sendEvent(socketAO->m_notifier, &e); |
|
824 |
socketAO->m_inSocketEvent = false; |
|
825 |
||
826 |
if (socketAO->m_deleteLater) { |
|
827 |
delete socketAO; |
|
828 |
} else { |
|
829 |
socketAO->iStatus = KRequestPending; |
|
830 |
socketAO->SetActive(); |
|
831 |
reactivateSocketNotifier(socketAO->m_notifier); |
|
832 |
} |
|
833 |
} |
|
834 |
||
835 |
void QEventDispatcherSymbian::wakeUpWasCalled() |
|
836 |
{ |
|
837 |
// The reactivation should happen in RunL, right before the call to this function. |
|
838 |
// This is because m_wakeUpDone is the "signal" that the object can be completed |
|
839 |
// once more. |
|
840 |
// Also, by dispatching the posted events after resetting m_wakeUpDone, we guarantee |
|
841 |
// that no posted event notification will be lost. If we did it the other way |
|
842 |
// around, it would be possible for another thread to post an event right after |
|
843 |
// the sendPostedEvents was done, but before the object was ready to be completed |
|
844 |
// again. This could deadlock the application if there are no other posted events. |
|
845 |
m_wakeUpDone.fetchAndStoreOrdered(0); |
|
846 |
sendPostedEvents(); |
|
847 |
} |
|
848 |
||
849 |
void QEventDispatcherSymbian::interrupt() |
|
850 |
{ |
|
851 |
m_interrupt = true; |
|
852 |
wakeUp(); |
|
853 |
} |
|
854 |
||
855 |
void QEventDispatcherSymbian::wakeUp() |
|
856 |
{ |
|
857 |
Q_D(QAbstractEventDispatcher); |
|
858 |
||
859 |
if (m_wakeUpAO && m_wakeUpDone.testAndSetAcquire(0, 1)) { |
|
860 |
TRequestStatus *status = &m_wakeUpAO->iStatus; |
|
861 |
QEventDispatcherSymbian::RequestComplete(d->threadData->symbian_thread_handle, status, KErrNone); |
|
862 |
} |
|
863 |
} |
|
864 |
||
865 |
bool QEventDispatcherSymbian::sendPostedEvents() |
|
866 |
{ |
|
867 |
Q_D(QAbstractEventDispatcher); |
|
868 |
||
869 |
// moveToThread calls this and canWait == true -> Events will never get processed |
|
870 |
// if we check for d->threadData->canWait |
|
871 |
// |
|
872 |
// QCoreApplication::postEvent sets canWait = false, but after the object and events |
|
873 |
// are moved to a new thread, the canWait in new thread is true i.e. not changed to reflect |
|
874 |
// the flag on old thread. That's why events in a new thread will not get processed. |
|
875 |
// This migth be actually bug in moveToThread functionality, but because other platforms |
|
876 |
// do not check canWait in wakeUp (where we essentially are now) - decided to remove it from |
|
877 |
// here as well. |
|
878 |
||
879 |
//if (!d->threadData->canWait) { |
|
880 |
QCoreApplicationPrivate::sendPostedEvents(0, 0, d->threadData); |
|
881 |
return true; |
|
882 |
//} |
|
883 |
//return false; |
|
884 |
} |
|
885 |
||
886 |
inline void QEventDispatcherSymbian::addDeferredActiveObject(QActiveObject *object) |
|
887 |
{ |
|
888 |
if (m_deferredActiveObjects.isEmpty()) { |
|
889 |
m_completeDeferredAOs->complete(); |
|
890 |
} |
|
891 |
m_deferredActiveObjects.append(object); |
|
892 |
} |
|
893 |
||
894 |
inline void QEventDispatcherSymbian::removeDeferredActiveObject(QActiveObject *object) |
|
895 |
{ |
|
896 |
m_deferredActiveObjects.removeAll(object); |
|
897 |
} |
|
898 |
||
899 |
void QEventDispatcherSymbian::reactivateDeferredActiveObjects() |
|
900 |
{ |
|
901 |
while (!m_deferredActiveObjects.isEmpty()) { |
|
902 |
QActiveObject *object = m_deferredActiveObjects.takeFirst(); |
|
903 |
object->reactivateAndComplete(); |
|
904 |
} |
|
905 |
||
906 |
// We do this because we want to return from processEvents. This is because |
|
907 |
// each invocation of processEvents should only run each active object once. |
|
908 |
// The active scheduler should run them continously, however. |
|
909 |
m_interrupt = true; |
|
910 |
} |
|
911 |
||
912 |
bool QEventDispatcherSymbian::sendDeferredSocketEvents() |
|
913 |
{ |
|
914 |
bool sentAnyEvents = false; |
|
915 |
while (!m_deferredSocketEvents.isEmpty()) { |
|
916 |
sentAnyEvents = true; |
|
917 |
socketFired(m_deferredSocketEvents.takeFirst()); |
|
918 |
} |
|
919 |
||
920 |
return sentAnyEvents; |
|
921 |
} |
|
922 |
||
923 |
void QEventDispatcherSymbian::flush() |
|
924 |
{ |
|
925 |
} |
|
926 |
||
927 |
bool QEventDispatcherSymbian::hasPendingEvents() |
|
928 |
{ |
|
929 |
Q_D(QAbstractEventDispatcher); |
|
930 |
return (d->threadData->symbian_thread_handle.RequestCount() != 0 |
|
931 |
|| !d->threadData->canWait || !m_deferredSocketEvents.isEmpty()); |
|
932 |
} |
|
933 |
||
934 |
void QEventDispatcherSymbian::registerSocketNotifier ( QSocketNotifier * notifier ) |
|
935 |
{ |
|
936 |
QSocketActiveObject *socketAO = q_check_ptr(new QSocketActiveObject(this, notifier)); |
|
937 |
m_notifiers.insert(notifier, socketAO); |
|
938 |
m_selectThread.requestSocketEvents(notifier, &socketAO->iStatus); |
|
939 |
} |
|
940 |
||
941 |
void QEventDispatcherSymbian::unregisterSocketNotifier ( QSocketNotifier * notifier ) |
|
942 |
{ |
|
943 |
m_selectThread.cancelSocketEvents(notifier); |
|
944 |
if (m_notifiers.contains(notifier)) { |
|
945 |
QSocketActiveObject *sockObj = *m_notifiers.find(notifier); |
|
946 |
m_deferredSocketEvents.removeAll(sockObj); |
|
947 |
sockObj->deleteLater(); |
|
948 |
m_notifiers.remove(notifier); |
|
949 |
} |
|
950 |
} |
|
951 |
||
952 |
void QEventDispatcherSymbian::reactivateSocketNotifier(QSocketNotifier *notifier) |
|
953 |
{ |
|
954 |
m_selectThread.requestSocketEvents(notifier, &m_notifiers[notifier]->iStatus); |
|
955 |
} |
|
956 |
||
957 |
void QEventDispatcherSymbian::registerTimer ( int timerId, int interval, QObject * object ) |
|
958 |
{ |
|
959 |
if (interval < 0) { |
|
960 |
qWarning("Timer interval < 0"); |
|
961 |
interval = 0; |
|
962 |
} |
|
963 |
||
964 |
SymbianTimerInfoPtr timer(new SymbianTimerInfo); |
|
965 |
timer->timerId = timerId; |
|
966 |
timer->interval = interval; |
|
967 |
timer->inTimerEvent = false; |
|
968 |
timer->receiver = object; |
|
969 |
timer->dispatcher = this; |
|
970 |
timer->timerAO = q_check_ptr(new QTimerActiveObject(this, timer.data())); |
|
971 |
m_timerList.insert(timerId, timer); |
|
972 |
||
973 |
timer->timerAO->Start(); |
|
974 |
} |
|
975 |
||
976 |
bool QEventDispatcherSymbian::unregisterTimer ( int timerId ) |
|
977 |
{ |
|
978 |
if (!m_timerList.contains(timerId)) { |
|
979 |
return false; |
|
980 |
} |
|
981 |
||
982 |
SymbianTimerInfoPtr timerInfo = m_timerList.take(timerId); |
|
983 |
||
984 |
if (!QObjectPrivate::get(timerInfo->receiver)->inThreadChangeEvent) |
|
985 |
QAbstractEventDispatcherPrivate::releaseTimerId(timerId); |
|
986 |
||
987 |
return true; |
|
988 |
} |
|
989 |
||
990 |
bool QEventDispatcherSymbian::unregisterTimers ( QObject * object ) |
|
991 |
{ |
|
992 |
if (m_timerList.isEmpty()) |
|
993 |
return false; |
|
994 |
||
995 |
bool unregistered = false; |
|
996 |
for (QHash<int, SymbianTimerInfoPtr>::iterator i = m_timerList.begin(); i != m_timerList.end(); ) { |
|
997 |
if ((*i)->receiver == object) { |
|
998 |
i = m_timerList.erase(i); |
|
999 |
unregistered = true; |
|
1000 |
} else { |
|
1001 |
++i; |
|
1002 |
} |
|
1003 |
} |
|
1004 |
||
1005 |
return unregistered; |
|
1006 |
} |
|
1007 |
||
1008 |
QList<QEventDispatcherSymbian::TimerInfo> QEventDispatcherSymbian::registeredTimers ( QObject * object ) const |
|
1009 |
{ |
|
1010 |
QList<TimerInfo> list; |
|
1011 |
for (QHash<int, SymbianTimerInfoPtr>::const_iterator i = m_timerList.begin(); i != m_timerList.end(); ++i) { |
|
1012 |
if ((*i)->receiver == object) { |
|
1013 |
list.push_back(TimerInfo((*i)->timerId, (*i)->interval)); |
|
1014 |
} |
|
1015 |
} |
|
1016 |
||
1017 |
return list; |
|
1018 |
} |
|
1019 |
||
1020 |
/* |
|
1021 |
* This active scheduler class implements a simple report and continue policy, for Symbian OS leaves |
|
1022 |
* or exceptions from Qt that fall back to the scheduler. |
|
1023 |
* It will be used in cases where there is no existing active scheduler installed. |
|
1024 |
* Apps which link to qts60main.lib will have the UI active scheduler installed in the main thread |
|
1025 |
* instead of this one. But this would be used in other threads in the UI. |
|
1026 |
* An app could replace this behaviour by installing an alternative active scheduler. |
|
1027 |
*/ |
|
1028 |
void CQtActiveScheduler::Error(TInt aError) const |
|
1029 |
{ |
|
1030 |
QT_TRY { |
|
1031 |
qWarning("Error from active scheduler %d", aError); |
|
1032 |
} |
|
1033 |
QT_CATCH (const std::bad_alloc&) {} // ignore alloc fails, nothing more can be done |
|
1034 |
} |
|
1035 |
||
1036 |
QT_END_NAMESPACE |