[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-kimageshop
Subject:    =?utf-8?q?=5Bgraphics/krita/krita/5=2E0=5D_/=3A_Correctly_fix_name_refresh_of_paintop_and_SeExpr_pre
From:       L. E. Segovia <null () kde ! org>
Date:       2021-11-25 13:49:04
Message-ID: 20211125134904.3AA9A12421F5 () leptone ! kde ! org
[Download RAW message or body]

Git commit be7013420e4277a7e393148b797b37bf66488c84 by L. E. Segovia.
Committed on 25/11/2021 at 13:47.
Pushed by lsegovia into branch 'krita/5.0'.

Correctly fix name refresh of paintop and SeExpr presets

778e8432d5e32d32af7c29a54175ca3470d5100e attempts to fix this by forcing
an update of the name widget. This is incorrect, as the underlying preset
instance still has (and will until replaced) the old name. This is easy to
verify by qWarning() both instances' name() after
the resourceSelected call.

The fix here is to:
- apply the changes to the freshly renamed resource,
- and *then* (not before) issuing the resourceSelected call.

CCBUG: 445048
CCMAIL: kimageshop@kde.org

M  +7    -5    libs/ui/widgets/kis_paintop_presets_editor.cpp
M  +4    -4    plugins/generators/seexpr/kis_wdg_seexpr.cpp

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

diff --git a/libs/ui/widgets/kis_paintop_presets_editor.cpp \
b/libs/ui/widgets/kis_paintop_presets_editor.cpp index 80bf618cf5..9253eb0b6d 100644
--- a/libs/ui/widgets/kis_paintop_presets_editor.cpp
+++ b/libs/ui/widgets/kis_paintop_presets_editor.cpp
@@ -384,16 +384,18 @@ void KisPaintOpPresetsEditor::slotSaveRenameCurrentBrush()
     // create a new brush preset with the name specified and add to resource \
provider  KisResourceModel model(ResourceType::PaintOpPresets);
     KoResourceSP properCleanResource = model.resourceForId(currentPresetResourceId);
-    KisResourceUserOperations::renameResourceWithUserInput(this, \
properCleanResource, renamedPresetName); +    const bool success = \
KisResourceUserOperations::renameResourceWithUserInput(this, properCleanResource, \
renamedPresetName);  
-    resourceSelected(curPreset); // refresh and select our freshly renamed resource
     if (isDirty) {
-        m_d->resourceProvider->currentPreset()->setSettings(prevSettings);
-        m_d->resourceProvider->currentPreset()->setDirty(isDirty);
+        properCleanResource.dynamicCast<KisPaintOpPreset>()->setSettings(prevSettings);
 +        properCleanResource.dynamicCast<KisPaintOpPreset>()->setDirty(isDirty);
     }
+
+    // refresh and select our freshly renamed resource
+    if (success) resourceSelected(properCleanResource);
+
     m_d->favoriteResManager->updateFavoritePresets();
 
-    m_d->uiWdgPaintOpPresetSettings.renameBrushNameTextField->setText(curPreset->name());
                
     slotUpdatePresetSettings(); // update visibility of dirty preset and icon
 }
 
diff --git a/plugins/generators/seexpr/kis_wdg_seexpr.cpp \
b/plugins/generators/seexpr/kis_wdg_seexpr.cpp index 286014a440..841605f14e 100644
--- a/plugins/generators/seexpr/kis_wdg_seexpr.cpp
+++ b/plugins/generators/seexpr/kis_wdg_seexpr.cpp
@@ -235,14 +235,14 @@ void KisWdgSeExpr::slotSaveRenameCurrentPreset()
     KoResourceSP properCleanResource = model.resourceForId(currentPresetResourceId);
     const bool success = \
KisResourceUserOperations::renameResourceWithUserInput(this, properCleanResource, \
renamedPresetName);  
-
     if (isDirty) {
-        m_currentPreset->setScript(prevScript);
-        m_currentPreset->setDirty(isDirty);
+        properCleanResource.dynamicCast<KisSeExprScript>()->setScript(prevScript);
+        properCleanResource.dynamicCast<KisSeExprScript>()->setDirty(isDirty);
     }
 
     // refresh and select our freshly renamed resource
-    if (success) slotResourceSelected(m_currentPreset);
+    if (success) slotResourceSelected(properCleanResource);
+
 
     slotUpdatePresetSettings(); // update visibility of dirty preset and icon
 }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic