From 7c029e83a3e5058f7b82efd0235e766952357ffd Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 28 Nov 2013 11:00:15 +0100 Subject: Fix invalid memory read when shutting down QML applications As the last line in the QObject destructor, we call setParentHelper(0) to remove ourselves from the parent. In the process of that we also initiate the QML parentChanged callback. The first thing that parentChanged callback used to do (but now does it too late, after 26350b5ceafa0ade1328037f6234a7d288eb8f48 in qtdeclarative) is to check if the object was deleted and then return. We could re-introduce the check there, but I think it's cleaner to not bother calling the callback on a dead object in the first place. Change-Id: Ia4d43b65a9b3744a451b4c312a2d6f9c0e3b67dc Reviewed-by: Lars Knoll --- src/corelib/kernel/qobject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index e062a38185..f8664ba3a2 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -1876,7 +1876,7 @@ void QObjectPrivate::setParent_helper(QObject *o) } } } - if (!isDeletingChildren && declarativeData && QAbstractDeclarativeData::parentChanged) + if (!wasDeleted && !isDeletingChildren && declarativeData && QAbstractDeclarativeData::parentChanged) QAbstractDeclarativeData::parentChanged(declarativeData, q, o); } -- cgit v1.2.3 From c5b19f252188a01dd7b12090f4776420e3714000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 28 Nov 2013 15:33:06 +0100 Subject: iOS: Forward [UIApplicationDelegate handleOpenURL:] to QDesktopServices The user may use QDesktopServices::setUrlHandler() in combination with the appropriate Info.plist keys (CFBundleURLTypes, CFBundleURLSchemes) to react to URL requests from other applications. This is among other things useful for handling OAuth authentication from applications such as Dropbox. See: https://www.dropbox.com/developers/core/start/ios We protect against recursive URL opening, but an application may still redirect a request to open a URL by opening another URL, eg a website. Task-number: QTBUG-35201 Change-Id: I9f1d246206c5594b1b65bb11fa98c6bcdefc443e Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/ios/qiosapplicationdelegate.mm | 20 ++++++++++++++++++++ src/plugins/platforms/ios/qiosservices.h | 7 +++++++ src/plugins/platforms/ios/qiosservices.mm | 19 +++++++++++++++++++ 3 files changed, 46 insertions(+) (limited to 'src') diff --git a/src/plugins/platforms/ios/qiosapplicationdelegate.mm b/src/plugins/platforms/ios/qiosapplicationdelegate.mm index cf702c82af..9cf1047a6b 100644 --- a/src/plugins/platforms/ios/qiosapplicationdelegate.mm +++ b/src/plugins/platforms/ios/qiosapplicationdelegate.mm @@ -41,9 +41,14 @@ #include "qiosapplicationdelegate.h" +#include "qiosintegration.h" +#include "qiosservices.h" #include "qiosviewcontroller.h" #include "qioswindow.h" +#include +#include + #include @implementation QIOSApplicationDelegate @@ -82,6 +87,21 @@ return YES; } +- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation +{ + Q_UNUSED(application); + Q_UNUSED(sourceApplication); + Q_UNUSED(annotation); + + if (!QGuiApplication::instance()) + return NO; + + QIOSIntegration *iosIntegration = static_cast(QGuiApplicationPrivate::platformIntegration()); + QIOSServices *iosServices = static_cast(iosIntegration->services()); + + return iosServices->handleUrl(QUrl::fromNSURL(url)); +} + - (void)dealloc { [window release]; diff --git a/src/plugins/platforms/ios/qiosservices.h b/src/plugins/platforms/ios/qiosservices.h index 692b3a0b99..aa39fbbed4 100644 --- a/src/plugins/platforms/ios/qiosservices.h +++ b/src/plugins/platforms/ios/qiosservices.h @@ -41,6 +41,8 @@ #ifndef QIOSSERVICES_H #define QIOSSERVICES_H + +#include #include QT_BEGIN_NAMESPACE @@ -50,6 +52,11 @@ class QIOSServices : public QPlatformServices public: bool openUrl(const QUrl &url); bool openDocument(const QUrl &url); + + bool handleUrl(const QUrl &url); + +private: + QUrl m_handlingUrl; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/ios/qiosservices.mm b/src/plugins/platforms/ios/qiosservices.mm index 32203aeb71..0ac6c590ca 100644 --- a/src/plugins/platforms/ios/qiosservices.mm +++ b/src/plugins/platforms/ios/qiosservices.mm @@ -42,6 +42,7 @@ #include "qiosservices.h" #include +#include #import @@ -49,6 +50,9 @@ QT_BEGIN_NAMESPACE bool QIOSServices::openUrl(const QUrl &url) { + if (url == m_handlingUrl) + return false; + if (url.scheme().isEmpty()) return openDocument(url); @@ -66,4 +70,19 @@ bool QIOSServices::openDocument(const QUrl &url) return QPlatformServices::openDocument(url); } +/* Callback from iOS that the application should handle a URL */ +bool QIOSServices::handleUrl(const QUrl &url) +{ + QUrl previouslyHandling = m_handlingUrl; + m_handlingUrl = url; + + // FIXME: Add platform services callback from QDesktopServices::setUrlHandler + // so that we can warn the user if calling setUrlHandler without also setting + // up the matching keys in the Info.plist file (CFBundleURLTypes and friends). + bool couldHandle = QDesktopServices::openUrl(url); + + m_handlingUrl = previouslyHandling; + return couldHandle; +} + QT_END_NAMESPACE -- cgit v1.2.3 From 9b782dca45331c0e0246b8439d5cf007a440afc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 27 Nov 2013 18:20:10 +0100 Subject: iOS: Update screen properties when we trigger statusbar changes on iOS7 Ideally we'd have a callback from iOS when this happens, so we can also react to changes done outside of Qt, but willChangeStatusBarFrame and friends do not seem to give us what we want. Change-Id: I686ce7950395a83c4257372363c773a95c3935ed Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/ios/qiosscreen.mm | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm index 57522cb1a3..96410952f9 100644 --- a/src/plugins/platforms/ios/qiosscreen.mm +++ b/src/plugins/platforms/ios/qiosscreen.mm @@ -189,6 +189,9 @@ void QIOSScreen::updateProperties() void QIOSScreen::updateStatusBarVisibility() { + if (!isQtApplication()) + return; + QWindow *focusWindow = QGuiApplication::focusWindow(); // If we don't have a focus window we leave the status @@ -199,20 +202,26 @@ void QIOSScreen::updateStatusBarVisibility() return; UIView *view = reinterpret_cast(focusWindow->handle()->winId()); + QIOSViewController *viewController = static_cast(view.viewController); + + bool currentStatusBarVisibility = [UIApplication sharedApplication].statusBarHidden; + if (viewController.prefersStatusBarHidden == currentStatusBarVisibility) + return; + #if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_7_0) if (QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_7_0) { - [view.viewController setNeedsStatusBarAppearanceUpdate]; + [viewController setNeedsStatusBarAppearanceUpdate]; + dispatch_async(dispatch_get_main_queue(), ^{ + updateProperties(); + }); } else #endif { - bool wasHidden = [UIApplication sharedApplication].statusBarHidden; - QIOSViewController *viewController = static_cast(view.viewController); [[UIApplication sharedApplication] setStatusBarHidden:[viewController prefersStatusBarHidden] withAnimation:UIStatusBarAnimationNone]; - if ([UIApplication sharedApplication].statusBarHidden != wasHidden) - updateProperties(); + updateProperties(); } } -- cgit v1.2.3 From 6c3adb5f966e349f0488c194462e48cc8ddf248e Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Wed, 27 Nov 2013 14:47:26 +0100 Subject: Doc: corrected invalid ref. to output iterators MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-34749 Change-Id: I7abd504b6081e84a8e67c7957e13d402999e9d38 Reviewed-by: Martin Smith Reviewed-by: Topi Reiniƶ --- src/corelib/tools/qalgorithms.qdoc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qalgorithms.qdoc b/src/corelib/tools/qalgorithms.qdoc index cd389470a4..412b9cf3b2 100644 --- a/src/corelib/tools/qalgorithms.qdoc +++ b/src/corelib/tools/qalgorithms.qdoc @@ -49,9 +49,9 @@ iterators they accept. For example, qFill() accepts two \l {forward iterators}. The iterator types required are specified for each algorithm. If an iterator of the wrong type is passed (for - example, if QList::ConstIterator is passed as an \l {output - iterator}), you will always get a compiler error, although not - necessarily a very informative one. + example, if QList::ConstIterator is passed as an + \l {Output Iterators}{output iterator}), you will always get a + compiler error, although not necessarily a very informative one. Some algorithms have special requirements on the value type stored in the containers. For example, @@ -99,7 +99,7 @@ \section2 Output Iterators - An \e{output iterator} is an iterator that can be used for + An output iterator is an iterator that can be used for writing data sequentially to a container or to some output stream. It must provide the following operators: unary \c{*} for writing a value (i.e., \c{*it = val}) and prefix \c{++} for -- cgit v1.2.3 From 7d5448d9e2ae4d2d10c0cff867cf34b315336feb Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 27 Nov 2013 13:24:59 +0100 Subject: Docs: add important QWheelEvent::phase() related notes Change-Id: I4901b96b44b7c1179e678689af5962cb4570d50d Reviewed-by: Jens Bache-Wiig Reviewed-by: Gabriel de Dietrich Reviewed-by: Lars Knoll --- src/gui/kernel/qevent.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src') diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 28666085a7..88f132b877 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -709,6 +709,12 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, Example: \snippet code/src_gui_kernel_qevent.cpp 0 + + \note On platforms that support scrolling \l{phase()}{phases}, the delta may be null when: + \list + \li scrolling is about to begin, but the distance did not yet change (Qt::ScrollBegin), + \li or scrolling has ended and the distance did not change anymore (Qt::ScrollEnd). + \endlist */ /*! @@ -731,6 +737,12 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, Example: \snippet code/src_gui_kernel_qevent.cpp 0 + + \note On platforms that support scrolling \l{phase()}{phases}, the delta may be null when: + \list + \li scrolling is about to begin, but the distance did not yet change (Qt::ScrollBegin), + \li or scrolling has ended and the distance did not change anymore (Qt::ScrollEnd). + \endlist */ /*! @@ -830,6 +842,9 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, \since 5.2 Returns the scrolling phase of this wheel event. + + \note The Qt::ScrollBegin and Qt::ScrollEnd phases are currently + supported only on Mac OS X. */ -- cgit v1.2.3