Bug 515839 - Cockpit and Dual screen window layouts not compatible with Krita 6
Summary: Cockpit and Dual screen window layouts not compatible with Krita 6
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Usability (other bugs)
Version First Reported In: 6.0.0-beta1
Platform: Ubuntu Linux
: NOR crash
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords: regression, release_blocker
Depends on:
Blocks:
 
Reported: 2026-02-10 22:14 UTC by vurentjie
Modified: 2026-03-17 10:31 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
Fix closing windows cause crash (3.20 KB, patch)
2026-02-13 15:07 UTC, vurentjie
Details
Fix closing windows cause crash (fixed typo) (3.15 KB, patch)
2026-02-13 16:33 UTC, vurentjie
Details

Note You need to log in before you can comment on or make changes to this bug.
Description vurentjie 2026-02-10 22:14:30 UTC
SUMMARY
The Cockpit and Dual screen window layouts are not compatible with Krita 6. I don't actually use these but I happened to try them today and noticed the issue.

STEPS TO REPRODUCE
1.  Open Krita 6
2.  Open or create a new document
3.  From the workspace switcher, select either one of the window layouts: "Cockpit (laptop mode)" or "Dual screen editing"

OBSERVED RESULT
Krita crashes with a seg fault. I think this might be an issue with the .kwl files compatibility. 

EXPECTED RESULT
Doesn't crash.

SOFTWARE/OS VERSIONS
Version: 6.0.0-beta1 (git db05298)
Hidpi: true
Qt: 6.8.0
OS Information
  Build ABI: x86_64-little_endian-lp64
  Build CPU: x86_64
  CPU: x86_64
  Kernel Type: linux
  Kernel Version: 6.14.0-37-generic
  Pretty Productname: Ubuntu 24.04.3 LTS
  Product Type: ubuntu
  Product Version: 24.04
  Desktop: ubuntu:GNOME
  Appimage build: Yes


ADDITIONAL INFORMATION
Comment 1 Freya Lupen 2026-02-11 15:58:24 UTC
Confirmed, selecting a window layout crashes on Qt6 but not Qt5.

It crashes here
> 0   libkritaresourcewidgets.21.0.0.dylib	       0x103dbc2e0 KisResourceItemChooser::activate(QModelIndex const&) + 336 (KisResourceItemChooser.cpp:515)

When the window layout is activated, the updates are blocked on the window layout chooser, it emits the resourceSelected signal, a bunch of other stuff happens,  and then eventually it unblocks the updates.
However, by the time it gets back to `d->updatesBlocked = false;`, `d` is null for some reason, so it crashes instead.
Comment 2 vurentjie 2026-02-13 15:07:23 UTC
Created attachment 189530 [details]
Fix closing windows cause crash

I decided to look into this a bit today. Attached a patch with a fix, 

It is mainly this line in KisWindowLayoutResource.cpp that cause the crash, when closing the windows:

https://invent.kde.org/graphics/krita/-/blame/cb158acfc714301289a63bff7aa892eb8c4f1f23/libs/ui/KisWindowLayoutResource.cpp#L157

I shuffled some things around in  openNecessaryWindows(), closeUnneededWindows(). And moved closeUnneededWindows() to the end. This seems to fix the crash.

I can submit a PR if you want, or you can take my patch and investigate further.
Comment 3 vurentjie 2026-02-13 16:09:59 UTC
Comment on attachment 189530 [details]
Fix closing windows cause crash

diff --git a/libs/ui/KisWindowLayoutResource.cpp b/libs/ui/KisWindowLayoutResource.cpp
index 2fcec19221..65ff208bf7 100644
--- a/libs/ui/KisWindowLayoutResource.cpp
+++ b/libs/ui/KisWindowLayoutResource.cpp
@@ -126,10 +126,8 @@ struct KisWindowLayoutResource::Private
                 mainWindow->show();
             }
         }
-    }
-
-    void closeUnneededWindows(QList<QPointer<KisMainWindow>> &currentWindows) {
-        QVector<QPointer<KisMainWindow>> windowsToClose;
+        
+        QVector<QPointer<KisMainWindow>> windowsToMigrate;
 
         Q_FOREACH(KisMainWindow *mainWindow, currentWindows) {
             bool keep = false;
@@ -141,8 +139,8 @@ struct KisWindowLayoutResource::Private
             }
 
             if (!keep) {
-                windowsToClose.append(mainWindow);
-
+                windowsToMigrate.append(mainWindow);
+                
                 // Set the window hidden to prevent "show image in all windows" feature from opening new views on it
                 // while we migrate views onto the remaining windows
                 if (mainWindow->isVisible()) {
@@ -150,11 +148,25 @@ struct KisWindowLayoutResource::Private
                 }
             }
         }
