From 511623b6f065d1ac633af66926150f35676be498 Mon Sep 17 00:00:00 2001 From: Jesus Fernandez Date: Mon, 2 May 2016 13:39:27 +0200 Subject: 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 --- src/gui/util/qdesktopservices.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/gui/util') 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(application))) + qWarning("QDesktopServices::openUrl: Application is not a GUI application"); return false; + } QPlatformServices *platformServices = platformIntegration->services(); if (!platformServices) { -- cgit v1.2.3