diff options
author | Jonathan Liu <net147@gmail.com> | 2014-09-18 19:54:46 +1000 |
---|---|---|
committer | Jonathan Liu <net147@gmail.com> | 2014-09-23 00:47:34 +0200 |
commit | 7b7ad02681f2c28fb18d053618f6804e989b2f56 (patch) | |
tree | c79a8a04b4352f2ffac6b63a449d73c53787bd2e /src/corelib/kernel/qtimer.cpp | |
parent | a6316e6e744815c89b2d7bd7946e04549d183769 (diff) |
Improve checking for event/socket notifiers and timers
Starting/stopping timers from another thread may result in errors that
may not appear until hours, days or weeks after if a release build of
Qt is used with the GLib/UNIX event dispatchers. Such errors may
manifest as warnings such as "QObject::killTimer(): Error: timer id 7
is not valid for object 0x2a51b488 (), timer has not been killed" and
application crashes (e.g. crashes in malloc, realloc and
malloc_consolidate).
Initial-patch-by: Eike Ziller <eike.ziller@digia.com>
Task-number: QTBUG-40636
Change-Id: I2de50d50eb1fc7467fcebb9c73b74d2f85137933
Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/kernel/qtimer.cpp')
-rw-r--r-- | src/corelib/kernel/qtimer.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/corelib/kernel/qtimer.cpp b/src/corelib/kernel/qtimer.cpp index 97aae6f7e0..5c09b483c6 100644 --- a/src/corelib/kernel/qtimer.cpp +++ b/src/corelib/kernel/qtimer.cpp @@ -395,6 +395,10 @@ void QTimer::singleShot(int msec, const QObject *receiver, const char *member) */ void QTimer::singleShot(int msec, Qt::TimerType timerType, const QObject *receiver, const char *member) { + if (Q_UNLIKELY(msec < 0)) { + qWarning("QTimer::singleShot: Timers cannot have negative timeouts"); + return; + } if (receiver && member) { if (msec == 0) { // special code shortpath for 0-timers |