diff options
author | Liang Qi <liang.qi@qt.io> | 2016-04-26 11:08:23 +0000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2016-04-26 11:08:23 +0000 |
commit | 75d4742e0481d236aba9913768f24b377603f6c6 (patch) | |
tree | f799474f9dc86fdc12ff5aea28f545e4c58d28fa /src/corelib/kernel | |
parent | 84330007e12122bf1b690a4e68b5ef8e973c7882 (diff) | |
parent | bb4b86618dc930e0035c5829e336f2606d140ada (diff) |
Merge "Merge remote-tracking branch 'origin/5.6' into 5.7" into refs/staging/5.7
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r-- | src/corelib/kernel/qcore_mac_objc.mm | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qeventdispatcher_win.cpp | 25 | ||||
-rw-r--r-- | src/corelib/kernel/qeventdispatcher_win_p.h | 4 | ||||
-rw-r--r-- | src/corelib/kernel/qeventdispatcher_winrt.cpp | 31 | ||||
-rw-r--r-- | src/corelib/kernel/qobjectdefs_impl.h | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qwineventnotifier.h | 4 |
6 files changed, 60 insertions, 8 deletions
diff --git a/src/corelib/kernel/qcore_mac_objc.mm b/src/corelib/kernel/qcore_mac_objc.mm index a923d83bcf..de491dd43d 100644 --- a/src/corelib/kernel/qcore_mac_objc.mm +++ b/src/corelib/kernel/qcore_mac_objc.mm @@ -156,7 +156,7 @@ QMacAutoReleasePool::~QMacAutoReleasePool() // Drain behaves the same as release, with the advantage that // if we're ever used in a garbage-collected environment, the // drain acts as a hint to the garbage collector to collect. - [pool drain]; + [static_cast<NSAutoreleasePool*>(pool) drain]; } // ------------------------------------------------------------------------- diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index 4d7aa83c43..166e509635 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -316,7 +316,10 @@ static void resolveTimerAPI() QEventDispatcherWin32Private::QEventDispatcherWin32Private() : threadId(GetCurrentThreadId()), interrupt(false), closingDown(false), internalHwnd(0), getMessageHook(0), serialNumber(0), lastSerialNumber(0), sendPostedEventsWindowsTimerId(0), - wakeUps(0), activateNotifiersPosted(false) + wakeUps(0) +#ifndef Q_OS_WINCE + , activateNotifiersPosted(false) +#endif { resolveTimerAPI(); } @@ -398,9 +401,11 @@ LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPA QSockNot *sn = dict ? dict->value(wp) : 0; if (sn) { +#ifndef Q_OS_WINCE d->doWsaAsyncSelect(sn->fd, 0); d->active_fd[sn->fd].selected = false; d->postActivateSocketNotifiers(); +#endif if (type < 3) { QEvent event(QEvent::SockAct); QCoreApplication::sendEvent(sn->obj, &event); @@ -411,6 +416,7 @@ LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPA } } return 0; +#ifndef Q_OS_WINCE } else if (message == WM_QT_ACTIVATENOTIFIERS) { Q_ASSERT(d != 0); @@ -425,6 +431,7 @@ LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPA } d->activateNotifiersPosted = false; return 0; +#endif // !Q_OS_WINCE } else if (message == WM_QT_SENDPOSTEDEVENTS // we also use a Windows timer to send posted events when the message queue is full || (message == WM_TIMER @@ -665,11 +672,13 @@ void QEventDispatcherWin32Private::doWsaAsyncSelect(int socket, long event) WSAAsyncSelect(socket, internalHwnd, event ? int(WM_QT_SOCKETNOTIFIER) : 0, event); } +#ifndef Q_OS_WINCE void QEventDispatcherWin32Private::postActivateSocketNotifiers() { if (!activateNotifiersPosted) activateNotifiersPosted = PostMessage(internalHwnd, WM_QT_ACTIVATENOTIFIERS, 0, 0); } +#endif // !Q_OS_WINCE void QEventDispatcherWin32::createInternalHwnd() { @@ -927,16 +936,22 @@ void QEventDispatcherWin32::registerSocketNotifier(QSocketNotifier *notifier) QSFDict::iterator it = d->active_fd.find(sockfd); if (it != d->active_fd.end()) { QSockFd &sd = it.value(); +#ifndef Q_OS_WINCE if (sd.selected) { d->doWsaAsyncSelect(sockfd, 0); sd.selected = false; } +#endif // !Q_OS_WINCE sd.event |= event; } else { d->active_fd.insert(sockfd, QSockFd(event)); } +#ifndef Q_OS_WINCE d->postActivateSocketNotifiers(); +#else + d->doWsaAsyncSelect(sockfd, event); +#endif } void QEventDispatcherWin32::unregisterSocketNotifier(QSocketNotifier *notifier) @@ -965,6 +980,7 @@ void QEventDispatcherWin32::doUnregisterSocketNotifier(QSocketNotifier *notifier QSFDict::iterator it = d->active_fd.find(sockfd); if (it != d->active_fd.end()) { QSockFd &sd = it.value(); +#ifndef Q_OS_WINCE if (sd.selected) d->doWsaAsyncSelect(sockfd, 0); const long event[3] = { FD_READ | FD_CLOSE | FD_ACCEPT, FD_WRITE | FD_CONNECT, FD_OOB }; @@ -975,6 +991,13 @@ void QEventDispatcherWin32::doUnregisterSocketNotifier(QSocketNotifier *notifier sd.selected = false; d->postActivateSocketNotifiers(); } +#else + const long event[3] = { FD_READ | FD_CLOSE | FD_ACCEPT, FD_WRITE | FD_CONNECT, FD_OOB }; + sd.event ^= event[type]; + d->doWsaAsyncSelect(sockfd, sd.event); + if (sd.event == 0) + d->active_fd.erase(it); +#endif // !Q_OS_WINCE } QSNDict *sn_vec[3] = { &d->sn_read, &d->sn_write, &d->sn_except }; diff --git a/src/corelib/kernel/qeventdispatcher_win_p.h b/src/corelib/kernel/qeventdispatcher_win_p.h index d745f16975..a87b56cd38 100644 --- a/src/corelib/kernel/qeventdispatcher_win_p.h +++ b/src/corelib/kernel/qeventdispatcher_win_p.h @@ -185,9 +185,11 @@ public: QSNDict sn_write; QSNDict sn_except; QSFDict active_fd; +#ifndef Q_OS_WINCE bool activateNotifiersPosted; - void doWsaAsyncSelect(int socket, long event); void postActivateSocketNotifiers(); +#endif + void doWsaAsyncSelect(int socket, long event); QList<QWinEventNotifier *> winEventNotifierList; void activateEventNotifier(QWinEventNotifier * wen); diff --git a/src/corelib/kernel/qeventdispatcher_winrt.cpp b/src/corelib/kernel/qeventdispatcher_winrt.cpp index a6f61afc90..2ffcf03eb2 100644 --- a/src/corelib/kernel/qeventdispatcher_winrt.cpp +++ b/src/corelib/kernel/qeventdispatcher_winrt.cpp @@ -56,6 +56,7 @@ using namespace Microsoft::WRL; using namespace Microsoft::WRL::Wrappers; using namespace ABI::Windows::System::Threading; using namespace ABI::Windows::Foundation; +using namespace ABI::Windows::Foundation::Collections; using namespace ABI::Windows::UI::Core; using namespace ABI::Windows::ApplicationModel::Core; @@ -185,8 +186,34 @@ HRESULT QEventDispatcherWinRT::runOnXamlThread(const std::function<HRESULT ()> & ComPtr<ICoreWindow> window; hr = view->get_CoreWindow(&window); Q_ASSERT_SUCCEEDED(hr); - hr = window->get_Dispatcher(&dispatcher); - Q_ASSERT_SUCCEEDED(hr); + if (!window) { + // In case the application is launched via activation + // there might not be a main view (eg ShareTarget). + // Hence iterate through the available views and try to find + // a dispatcher in there + ComPtr<IVectorView<CoreApplicationView*>> appViews; + hr = application->get_Views(&appViews); + Q_ASSERT_SUCCEEDED(hr); + quint32 count; + hr = appViews->get_Size(&count); + Q_ASSERT_SUCCEEDED(hr); + for (quint32 i = 0; i < count; ++i) { + hr = appViews->GetAt(i, &view); + Q_ASSERT_SUCCEEDED(hr); + hr = view->get_CoreWindow(&window); + Q_ASSERT_SUCCEEDED(hr); + if (window) { + hr = window->get_Dispatcher(&dispatcher); + Q_ASSERT_SUCCEEDED(hr); + if (dispatcher) + break; + } + } + Q_ASSERT(dispatcher); + } else { + hr = window->get_Dispatcher(&dispatcher); + Q_ASSERT_SUCCEEDED(hr); + } } HRESULT hr; diff --git a/src/corelib/kernel/qobjectdefs_impl.h b/src/corelib/kernel/qobjectdefs_impl.h index 2da76e1a4e..6ef83a6eb5 100644 --- a/src/corelib/kernel/qobjectdefs_impl.h +++ b/src/corelib/kernel/qobjectdefs_impl.h @@ -497,7 +497,7 @@ namespace QtPrivate { template <typename, typename, typename, typename> struct FunctorCall; template <int... II, typename... SignalArgs, typename R, typename Function> struct FunctorCall<IndexesList<II...>, List<SignalArgs...>, R, Function> { - static void call(Function f, void **arg) { + static void call(Function &f, void **arg) { f((*reinterpret_cast<typename RemoveRef<SignalArgs>::Type *>(arg[II+1]))...), ApplyReturnValue<R>(arg[0]); } }; diff --git a/src/corelib/kernel/qwineventnotifier.h b/src/corelib/kernel/qwineventnotifier.h index ad712b20a4..f17fa059a1 100644 --- a/src/corelib/kernel/qwineventnotifier.h +++ b/src/corelib/kernel/qwineventnotifier.h @@ -54,8 +54,8 @@ class Q_CORE_EXPORT QWinEventNotifier : public QObject typedef Qt::HANDLE HANDLE; public: - explicit QWinEventNotifier(QObject *parent = 0); - explicit QWinEventNotifier(HANDLE hEvent, QObject *parent = 0); + explicit QWinEventNotifier(QObject *parent = Q_NULLPTR); + explicit QWinEventNotifier(HANDLE hEvent, QObject *parent = Q_NULLPTR); ~QWinEventNotifier(); void setHandle(HANDLE hEvent); |