+        
+        migrateViewsFromClosingWindows(windowsToMigrate);
+    }
 
-        migrateViewsFromClosingWindows(windowsToClose);
+    void closeUnneededWindows(QList<QPointer<KisMainWindow>> &currentWindows) {
+        QVector<QPointer<KisMainWindow>> windowsToClose;
+
+        Q_FOREACH(KisMainWindow *mainWindow, currentWindows) {
+            bool keep = false;
+            Q_FOREACH(const Window &window, windows) {
+                if (window.windowId == mainWindow->id()) {
+                    keep = true;
+                    break;
+                }
+            }
 
-        Q_FOREACH(QPointer<KisMainWindow> mainWindow, windowsToClose) {
-            mainWindow->close();
+            if (!keep) {
+                mainWindow->close();
+            }
         }
     }
 
@@ -248,8 +260,9 @@ void KisWindowLayoutResource::applyLayout()
     layoutManager->setLastUsedLayout(this);
 
     QList<QPointer<KisMainWindow>> currentWindows = kisPart->mainWindows();
+    bool createWindows = d->windows.isEmpty();
 
-    if (d->windows.isEmpty()) {
+    if (createWindows) {
         // No windows defined (e.g. fresh new session). Leave things as they are, but make sure there's at least one visible main window
         if (kisPart->mainwindowCount() == 0) {
             kisPart->createMainWindow();
@@ -258,7 +271,6 @@ void KisWindowLayoutResource::applyLayout()
         }
     } else {
         d->openNecessaryWindows(currentWindows);
-        d->closeUnneededWindows(currentWindows);
     }
 
     // Wait for the windows to finish opening / closing before applying saved geometry.
@@ -300,6 +312,9 @@ void KisWindowLayoutResource::applyLayout()
 
     layoutManager->setShowImageInAllWindowsEnabled(d->showImageInAllWindows);
     layoutManager->setPrimaryWorkspaceFollowsFocus(d->primaryWorkspaceFollowsFocus, d->primaryWindow);
+    if (!createWindows) {
+        d->closeUnneededWindows(currentWindows);
+    }
 }
 
 bool KisWindowLayoutResource::saveToDevice(QIODevice *dev) const
Comment 4 vurentjie 2026-02-13 16:12:15 UTC
Sorry, I am not used to this bug trackers function. I updated the patch, there was one typo, I uncommented a commented line for some reason.
Comment 5 vurentjie 2026-02-13 16:33:50 UTC
Created attachment 189534 [details]
Fix closing windows cause crash (fixed typo)

Re-uploading patch.
Comment 6 wolthera 2026-03-12 14:58:06 UTC
Hey vurentjie, we use gitlab. dmitryK has moved your patch onto gitlab, but hasn't yet mentioned that here, so I am going so now: https://invent.kde.org/graphics/krita/-/merge_requests/2698
Comment 7 vurentjie 2026-03-12 15:20:29 UTC
(In reply to wolthera from comment #6)
> Hey vurentjie, we use gitlab. dmitryK has moved your patch onto gitlab, but
> hasn't yet mentioned that here, so I am going so now:
> https://invent.kde.org/graphics/krita/-/merge_requests/2698

Thanks, the link you share is different, I looked now, and it is this merge request:
https://invent.kde.org/graphics/krita/-/merge_requests/2695
Comment 8 wolthera 2026-03-12 15:46:37 UTC
Ah, sorry, I had too many tabs open. Good to see you found it though,
Comment 9 Dmitry Kazakov 2026-03-16 12:14:36 UTC
The related MR: https://invent.kde.org/graphics/krita/-/merge_requests/2695
Comment 10 Dmitry Kazakov 2026-03-17 10:31:13 UTC
Hi, vurentjie!

The bug is now fixed in both, master and krita/6.0! Thank you for the report and the proposed fix! :)

https://invent.kde.org/graphics/krita/-/commit/5cf31d1445ef45373ffe9e5d08a74d8914085fcc