summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesus Fernandez <jesus.fernandez@theqtcompany.com>2016-05-02 13:39:27 +0200
committerJesus Fernandez <jesus.fernandez@qt.io>2016-09-06 13:07:56 +0000
commit511623b6f065d1ac633af66926150f35676be498 (patch)
tree38215e76ede3d1e6a38faf424644de30807b60a6
parent160a4fe7ee92c4c0d6c66452be45637b34fb7aea (diff)
Added warning in QDesktopServices::openUrl
Shows a descriptive warning when the application is not initialized or it's not a GUI application. Change-Id: I0fbb1c30fb603f444b6ef2a5adbe4f27a15f1daf Reviewed-by: David Faure <david.faure@kdab.com>
-rw-r--r--src/gui/util/qdesktopservices.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/gui/util/qdesktopservices.cpp b/src/gui/util/qdesktopservices.cpp
index 085c073bb1..c9747877f7 100644
--- a/src/gui/util/qdesktopservices.cpp
+++ b/src/gui/util/qdesktopservices.cpp
@@ -198,8 +198,15 @@ bool QDesktopServices::openUrl(const QUrl &url)
return false;
QPlatformIntegration *platformIntegration = QGuiApplicationPrivate::platformIntegration();
- if (!platformIntegration)
+ if (Q_UNLIKELY(!platformIntegration)) {
+ QCoreApplication *application = QCoreApplication::instance();
+ if (Q_UNLIKELY(!application))
+ qWarning("QDesktopServices::openUrl: Please instantiate the QGuiApplication object "
+ "first");
+ else if (Q_UNLIKELY(!qobject_cast<QGuiApplication *>(application)))
+ qWarning("QDesktopServices::openUrl: Application is not a GUI application");
return false;
+ }
QPlatformServices *platformServices = platformIntegration->services();
if (!platformServices) {