Bug 444309 - Palette doesn't autosave on quit
Summary: Palette doesn't autosave on quit
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Resource Management (show other bugs)
Version: 5.0.0-beta2
Platform: Appimage Linux
: NOR normal
Target Milestone: ---
Assignee: Tiar
URL:
Keywords: regression, release_blocker
Depends on:
Blocks:
 
Reported: 2021-10-24 05:49 UTC by tomtomtomreportingin
Modified: 2021-12-03 11:59 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tomtomtomreportingin 2021-10-24 05:49:53 UTC
SUMMARY
As of beta 2, the palette no longer autosaves on quitting Krita. 

This issue does not occur in beta 1, but it does occur in 5.1.0-prealpha git a6fbd9d.

STEPS TO REPRODUCE
1. Create a new palette.
2. Add some colors.
3. Restart Krita.

OBSERVED RESULT
No colors are saved.

EXPECTED RESULT
The colors should have been autosaved on quit.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Debian sid
KDE Plasma Version: 5.23.0
KDE Frameworks Version: 5.86.0
Qt Version: 5.12.11 (Appimage)
Comment 1 tomtomtomreportingin 2021-10-24 05:52:34 UTC
Since Krita 4 and Krita 5 beta 1 had autosaving palettes, this is a regression of beta 2.
Comment 2 Tiar 2021-10-24 16:48:55 UTC
Probably just another way embedding resources broke with recent changes. Thanks for reporting!
Comment 3 Halla Rempt 2021-10-25 06:44:48 UTC
No, that's not related. It's simply that we now have an explicit save button for palettes to avoid making too many versions when editing a palette.
Comment 4 tomtomtomreportingin 2021-10-25 06:49:36 UTC
The tooltip of that save button notes that it should autosave on quit.
Comment 5 Halla Rempt 2021-10-25 06:52:17 UTC
Yes, but I was replying to Tiar: I think this has never worked since the save button was implemented.
Comment 6 tomtomtomreportingin 2021-10-25 07:02:31 UTC
In beta 1, it acts like this: creating a new palette and adding colors without explicitly saving (with the save button that does exist) will NOT save the colors on quit. After restarting Krita, adding colors to that existing palette without explicitly saving WILL save the colors on quit.

In beta 2, it will NEVER autosave on quit. Notably, on a fresh profile, I observe a segmentation fault in the terminal on exit if I did add some colors, but I do not observe it in my typical environment.
Comment 7 tomtomtomreportingin 2021-10-25 07:28:49 UTC
By the way, I'm not sure if this the right place (or time, this late into 5.0 development) for a suggestion, but: 

