diff options
author | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2015-07-17 15:06:22 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2015-07-17 16:35:42 +0200 |
commit | b2603b76655ac819e43c063bb6f16bc95f358083 (patch) | |
tree | 0fbe2c367ebfffdb70e9e3f21a7cf408bafd9626 /src/corelib/kernel | |
parent | 99b94aadf875c822afb6c2580e43355ac392ac92 (diff) | |
parent | 756266d01560157b7274e466b9ffc1b0e2ef9a1f (diff) |
Merge remote-tracking branch 'origin/5.5' into HEAD
Conflicts:
src/plugins/platforms/windows/qwindowsopengltester.cpp
Change-Id: Ia7abeba9395ccf84e2fa81b91a5725a86dedb9fe
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r-- | src/corelib/kernel/qcoreapplication.cpp | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qeventdispatcher_win.cpp | 21 | ||||
-rw-r--r-- | src/corelib/kernel/qeventdispatcher_win_p.h | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qeventdispatcher_winrt_p.h | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qmetaobject.cpp | 20 | ||||
-rw-r--r-- | src/corelib/kernel/qobject.cpp | 9 |
6 files changed, 32 insertions, 24 deletions
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 66481d4c87..08c0473cf0 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -392,7 +392,7 @@ static bool quitLockRefEnabled = true; // GUI apps or when using MinGW due to its globbing. static inline bool isArgvModified(int argc, char **argv) { - if (__argc != argc) + if (__argc != argc || !__argv /* wmain() */) return true; if (__argv == argv) return false; diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index ccb8341d0a..e8ff8a7936 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -560,6 +560,17 @@ static HWND qt_create_internal_window(const QEventDispatcherWin32 *eventDispatch return wnd; } +static void calculateNextTimeout(WinTimerInfo *t, quint64 currentTime) +{ + uint interval = t->interval; + if ((interval >= 20000u && t->timerType != Qt::PreciseTimer) || t->timerType == Qt::VeryCoarseTimer) { + // round the interval, VeryCoarseTimers only have full second accuracy + interval = ((interval + 500)) / 1000 * 1000; + } + t->interval = interval; + t->timeout = currentTime + interval; +} + void QEventDispatcherWin32Private::registerTimer(WinTimerInfo *t) { Q_ASSERT(internalHwnd); @@ -567,6 +578,7 @@ void QEventDispatcherWin32Private::registerTimer(WinTimerInfo *t) Q_Q(QEventDispatcherWin32); int ok = 0; + calculateNextTimeout(t, qt_msectime()); uint interval = t->interval; if (interval == 0u) { // optimization for single-shot-zero-timer @@ -575,17 +587,13 @@ void QEventDispatcherWin32Private::registerTimer(WinTimerInfo *t) } else if ((interval < 20u || t->timerType == Qt::PreciseTimer) && qtimeSetEvent) { ok = t->fastTimerId = qtimeSetEvent(interval, 1, qt_fast_timer_proc, (DWORD_PTR)t, TIME_CALLBACK_FUNCTION | TIME_PERIODIC | TIME_KILL_SYNCHRONOUS); - } else if (interval >= 20000u || t->timerType == Qt::VeryCoarseTimer) { - // round the interval, VeryCoarseTimers only have full second accuracy - interval = ((interval + 500)) / 1000 * 1000; } + if (ok == 0) { // user normal timers for (Very)CoarseTimers, or if no more multimedia timers available ok = SetTimer(internalHwnd, t->timerId, interval, 0); } - t->timeout = qt_msectime() + interval; - if (ok == 0) qErrnoWarning("QEventDispatcherWin32::registerTimer: Failed to create a timer"); } @@ -610,6 +618,9 @@ void QEventDispatcherWin32Private::sendTimerEvent(int timerId) // send event, but don't allow it to recurse t->inTimerEvent = true; + // recalculate next emission + calculateNextTimeout(t, qt_msectime()); + QTimerEvent e(t->timerId); QCoreApplication::sendEvent(t->obj, &e); diff --git a/src/corelib/kernel/qeventdispatcher_win_p.h b/src/corelib/kernel/qeventdispatcher_win_p.h index 6b4fb18f46..e59e29f1ff 100644 --- a/src/corelib/kernel/qeventdispatcher_win_p.h +++ b/src/corelib/kernel/qeventdispatcher_win_p.h @@ -58,7 +58,7 @@ class QEventDispatcherWin32Private; // forward declaration LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp); -int qt_msectime(); +quint64 qt_msectime(); class Q_CORE_EXPORT QEventDispatcherWin32 : public QAbstractEventDispatcher { diff --git a/src/corelib/kernel/qeventdispatcher_winrt_p.h b/src/corelib/kernel/qeventdispatcher_winrt_p.h index e39746aeef..fd3d259c96 100644 --- a/src/corelib/kernel/qeventdispatcher_winrt_p.h +++ b/src/corelib/kernel/qeventdispatcher_winrt_p.h @@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE -int qt_msectime(); +quint64 qt_msectime(); class QEventDispatcherWinRTPrivate; diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 60cd3ab94a..90ee7d8f95 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -1879,13 +1879,14 @@ const char *QMetaMethod::typeName() const way in the function declaration: \code + // In the class MainWindow declaration #ifndef Q_MOC_RUN - // define the tag text - # define THISISTESTTAG + // define the tag text as empty, so the compiler doesn't see it + # define MY_CUSTOM_TAG #endif ... private slots: - THISISTESTTAG void testFunc(); + MY_CUSTOM_TAG void testFunc(); \endcode and the information can be accessed by using: @@ -1895,12 +1896,14 @@ const char *QMetaMethod::typeName() const win.show(); int functionIndex = win.metaObject()->indexOfSlot("testFunc()"); - QMetaMethod mm = metaObject()->method(functionIndex); - qDebug() << mm.tag(); // prints THISISTESTTAG + QMetaMethod mm = win.metaObject()->method(functionIndex); + qDebug() << mm.tag(); // prints MY_CUSTOM_TAG \endcode For the moment, \c moc will extract and record all tags, but it will not - handle any of them specially. + handle any of them specially. You can use the tags to annotate your methods + differently, and treat them according to the specific needs of your + application. \note Since Qt 5.0, \c moc expands preprocessor macros, so it is necessary to surround the definition with \c #ifndef \c Q_MOC_RUN, as shown in the @@ -1960,8 +1963,9 @@ int QMetaMethod::revision() const Returns the access specification of this method (private, protected, or public). - Signals are always protected, meaning that you can only emit them - from the class or from a subclass. + \note Signals are always public, but you should regard that as an + implementation detail. It is almost always a bad idea to emit a signal from + outside its class. \sa methodType() */ diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index c63dd79f02..e6458382f2 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -909,14 +909,7 @@ QObject::~QObject() } if (!d->isWidget && d->isSignalConnected(0)) { - QT_TRY { - emit destroyed(this); - } QT_CATCH(...) { - // all the signal/slots connections are still in place - if we don't - // quit now, we will crash pretty soon. - qWarning("Detected an unexpected exception in ~QObject while emitting destroyed()."); - QT_RETHROW; - } + emit destroyed(this); } if (d->declarativeData) { |