Guard the usages of QPlatformIntegration::services()

Task-number: QTBUG-130884
Pick-to: 6.8 6.5
Change-Id: I6c8060ce8b7a4e525c46e2e1fec227f46fe8c4d6
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Liang Qi 2024-11-21 07:05:11 +01:00
parent 0a8458b44d
commit 7f06824408
2 changed files with 3 additions and 2 deletions

View File

@ -191,7 +191,8 @@ QTemporaryFile *QDBusTrayIcon::tempIcon(const QIcon &icon)
// Accessing to process name might be not allowed if the application
// is confined, thus we can just rely on the current desktop in use
const QPlatformServices *services = QGuiApplicationPrivate::platformIntegration()->services();
necessary = services->desktopEnvironment().split(':').contains("UNITY");
if (services)
necessary = services->desktopEnvironment().split(':').contains("UNITY");
}
necessity_checked = true;
}

View File

@ -1610,7 +1610,7 @@ void QColorDialogPrivate::pickScreenColor()
Q_Q(QColorDialog);
auto *platformServices = QGuiApplicationPrivate::platformIntegration()->services();
if (platformServices->hasCapability(QPlatformServices::Capability::ColorPicking)) {
if (platformServices && platformServices->hasCapability(QPlatformServices::Capability::ColorPicking)) {
if (auto *colorPicker = platformServices->colorPicker(q->windowHandle())) {
q->connect(colorPicker, &QPlatformServiceColorPicker::colorPicked, q,
[q, colorPicker](const QColor &color) {