[chirp_devel] [PATCH] Prevent re-entrant calls to 'update_recent_files' when opening a file from the 'Recent Files' menu action
# HG changeset patch # User Kosta A. ve7kcy@gmail.com # Date 1632716707 25200 # Sun Sep 26 21:25:07 2021 -0700 # Branch update-recent # Node ID 261a9ac27d14a2e285bd492ffff67a98af56540c # Parent 5aa2294d78ea241c6573dcf1929475b072e73685 Prevent re-entrant calls to 'update_recent_files' when opening a file from the 'Recent Files' menu action.
Gtk was failing on this and was sending an error message to the console.
diff --git a/chirp/ui/mainapp.py b/chirp/ui/mainapp.py --- a/chirp/ui/mainapp.py +++ b/chirp/ui/mainapp.py @@ -540,9 +540,13 @@ CONF.set(key, fn, "state") else: CONF.remove_option(key, "state") + self.recent_files = None
def update_recent_files(self): - recent_files = self._get_recent_list() + if (not self.recent_files == None): + return + + self.recent_files = self._get_recent_list() for index in range(0, KEEP_RECENT): action_name = "recent%i" % index path = "/MenuBar/file/recent" @@ -552,8 +556,8 @@ old_action.set_visible(False) self.menu_ag.remove_action(old_action)
- if (index < len(recent_files)): - fname = recent_files[index] + if (index < len(self.recent_files)): + fname = self.recent_files[index] widget_label = os.path.basename(fname).replace("_", "__") widget_tip = _("Open recent file") + (" {name}").format( name=fname) @@ -583,11 +587,9 @@ recent_files.append(fname)
self._set_recent_list(recent_files) - self.update_recent_files()
def clear_recent_files(self): self._set_recent_list([]) - self.update_recent_files()
def import_stock_config(self, action, config): eset = self.get_current_editorset() @@ -2092,6 +2094,9 @@
self.add_accel_group(self.menu_uim.get_accel_group())
+ self.recentmenu = self.menu_uim.get_widget( + "/MenuBar/file/recent") + self.infomenu = self.menu_uim.get_widget( "/MenuBar/help/clone_information")
@@ -2100,6 +2105,7 @@
# Initialize self.do_toggle_developer(self.menu_ag.get_action("developer")) + self.recentmenu.connect("activate", lambda a: self.update_recent_files())
return self.menu_uim.get_widget("/MenuBar")
@@ -2325,6 +2331,7 @@ d.destroy() CONF.set_bool("warned_about_reporting", True)
+ self.recent_files = None self.update_recent_files() try: self.update_stock_configs()
# HG changeset patch # User Kosta A. ve7kcy@gmail.com # Date 1632716707 25200 # Sun Sep 26 21:25:07 2021 -0700 # Branch update-recent # Node ID 261a9ac27d14a2e285bd492ffff67a98af56540c # Parent 5aa2294d78ea241c6573dcf1929475b072e73685 Prevent re-entrant calls to 'update_recent_files' when opening a file from the 'Recent Files' menu action.
Gtk was failing on this and was sending an error message to the console.
There's no bug here and the description doesn't really explain what the problem is. What is the GTK error message? What does it mean, and what is the problem?
--Dan
participants (2)
-
Dan Smith
-
Kosta A.