summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.cpp47
1 files changed, 35 insertions, 12 deletions
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
index 0688898cae..3a4539c5e6 100644
--- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
@@ -92,13 +92,21 @@ QXcbNativeInterface::QXcbNativeInterface() :
void QXcbNativeInterface::beep() // For QApplication::beep()
{
- QPlatformScreen *screen = QGuiApplication::primaryScreen()->handle();
+ QScreen *priScreen = QGuiApplication::primaryScreen();
+ if (!priScreen)
+ return;
+ QPlatformScreen *screen = priScreen->handle();
+ if (!screen)
+ return;
xcb_connection_t *connection = static_cast<QXcbScreen *>(screen)->xcb_connection();
xcb_bell(connection, 0);
}
static inline QXcbSystemTrayTracker *systemTrayTracker(const QScreen *s)
{
+ if (!s)
+ return Q_NULLPTR;
+
return static_cast<const QXcbScreen *>(s->handle())->connection()->systemTrayTracker();
}
@@ -386,16 +394,25 @@ QFunctionPointer QXcbNativeInterface::platformFunction(const QByteArray &functio
void *QXcbNativeInterface::appTime(const QXcbScreen *screen)
{
+ if (!screen)
+ return Q_NULLPTR;
+
return reinterpret_cast<void *>(quintptr(screen->connection()->time()));
}
void *QXcbNativeInterface::appUserTime(const QXcbScreen *screen)
{
+ if (!screen)
+ return Q_NULLPTR;
+
return reinterpret_cast<void *>(quintptr(screen->connection()->netWmUserTime()));
}
void *QXcbNativeInterface::getTimestamp(const QXcbScreen *screen)
{
+ if (!screen)
+ return Q_NULLPTR;
+
return reinterpret_cast<void *>(quintptr(screen->connection()->getTimestamp()));
}
@@ -431,20 +448,24 @@ void *QXcbNativeInterface::display()
#ifdef XCB_USE_XLIB
QXcbIntegration *integration = QXcbIntegration::instance();
QXcbConnection *defaultConnection = integration->defaultConnection();
- return defaultConnection->xlib_display();
-#else
- return 0;
+ if (defaultConnection)
+ return defaultConnection->xlib_display();
#endif
+ return Q_NULLPTR;
}
void QXcbNativeInterface::setAppTime(QScreen* screen, xcb_timestamp_t time)
{
- static_cast<QXcbScreen *>(screen->handle())->connection()->setTime(time);
+ if (screen) {
+ static_cast<QXcbScreen *>(screen->handle())->connection()->setTime(time);
+ }
}
void QXcbNativeInterface::setAppUserTime(QScreen* screen, xcb_timestamp_t time)
{
- static_cast<QXcbScreen *>(screen->handle())->connection()->setNetWmUserTime(time);
+ if (screen) {
+ static_cast<QXcbScreen *>(screen->handle())->connection()->setNetWmUserTime(time);
+ }
}
void QXcbNativeInterface::setStartupId(const char *data)
@@ -460,9 +481,11 @@ QXcbScreen *QXcbNativeInterface::qPlatformScreenForWindow(QWindow *window)
{
QXcbScreen *screen;
if (window) {
- screen = static_cast<QXcbScreen *>(window->screen()->handle());
+ QScreen *qs = window->screen();
+ screen = static_cast<QXcbScreen *>(qs ? qs->handle() : Q_NULLPTR);
} else {
- screen = static_cast<QXcbScreen *>(QGuiApplication::primaryScreen()->handle());
+ QScreen *qs = QGuiApplication::primaryScreen();
+ screen = static_cast<QXcbScreen *>(qs ? qs->handle() : Q_NULLPTR);
}
return screen;
}
@@ -471,23 +494,23 @@ void *QXcbNativeInterface::displayForWindow(QWindow *window)
{
#if defined(XCB_USE_XLIB)
QXcbScreen *screen = qPlatformScreenForWindow(window);
- return screen->connection()->xlib_display();
+ return screen ? screen->connection()->xlib_display() : Q_NULLPTR;
#else
Q_UNUSED(window);
- return 0;
+ return Q_NULLPTR;
#endif
}
void *QXcbNativeInterface::connectionForWindow(QWindow *window)
{
QXcbScreen *screen = qPlatformScreenForWindow(window);
- return screen->xcb_connection();
+ return screen ? screen->xcb_connection() : Q_NULLPTR;
}
void *QXcbNativeInterface::screenForWindow(QWindow *window)
{
QXcbScreen *screen = qPlatformScreenForWindow(window);
- return screen->screen();
+ return screen ? screen->screen() : Q_NULLPTR;
}
void QXcbNativeInterface::addHandler(QXcbNativeInterfaceHandler *handler)