Skip to content

Fix rename folder does not work - #1072

Merged
danirabbit merged 3 commits into
masterfrom
ryonakano/fix-folder-list-edit
Aug 5, 2026
Merged

Fix rename folder does not work #1072
danirabbit merged 3 commits into
masterfrom
ryonakano/fix-folder-list-edit

Conversation

@ryonakano

Copy link
Copy Markdown
Member

Fixes #1071
Can be rebase-merged if desired.

Changes Summary

1. ExpandableItem: Do not overwrite editable which already set

Fixes the constructor of ExpandableItem class overwrites editable which contains value set in update_infos() of FolderItemModel class.

How to validate this fix

Try adding the following debug codes against latest master:

diff --git a/src/FolderList/FolderItemModel.vala b/src/FolderList/FolderItemModel.vala
index 0d765e25..d734e6bb 100644
--- a/src/FolderList/FolderItemModel.vala
+++ b/src/FolderList/FolderItemModel.vala
@@ -113,6 +113,8 @@ public class Mail.FolderItemModel : Mail.SourceList.ExpandableItem {
             editable = false;
             edited.disconnect (rename);
         }
+
+        warning ("FolderItemModel name=%s, editable=%s", name, editable.to_string ());
     }
 
     private async void refresh () {
diff --git a/src/SourceList/SourceList.vala b/src/SourceList/SourceList.vala
index c758f662..80322bff 100644
--- a/src/SourceList/SourceList.vala
+++ b/src/SourceList/SourceList.vala
@@ -418,6 +418,8 @@ public class Mail.SourceList : Gtk.ScrolledWindow {
 
         construct {
             editable = false;
+
+            warning ("ExpandableItem name=%s, editable=%s", name, editable.to_string ());
         }
 
         /**

You can see editable flags of non-special folders are overwritten from true to false:

** (io.elementary.mail:6793): WARNING **: 22:56:19.036: FolderItemModel.vala:117: FolderItemModel name=Inbox, editable=false

** (io.elementary.mail:6793): WARNING **: 22:56:19.036: SourceList.vala:422: ExpandableItem name=Inbox, editable=false

** (io.elementary.mail:6793): WARNING **: 22:56:19.036: FolderItemModel.vala:117: FolderItemModel name=[Gmail], editable=true

** (io.elementary.mail:6793): WARNING **: 22:56:19.036: SourceList.vala:422: ExpandableItem name=[Gmail], editable=false

2. SourceList: Fix double-click does not trigger rename

Fixes the following warning is shown when double-clicking the source list:

** (io.elementary.mail:9075): CRITICAL **: 23:15:29.989: mail_source_list_tree_start_editing_item: assertion 'item != NULL' failed

This is because item is already freed when the callback of Idle.add_once() is called because on_button_pressed() is already returned.

3. FolderItemModel: Fix coredump when deciding new name

Mails coredumps when finishing rename with the following place:

Thread 1 "io.elementary.m" received signal SIGSEGV, Segmentation fault.
mail_folder_item_model_rename_co (_data_=0x5baf932ed1d0) at ../src/FolderList/FolderItemModel.vala:184
184             yield offlinestore.rename_folder (folder_info.full_name, new_full_name, GLib.Priority.DEFAULT, cancellable);

This is because folder_info points to null when the new name is not yet taken when offlinestore.folder_info() is called just before here. So, rename folder_info to new_folder_info so that folder_info as a property of FolderItemModel class is not sealed unintentionally.

Checklist

  • Confirmed folders can be renamed with F2, double-clicking, and the context menu
  • Confirmed the new folder name renamed in Mails is reflected to the server (I used Evolution to confirm this)
Screencast.From.2026-08-05.23-54-35.mp4

Fixes the following warning:

** (io.elementary.mail:9075): CRITICAL **: 23:15:29.989: mail_source_list_tree_start_editing_item: assertion 'item != NULL' failed
Mails coredumps when finishing rename with the following place:

    Thread 1 "io.elementary.m" received signal SIGSEGV, Segmentation fault.
    mail_folder_item_model_rename_co (_data_=0x5baf932ed1d0) at ../src/FolderList/FolderItemModel.vala:184
    184	            yield offlinestore.rename_folder (folder_info.full_name, new_full_name, GLib.Priority.DEFAULT, cancellable);

This is because folder_info points to null when the new name is not yet taken
when offlinestore.folder_info() is called just before here.

So, rename folder_info to new_folder_info so that folder_info as a property of
FolderItemModel class is not sealed unintentionally.
@ryonakano
ryonakano requested a review from a team August 5, 2026 14:58
@ryonakano ryonakano added this to OS 9 Aug 5, 2026
@ryonakano ryonakano moved this to Needs Review in OS 9 Aug 5, 2026
Comment on lines +1624 to +1628
// Keep back reference of item so that it can be accessed in Idle.add_once()
// where item is already freed
activated = item;
// Start editing after native event handlers finished else fails
Idle.add_once (() => { start_editing_item (item); });
Idle.add_once (() => { start_editing_item (activated); });

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like that Idle is used here. Does tweaking when on_button_pressed is called fixes the issue? button_controller's propagations phase is set to capture, while default handlers run in bubble phase. Does changing the propagation phase make a difference?

@danirabbit danirabbit Aug 5, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually wonder if we can remove this whole n_press case? I don't think double-click-rename is a pattern we use anywhere else

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't confirm that changing propagation phase fixes the issue

@danirabbit
danirabbit merged commit 1140d5e into master Aug 5, 2026
6 checks passed
@danirabbit
danirabbit deleted the ryonakano/fix-folder-list-edit branch August 5, 2026 19:20
@github-project-automation github-project-automation Bot moved this from Needs Review to Done in OS 9 Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Rename folder does not work

3 participants