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>
This commit is contained in:
parent
160a4fe7ee
commit
511623b6f0
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user