Bug 419800

Summary: Crash when selecting custom brush
Product: [Applications] krita Reporter: Yu-Hsuan Lai <raincolee>
Component: Resource ManagementAssignee: Halla Rempt <halla>
Status: RESOLVED FIXED    
Severity: normal CC: ahab.greybeard, halla, tamtamy.tymona
Priority: NOR    
Version First Reported In: nightly build (please specify the git hash!)   
Target Milestone: ---   
Platform: macOS (DMG)   
OS: macOS   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Log printed in terminal where Krita was launched
the crash log shown by the OS.

Description Yu-Hsuan Lai 2020-04-07 16:18:41 UTC
Created attachment 127358 [details]
Log printed in terminal where Krita was launched

SUMMARY
Crash immediately when I select a brush preset I just created.

STEPS TO REPRODUCE
1. Open a file with Krita
2. Select a brush, say Wet Paint
3. "Save New Brush Preset..." from Brush Options
4. Save the brush
5. Select the newly created brush from Brush Presets docker

OBSERVED RESULT
Crash

EXPECTED RESULT
The newly-created brush is selected

SOFTWARE/OS VERSIONS
macOS: 10.14.6
Krita: Nightly build. Git commit 5a1f66f

ADDITIONAL INFORMATION
See logs in attachment
Comment 1 Yu-Hsuan Lai 2020-04-07 16:19:04 UTC
Created attachment 127359 [details]
the crash log shown by the OS.
Comment 2 Yu-Hsuan Lai 2020-04-07 16:20:30 UTC
The canvas accelection option is already off, so I think it's a different bug from Bug 419783.
Comment 3 Tiar 2020-04-07 16:33:00 UTC
I'll set it to Resource Management because it sounds like an issue with resource rewrite, more precisely, Ivan's part of it, which is versioned resources.
Comment 4 Halla Rempt 2020-04-07 17:54:49 UTC
Have you really managed to get the nightly macOS build to run?
Comment 5 Yu-Hsuan Lai 2020-04-08 02:00:50 UTC
(In reply to Boudewijn Rempt from comment #4)
> Have you really managed to get the nightly macOS build to run?

I'm not sure if I got what you meant. I simply download the built file from the official site. Am I supposed to build it myself?
Comment 6 Yu-Hsuan Lai 2020-04-08 05:19:59 UTC
Update:  this problem doesn't occur in Krita 4.2.9 (the latest stable version)
Comment 7 Ahab Greybeard 2020-04-08 16:00:42 UTC
I can confirm this for appimages as follows:

4.2.9: does not happen
4.3.0 prealpha (18 Mar) git 9a24cf0 does not happen
4.3.0 prealpha (26 Mar) git 66b65ab it happens
4.3.0 prealpha (01 Apr) git 62b9516 it happens
5.0.0 prealpha (08 Apr) git 78d1d45 it happens

Using the 08 Apr 5.0.0 preslpah, the newly created brush preset appears in the brush presets docker and there is a crash if it is selected there.
For appimages where this happens, other appimages show the newly created preset in the brush preset docker and crash on selection.
For appimages where it does not happen, the newly created preset is not shown in the brush presets docker.

The newly created preset is not present in the paintoppresest folder if this is done with the 08 Apr 5.0.0 prealpha

There is a folder in the krita resources folder called 'Krita_4_Default_Resources.bundle_modified' which has a folder called 'paintoppresets' and this contains a .png file, named as the newly created preset, which is the icon for the brush preset that was created. (Probably because I created it by modifying one of the standard Krita-4 resource bundle brush presets.

If this is done with the 01 Apr 4.3.0 prealpha, then the .png file, comtaining the icon for the newly created preset is in the 'usual' paintoppresets folder and does not appear in the brush presets docker for any version.

Setting to Confirmed.
Comment 8 Halla Rempt 2020-06-30 11:48:56 UTC
Backtrace: 

[KCrash Handler]
#4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#5  0x00007f9d96056801 in __GI_abort () at abort.c:79
#6  0x00007f9d96a8168b in qt_message_fatal (context=..., message=<synthetic pointer>...) at global/qlogging.cpp:1914
#7  QMessageLogger::fatal (this=this@entry=0x7ffc0949c390, msg=msg@entry=0x7f9d96d819a0 "ASSERT: \"%s\" in file %s, line %d") at global/qlogging.cpp:893
#8  0x00007f9d96a80e81 in qt_assert (assertion=assertion@entry=0x7f9d988248b1 "loader", file=file@entry=0x7f9d98824808 "/home/boud/dev/model-rewrite/libs/resources/KisFolderStorage.cpp", line=line@entry=204) at global/qglobal.cpp:3342
#9  0x00007f9d98778366 in KisFolderStorage::resource (this=<optimized out>, url=...) at /home/boud/dev/model-rewrite/libs/resources/KisFolderStorage.cpp:204
#10 0x00007f9d987a6be6 in KisResourceStorage::resource (this=this@entry=0x562269e942e0, url=...) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qsharedpointer_impl.h:306
#11 0x00007f9d987a1387 in KisResourceLocator::resource (this=0x562269ecc2c0, storageLocation=..., resourceType=..., filename=...) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qstringbuilder.h:131
#12 0x00007f9d987a2438 in KisResourceLocator::resourceForId (this=0x562269ecc2c0, resourceId=<optimized out>) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qrefcount.h:60
#13 0x00007f9d987aa261 in KisAllResourcesModel::resourceForId (this=<optimized out>, id=876) at /home/boud/dev/model-rewrite/libs/resources/KisResourceModel.cpp:316
#14 0x00007f9d987aa5d2 in non-virtual thunk to KisAllResourcesModel::resourceForIndex(QModelIndex) const () at /usr/include/x86_64-linux-gnu/qt5/QtCore/qsharedpointer_impl.h:158
#15 0x00007f9d987ab1e4 in non-virtual thunk to KisResourceModel::resourceForIndex(QModelIndex) const () at /usr/include/x86_64-linux-gnu/qt5/QtCore/qsharedpointer_impl.h:311
#16 0x00007f9d9a46ffc4 in non-virtual thunk to KisPresetChooser::PaintOpFilterModel::resourceForIndex(QModelIndex) const () from /home/boud/dev/i-model-rewrite/lib/x86_64-linux-gnu/libkritaui.so.17
#17 0x00007f9d987b2f28 in KisTagFilterResourceProxyModel::resourceForIndex (this=0x56226eed10a0, index=...) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qsharedpointer_impl.h:311
#18 0x00007f9d93dcc7d2 in KisResourceItemChooser::resourceFromModelIndex (this=this@entry=0x56226eed0d40, index=...) at /home/boud/dev/model-rewrite/libs/resourcewidgets/KisResourceItemChooser.cpp:437
#19 0x00007f9d93dcd803 in KisResourceItemChooser::activated (this=0x56226eed0d40, index=...) at /home/boud/dev/model-rewrite/libs/resourcewidgets/KisResourceItemChooser.cpp:349
#20 0x00007f9d93dbe737 in KisResourceItemChooser::qt_static_metacall (_o=<optimized out>, _c=<optimized out>, _id=<optimized out>, _a=<optimized out>) at /home/boud/dev/b-model-rewrite/libs/resourcewidgets/kritaresourcewidgets_autogen/EWIEGA46WW/moc_KisResourceItemChooser.cpp:123
#21 0x00007f9d96cd04b9 in doActivate<false> (sender=0x56226eed1770, signal_index=16, argv=0x7ffc0949cad0) at kernel/qobject.cpp:3882
#22 0x00007f9d96ccaf92 in QMetaObject::activate (sender=sender@entry=0x56226eed1770, m=m@entry=0x7f9d93fe2860 <KisResourceItemListView::staticMetaObject>, local_signal_index=local_signal_index@entry=1, argv=argv@entry=0x7ffc0949cad0) at kernel/qobject.cpp:3930
#23 0x00007f9d93dbd785 in KisResourceItemListView::currentResourceChanged (this=this@entry=0x56226eed1770, _t1=...) at /home/boud/dev/b-model-rewrite/libs/resourcewidgets/kritaresourcewidgets_autogen/EWIEGA46WW/moc_KisResourceItemListView.cpp:185
#24 0x00007f9d93dcf85d in KisResourceItemListView::selectionChanged (this=0x56226eed1770, selected=...) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qlist.h:253
#25 0x00007f9d97de0ce1 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#26 0x00007f9d96cd04b9 in doActivate<false> (sender=0x56226eed9690, signal_index=3, argv=0x7ffc0949cc40) at kernel/qobject.cpp:3882
#27 0x00007f9d96ccaf92 in QMetaObject::activate (sender=sender@entry=0x56226eed9690, m=m@entry=0x7f9d97162180 <QItemSelectionModel::staticMetaObject>, local_signal_index=local_signal_index@entry=0, argv=argv@entry=0x7ffc0949cc40) at kernel/qobject.cpp:3930
#28 0x00007f9d96c3e917 in QItemSelectionModel::selectionChanged (this=this@entry=0x56226eed9690, _t1=..., _t2=...) at .moc/moc_qitemselectionmodel.cpp:459
#29 0x00007f9d96c43450 in QItemSelectionModel::emitSelectionChanged (this=this@entry=0x56226eed9690, newSelection=..., oldSelection=...) at itemmodels/qitemselectionmodel.cpp:1872
#30 0x00007f9d96c464d3 in QItemSelectionModel::select (this=0x56226eed9690, selection=..., command=...) at itemmodels/qitemselectionmodel.cpp:1338
#31 0x00007f9d97e1c712 in QListView::setSelection(QRect const&, QFlags<QItemSelectionModel::SelectionFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#32 0x00007f9d97de2ef9 in QAbstractItemView::mousePressEvent(QMouseEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#33 0x00007f9d97bc622f in QWidget::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#34 0x00007f9d97c6bbee in QFrame::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#35 0x00007f9d97de7f63 in QAbstractItemView::viewportEvent(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#36 0x00007f9d93dcfccf in KisResourceItemListView::viewportEvent (this=0x56226eed1770, event=0x7ffc0949d7f0) at /home/boud/dev/model-rewrite/libs/resourcewidgets/KisResourceItemListView.cpp:83
#37 0x00007f9d96c9522d in QCoreApplicationPrivate::sendThroughObjectEventFilters (receiver=0x56226eed1920, event=0x7ffc0949d7f0) at kernel/qcoreapplication.cpp:1201
#38 0x00007f9d97b84982 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#39 0x00007f9d97b8c9f8 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#40 0x00007f9d9a532b99 in KisApplication::notify (this=<optimized out>, receiver=0x56226eed1920, event=0x7ffc0949d7f0) at /home/boud/dev/model-rewrite/libs/ui/KisApplication.cpp:736
#41 0x00007f9d96c954a8 in QCoreApplication::notifyInternal2 (receiver=0x56226eed1920, event=0x7ffc0949d7f0) at kernel/qcoreapplication.cpp:1075
#42 0x00007f9d97b8b07f in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool, bool) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#43 0x00007f9d97bdff81 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#44 0x00007f9d97be2dea in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#45 0x00007f9d97b849ac in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#46 0x00007f9d97b8bbb0 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#47 0x00007f9d9a532b99 in KisApplication::notify (this=<optimized out>, receiver=0x56226b3f9590, event=0x7ffc0949dcf0) at /home/boud/dev/model-rewrite/libs/ui/KisApplication.cpp:736
#48 0x00007f9d96c954a8 in QCoreApplication::notifyInternal2 (receiver=0x56226b3f9590, event=0x7ffc0949dcf0) at kernel/qcoreapplication.cpp:1075
#49 0x00007f9d972928b5 in QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#50 0x00007f9d972939e5 in QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#51 0x00007f9d9726c1cb in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#52 0x00007f9d86d3af9a in ?? () from /usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5
#53 0x00007f9d8ddef417 in g_main_context_dispatch () from /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#54 0x00007f9d8ddef650 in ?? () from /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#55 0x00007f9d8ddef6dc in g_main_context_iteration () from /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#56 0x00007f9d96cf47ac in QEventDispatcherGlib::processEvents (this=0x562267fa1c00, flags=...) at kernel/qeventdispatcher_glib.cpp:423
#57 0x00007f9d96c93d2a in QEventLoop::exec (this=this@entry=0x7ffc0949e090, flags=..., flags@entry=...) at kernel/qeventloop.cpp:225
#58 0x00007f9d96c9d4a0 in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1383
#59 0x0000562265871f01 in main (argc=<optimized out>, argv=0x7ffc0949e3b8) at /home/boud/dev/model-rewrite/krita/main.cc:591
[Inferior 1 (process 14497) detached]
Comment 9 Halla Rempt 2020-06-30 12:53:59 UTC
Git commit 43a1aa98773314788ff632e4849dfb16cdef0d74 by Boudewijn Rempt.
Committed on 30/06/2020 at 12:53.
Pushed by rempt into branch 'rempt/resourcemodel_rewrite'.

Make sure presets are saved with a suffix

Otherwise we cannot get the loader for the preset.

M  +5    -0    libs/ui/widgets/kis_paintop_presets_save.cpp

https://invent.kde.org/graphics/krita/commit/43a1aa98773314788ff632e4849dfb16cdef0d74