summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Faure <faure@kde.org>2013-02-23 17:27:09 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-26 15:55:38 +0100
commit799621c0e235d41021b2785b690bfd0d1f44db11 (patch)
treec0983b4005a263611d287abf83f2dda4aeb28710 /src
parent211a5b1e866c4e40b07289d61d9df9bf8a871522 (diff)
downloadqtx11extras-799621c0e235d41021b2785b690bfd0d1f44db11.tar.gz
Fix crash when qApp is a QCoreApplication.
Yes, it makes little sense to call QX11Info API in such cases; but it happens currently in kio unittests which calls code which creates dialogs but never show them to the user (since they are unittests). With this fix, the tests pass. Change-Id: I96cd2080891a960aa405d98fd1801253930bde1e Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/x11extras/qx11info_x11.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/x11extras/qx11info_x11.cpp b/src/x11extras/qx11info_x11.cpp
index cb534b7..a7499e4 100644
--- a/src/x11extras/qx11info_x11.cpp
+++ b/src/x11extras/qx11info_x11.cpp
@@ -187,6 +187,8 @@ unsigned long QX11Info::appTime()
if (!qApp)
return 0;
QPlatformNativeInterface *native = qApp->platformNativeInterface();
+ if (!native)
+ return 0;
QScreen* screen = QGuiApplication::primaryScreen();
return static_cast<xcb_timestamp_t>(reinterpret_cast<quintptr>(native->nativeResourceForScreen("apptime", screen)));
}
@@ -201,6 +203,8 @@ unsigned long QX11Info::appUserTime()
if (!qApp)
return 0;
QPlatformNativeInterface *native = qApp->platformNativeInterface();
+ if (!native)
+ return 0;
QScreen* screen = QGuiApplication::primaryScreen();
return static_cast<xcb_timestamp_t>(reinterpret_cast<quintptr>(native->nativeResourceForScreen("appusertime", screen)));
}
@@ -215,6 +219,8 @@ void QX11Info::setAppTime(unsigned long time)
if (!qApp)
return;
QPlatformNativeInterface *native = qApp->platformNativeInterface();
+ if (!native)
+ return;
typedef void (*SetAppTimeFunc)(QScreen *, xcb_timestamp_t);
QScreen* screen = QGuiApplication::primaryScreen();
SetAppTimeFunc func = reinterpret_cast<SetAppTimeFunc>(native->nativeResourceFunctionForScreen("setapptime"));
@@ -234,6 +240,8 @@ void QX11Info::setAppUserTime(unsigned long time)
if (!qApp)
return;
QPlatformNativeInterface *native = qApp->platformNativeInterface();
+ if (!native)
+ return;
typedef void (*SetAppUserTimeFunc)(QScreen *, xcb_timestamp_t);
QScreen* screen = QGuiApplication::primaryScreen();
SetAppUserTimeFunc func = reinterpret_cast<SetAppUserTimeFunc>(native->nativeResourceFunctionForScreen("setappusertime"));
@@ -253,6 +261,8 @@ Display *QX11Info::display()
if (!qApp)
return NULL;
QPlatformNativeInterface *native = qApp->platformNativeInterface();
+ if (!native)
+ return NULL;
void *display = native->nativeResourceForScreen(QByteArray("display"), QGuiApplication::primaryScreen());
return reinterpret_cast<Display *>(display);
@@ -268,6 +278,8 @@ xcb_connection_t *QX11Info::connection()
if (!qApp)
return NULL;
QPlatformNativeInterface *native = qApp->platformNativeInterface();
+ if (!native)
+ return NULL;
void *connection = native->nativeResourceForWindow(QByteArray("connection"), 0);
return reinterpret_cast<xcb_connection_t *>(connection);