Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Don't create KisSRGBSurfaceColorSpaceManager twice

Dmitry Kazakovcd712b31aacd
diff --git a/libs/ui/KisApplication.cpp b/libs/ui/KisApplication.cpp
index 4a3541419a..c65d2165cb 100644
--- a/libs/ui/KisApplication.cpp
+++ b/libs/ui/KisApplication.cpp
@@ -124,6 +124,7 @@
#if KRITA_USE_SURFACE_COLOR_MANAGEMENT_API
+#include <QWindow>
#include <QPlatformSurfaceEvent>
#include <KisSRGBSurfaceColorSpaceManager.h>
@@ -302,7 +303,12 @@ KisApplication::KisApplication(const QString &key, int &argc, char **argv)
QPlatformSurfaceEvent *surfaceEvent = static_cast<QPlatformSurfaceEvent*>(event);
if (surfaceEvent->surfaceEventType() == QPlatformSurfaceEvent::SurfaceCreated) {
- KisSRGBSurfaceColorSpaceManager::tryCreateForCurrentPlatform(widget);
+ QWindow *nativeWindow = widget->windowHandle();
+ KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(widget->windowHandle(), false);
+
+ if (!nativeWindow->findChild<KisSRGBSurfaceColorSpaceManager*>()) {
+ KisSRGBSurfaceColorSpaceManager::tryCreateForCurrentPlatform(widget);
+ }
}
}
diff --git a/libs/ui/KisSRGBSurfaceColorSpaceManager.h b/libs/ui/KisSRGBSurfaceColorSpaceManager.h
index 84739f26b0..69009fba59 100644
--- a/libs/ui/KisSRGBSurfaceColorSpaceManager.h
+++ b/libs/ui/KisSRGBSurfaceColorSpaceManager.h
@@ -16,6 +16,7 @@ class KisSurfaceColorManagerInterface;
class KisSRGBSurfaceColorSpaceManager : public QObject
{
+ Q_OBJECT
public:
KisSRGBSurfaceColorSpaceManager(KisSurfaceColorManagerInterface *interface, QObject *parent = nullptr);
~KisSRGBSurfaceColorSpaceManager();
@@ -23,7 +24,7 @@ public:
QString colorManagementReport() const;
QString osPreferredColorSpaceReport() const;
- static KisSRGBSurfaceColorSpaceManager* tryCreateForCurrentPlatform(QWidget *widget);
+ static KisSRGBSurfaceColorSpaceManager* tryCreateForCurrentPlatform(QWidget *widget);
protected:
static KisSurfaceColorimetry::RenderIntent calculateConfigIntent();