Instead of an explicit save button/autosaving on quit to prevent versioning spam, would it be a bad idea to make it so that it only keeps the original and latest modified version of that particular palette for the session, so that it can autosave on modification again? This would also prevent changes being lost from crashes, and perhaps the save button could be replaced with a reload button.
Comment 8 Tiar 2021-10-25 19:34:24 UTC
@Halla I implemented the Save button and I implemented the autosaving; both should work at the same time (it's still less versions that if the palette saved after every swatch change, which is how it was before; autosaving makes it just a bit easier for users). Hence, the autosaving still should work, if it doesn't, then some of the recent changes broke it. Maybe not embedding, but something.

@tomtom's suggestion is a good one, and we need some actual overwriting of resources without making a new version already for bug 443875. But for now, fixing should be somewhat enough, hopefully. (The not saving colors first time after creating a palette needs to be fixed too).
Comment 9 wolthera 2021-11-24 18:04:28 UTC
So uh, I tried reproducing this...

And I get a crash on close! Gonna debug this a little further :D

=============================

Application: Krita (krita), signal: Segmentation fault

[New LWP 548954]
[New LWP 548955]
[New LWP 548956]
[New LWP 548957]
[New LWP 548958]
[New LWP 549247]
[New LWP 549257]
[New LWP 549281]
[New LWP 549282]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
0x00007f38b1cccaff in __GI___poll (fds=0x7ffe5e90aff8, nfds=1, timeout=1000) at ../sysdeps/unix/sysv/linux/poll.c:29
__preamble__
[Current thread is 1 (Thread 0x7f38ac901f80 (LWP 548929))]

Thread 10 (Thread 0x7f38377fe700 (LWP 549282)):
#0  __GI___libc_read (nbytes=16, buf=0x7f38377fdb10, fd=36) at ../sysdeps/unix/sysv/linux/read.c:26
#1  __GI___libc_read (fd=36, buf=0x7f38377fdb10, nbytes=16) at ../sysdeps/unix/sysv/linux/read.c:24
#2  0x00007f38af33fb2f in  () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007f38af2f6ebe in g_main_context_check () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#4  0x00007f38af2f7312 in  () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#5  0x00007f38af2f74a3 in g_main_context_iteration () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#6  0x00007f38b22b55eb in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#7  0x00007f38b225987b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#8  0x00007f38b2073292 in QThread::exec() () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#9  0x00007f38b207442c in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#10 0x00007f38afc74609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#11 0x00007f38b1cd9293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 9 (Thread 0x7f3837fff700 (LWP 549281)):
#0  0x00007f38af2f38ed in  () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#1  0x00007f38af2f5345 in  () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007f38af2f682b in g_main_context_prepare () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007f38af2f729b in  () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#4  0x00007f38af2f74a3 in g_main_context_iteration () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#5  0x00007f38b22b55eb in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#6  0x00007f38b225987b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#7  0x00007f38b2073292 in QThread::exec() () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#8  0x00007f38b207442c in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#9  0x00007f38afc74609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#10 0x00007f38b1cd9293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 8 (Thread 0x7f3845faa700 (LWP 549257)):
#0  syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1  0x00007f38b20769b0 in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#2  0x00007f38b2076816 in QSemaphore::tryAcquire(int, int) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#3  0x00007f38b36dc4e7 in KisTileDataSwapper::waitForWork() (this=<optimized out>) at /home/wolthera/krita/src/libs/image/tiles3/swap/kis_tile_data_swapper.cpp:74
#4  0x00007f38b36dc6ea in KisTileDataSwapper::run() (this=0x7f38b3c2dce0 <(anonymous namespace)::Q_QGS_s_instance::innerFunction()::holder+64>) at /home/wolthera/krita/src/libs/image/tiles3/swap/kis_tile_data_swapper.cpp:80
#5  0x00007f38b207442c in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#6  0x00007f38afc74609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#7  0x00007f38b1cd9293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 7 (Thread 0x7f386e3d3700 (LWP 549247)):
#0  0x00007f38b20738d0 in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#1  0x00007f38b22b5cb5 in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#2  0x00007f38af2f6da1 in g_main_context_check () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007f38af2f7312 in  () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#4  0x00007f38af2f74a3 in g_main_context_iteration () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#5  0x00007f38b22b55eb in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#6  0x00007f38b225987b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#7  0x00007f38b2073292 in QThread::exec() () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#8  0x00007f38b207442c in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#9  0x00007f38afc74609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#10 0x00007f38b1cd9293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 6 (Thread 0x7f3897fff700 (LWP 548958)):
#0  __GI___libc_read (nbytes=16, buf=0x7f3897ffeae0, fd=13) at ../sysdeps/unix/sysv/linux/read.c:26
#1  __GI___libc_read (fd=13, buf=0x7f3897ffeae0, nbytes=16) at ../sysdeps/unix/sysv/linux/read.c:24
#2  0x00007f38af33fb2f in  () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007f38af2f6ebe in g_main_context_check () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#4  0x00007f38af2f7312 in  () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#5  0x00007f38af2f74a3 in g_main_context_iteration () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#6  0x00007f38b22b55eb in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#7  0x00007f38b225987b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#8  0x00007f38b2073292 in QThread::exec() () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#9  0x00007f38af0c6f4b in  () at /usr/lib/x86_64-linux-gnu/libQt5DBus.so.5
#10 0x00007f38b207442c in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#11 0x00007f38afc74609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#12 0x00007f38b1cd9293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 5 (Thread 0x7f389cb8d700 (LWP 548957)):
#0  futex_wait_cancelable (private=<optimized out>, expected=0, futex_word=0x7f38880018d8) at ../sysdeps/nptl/futex-internal.h:183
#1  __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=0x7f3888001888, cond=0x7f38880018b0) at pthread_cond_wait.c:508
#2  __pthread_cond_wait (cond=0x7f38880018b0, mutex=0x7f3888001888) at pthread_cond_wait.c:638
#3  0x00007f38a9a3be7b in  () at /usr/lib/x86_64-linux-gnu/dri/iris_dri.so
#4  0x00007f38a9a3ba7b in  () at /usr/lib/x86_64-linux-gnu/dri/iris_dri.so
#5  0x00007f38afc74609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#6  0x00007f38b1cd9293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 4 (Thread 0x7f38a9662700 (LWP 548956)):
#0  futex_wait_cancelable (private=<optimized out>, expected=0, futex_word=0x7f38880018d8) at ../sysdeps/nptl/futex-internal.h:183
#1  __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=0x7f3888001888, cond=0x7f38880018b0) at pthread_cond_wait.c:508
#2  __pthread_cond_wait (cond=0x7f38880018b0, mutex=0x7f3888001888) at pthread_cond_wait.c:638
#3  0x00007f38a9a3be7b in  () at /usr/lib/x86_64-linux-gnu/dri/iris_dri.so
#4  0x00007f38a9a3ba7b in  () at /usr/lib/x86_64-linux-gnu/dri/iris_dri.so
#5  0x00007f38afc74609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#6  0x00007f38b1cd9293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 3 (Thread 0x7f38a8e61700 (LWP 548955)):
#0  futex_wait_cancelable (private=<optimized out>, expected=0, futex_word=0x7f38880018d8) at ../sysdeps/nptl/futex-internal.h:183
#1  __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=0x7f3888001888, cond=0x7f38880018b0) at pthread_cond_wait.c:508
#2  __pthread_cond_wait (cond=0x7f38880018b0, mutex=0x7f3888001888) at pthread_cond_wait.c:638
#3  0x00007f38a9a3be7b in  () at /usr/lib/x86_64-linux-gnu/dri/iris_dri.so
#4  0x00007f38a9a3ba7b in  () at /usr/lib/x86_64-linux-gnu/dri/iris_dri.so
#5  0x00007f38afc74609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#6  0x00007f38b1cd9293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 2 (Thread 0x7f389e849700 (LWP 548954)):
#0  futex_wait_cancelable (private=<optimized out>, expected=0, futex_word=0x7f38880018d8) at ../sysdeps/nptl/futex-internal.h:183
#1  __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=0x7f3888001888, cond=0x7f38880018b0) at pthread_cond_wait.c:508
#2  __pthread_cond_wait (cond=0x7f38880018b0, mutex=0x7f3888001888) at pthread_cond_wait.c:638
#3  0x00007f38a9a3be7b in  () at /usr/lib/x86_64-linux-gnu/dri/iris_dri.so
#4  0x00007f38a9a3ba7b in  () at /usr/lib/x86_64-linux-gnu/dri/iris_dri.so
#5  0x00007f38afc74609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#6  0x00007f38b1cd9293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 1 (Thread 0x7f38ac901f80 (LWP 548929)):
[KCrash Handler]
#4  KisViewManager::mainWindow() const (this=0x0) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qobject.h:519
#5  0x00007f38b440cfec in KisPaletteEditor::saveNewPaletteVersion() (this=0x55bd57d4d560) at /usr/include/c++/9/bits/atomic_base.h:413
#6  0x00007f386e82f38c in PaletteDockerDock::~PaletteDockerDock() (this=0x55bd57d045f0, __in_chrg=<optimized out>) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qscopedpointer.h:116
#7  0x00007f386e82f3dd in PaletteDockerDock::~PaletteDockerDock() (this=0x55bd57d045f0, __in_chrg=<optimized out>) at /home/wolthera/krita/src/plugins/dockers/palettedocker/palettedocker_dock.cpp:145
#8  0x00007f38b228539e in QObjectPrivate::deleteChildren() () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#9  0x00007f38b2d736a6 in QWidget::~QWidget() () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#10 0x00007f38b0a5eaf7 in KMainWindow::~KMainWindow() (this=0x55bd51eaccf0, __in_chrg=<optimized out>) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qsharedpointer_impl.h:159
#11 0x00007f38b452cae3 in KisMainWindow::~KisMainWindow() (this=0x55bd51eaccf0, __in_chrg=<optimized out>, __vtt_parm=<optimized out>) at /usr/include/c++/9/bits/atomic_base.h:326
#12 0x00007f38b452cdbd in KisMainWindow::~KisMainWindow() (this=0x55bd51eaccf0, __in_chrg=<optimized out>, __vtt_parm=<optimized out>) at /home/wolthera/krita/src/libs/ui/KisMainWindow.cpp:648
#13 0x00007f38b22886b3 in QObject::event(QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#14 0x00007f38b2d77c9d in QWidget::event(QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#15 0x00007f38b2e90a58 in QMainWindow::event(QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#16 0x00007f38b0a5f10b in KMainWindow::event(QEvent*) (this=this@entry=0x55bd51eaccf0, ev=ev@entry=0x55bd57d044f0) at /home/wolthera/krita/src/libs/widgetutils/xmlgui/kmainwindow.cpp:765
#17 0x00007f38b0aa157d in KXmlGuiWindow::event(QEvent*) (this=0x55bd51eaccf0, ev=0x55bd57d044f0) at /home/wolthera/krita/src/libs/widgetutils/xmlgui/kxmlguiwindow.cpp:113
#18 0x00007f38b2d34dc3 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#19 0x00007f38b2d3dbb8 in QApplication::notify(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#20 0x00007f38b44ea9fd in KisApplication::notify(QObject*, QEvent*) (this=<optimized out>, receiver=0x55bd51eaccf0, event=0x55bd57d044f0) at /home/wolthera/krita/src/libs/ui/KisApplication.cpp:705
#21 0x00007f38b225ad7a in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#22 0x00007f38b225d681 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#23 0x00007f38b22b5f77 in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#24 0x00007f38af2f717d in g_main_context_dispatch () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#25 0x00007f38af2f7400 in  () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#26 0x00007f38af2f74a3 in g_main_context_iteration () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#27 0x00007f38b22b55d2 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#28 0x00007f38b225987b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#29 0x00007f38b2261a34 in QCoreApplication::exec() () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#30 0x000055bd4c664320 in main(int, char**) (argc=<optimized out>, argv=<optimized out>) at /home/wolthera/krita/src/krita/main.cc:694
[Inferior 1 (process 548929) detached]
Comment 10 wolthera 2021-11-24 18:10:27 UTC
it's caused by the mainwindow not existing anymore by the time savenewpalette is called (and the mainwindow is requested because of the rename-flow) :)

Let's see what we can do there...
Comment 11 Bug Janitor Service 2021-11-24 18:29:27 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/krita/-/merge_requests/1172
Comment 12 wolthera 2021-11-25 18:21:58 UTC
Git commit fcbb682c1c4256615446c62eb5b7e183fae92554 by Wolthera van Hövell.
Committed on 25/11/2021 at 18:21.
Pushed by woltherav into branch 'krita/5.0'.

Fix saving palette on quit, specifically avoiding the potential crash.

The save-with-user-input flow requires a widget to parent it's potential
messages and other widgets to, but when we're closing the application
no such potential widgets exists anymore, leading to a crash.

Therefore, we'll just save the palette regularly, but only if it already
has a resource-version. I don't think it's currently possible to have
a palette without resource version, so that should suffice.

This also seems to fix actually saving the resource upon close, which was
the original bug to begin with.

M  +9    -3    libs/ui/KisPaletteEditor.cpp

https://invent.kde.org/graphics/krita/commit/fcbb682c1c4256615446c62eb5b7e183fae92554
Comment 13 wolthera 2021-11-25 18:22:19 UTC
Git commit 1cbfa33b202b178ff34df6f0f379acf841900f12 by Wolthera van Hövell.
Committed on 25/11/2021 at 18:22.
Pushed by woltherav into branch 'master'.

Fix saving palette on quit, specifically avoiding the potential crash.

The save-with-user-input flow requires a widget to parent it's potential
messages and other widgets to, but when we're closing the application
no such potential widgets exists anymore, leading to a crash.

Therefore, we'll just save the palette regularly, but only if it already
has a resource-version. I don't think it's currently possible to have
a palette without resource version, so that should suffice.

This also seems to fix actually saving the resource upon close, which was
the original bug to begin with.


(cherry picked from commit fcbb682c1c4256615446c62eb5b7e183fae92554)

M  +9    -3    libs/ui/KisPaletteEditor.cpp

https://invent.kde.org/graphics/krita/commit/1cbfa33b202b178ff34df6f0f379acf841900f12
Comment 14 tomtomtomreportingin 2021-11-27 01:33:17 UTC
"creating a new palette and adding colors without explicitly saving (with the save button that does exist) will NOT save the colors on quit"
This case still occurs as of git 4a272ff. Also, a palette created within the same session will not have a properly functioning explicit save button and will not show up in the list of palettes. Selecting a different palette within the same session will spawn a safe assert:

SAFE ASSERT (krita): "!m_d->isModified" in file /home/appimage/workspace/Krita_Nightly_Appimage_Build/krita/libs/ui/KisPaletteEditor.cpp, line 522
Comment 15 wolthera 2021-11-27 16:47:39 UTC
Ok, it seems the problem is question is because the palette has no index when it's freshly created, which in turn means it won't be recognized as global, which means it will not save.

This *only* happens when the palette has been created that specific session.

Some more data:
1. Both indexForResource and indexForResourceId return an invalid index.
2. The new palette does get a resource ID. 
3. Going into KisResourceModel::indexForResource and doing qDebug() << source->indexForResource(resource); reveals that the sourcemodel does have an index for it (I get "QModelIndex(73,0,0x0,KisAllResourcesModel(0x560671b3b660))" for my last attempt), but then mapFromSource is unable to return a proper index for it.

Tiar, I'm afraid you'll have to take over here, I know too little about the different mappings to even guess where it is going wrong.
Comment 16 Bug Janitor Service 2021-12-03 11:12:14 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/krita/-/merge_requests/1196
Comment 17 Dmitry Kazakov 2021-12-03 11:49:11 UTC
Git commit 655e5c25d87422349c2cef8fbb283e706fec4ea5 by Dmitry Kazakov.
Committed on 03/12/2021 at 11:07.
Pushed by dkazakov into branch 'master'.

Fix broken model indexes when a duplicated resource is added

After adding GROUP BY expression to the resources I should have
modified the rowCount() query as well. Otherwise they go out of
sync.

M  +8    -1    libs/resources/KisResourceModel.cpp

https://invent.kde.org/graphics/krita/commit/655e5c25d87422349c2cef8fbb283e706fec4ea5
Comment 18 Dmitry Kazakov 2021-12-03 11:59:04 UTC
Git commit e6a740f89422defedbf64525b6fd4e01cd5f36ac by Dmitry Kazakov.
Committed on 03/12/2021 at 11:50.
Pushed by dkazakov into branch 'krita/5.0'.

Fix broken model indexes when a duplicated resource is added

After adding GROUP BY expression to the resources I should have
modified the rowCount() query as well. Otherwise they go out of
sync.

M  +8    -1    libs/resources/KisResourceModel.cpp

https://invent.kde.org/graphics/krita/commit/e6a740f89422defedbf64525b6fd4e01cd5f36ac