aboutsummaryrefslogtreecommitdiffstats
path: root/ui/recent_utils.h
diff options
context:
space:
mode:
authorJohn Thacker <johnthacker@gmail.com>2023-11-14 23:05:40 -0500
committerAndersBroman <a.broman58@gmail.com>2023-11-15 08:57:36 +0000
commitbee7b2cb8e4d61681617e274d2c1ac7d0bbc6f6f (patch)
tree9c3cf76d5a67d8fa4db0fac1f3f2f773dbe8ec78 /ui/recent_utils.h
parent8988d21d265effc3c014bce496406d780bb253c8 (diff)
Qt: Fix Recent Files Max Count at startup
The recent files are read from recent_common in main.cpp, which happens before the prefs are read. (This is largely unavoidable, as we need some things in recent first, notably the last used preference Configuration Profile.) That means we add the recent files before we've read the preference that determines the maximum number of recent files, so it still has its initial value of 10 - the number of files in recent_common will be whatever value the last used Configuration Profile had for the preference, and could be greater (or lesser) than 10. It could also be different than the value for the preference after the preferences are loaded, if Wireshark is started with command line options like -C, -o, or -P. Add a parameter so that on initial startup, when recent_common is read, we add all the files to the list heedless of the pref value. Add connections so that the Menu and the Welcome Page list update the list of recent files whenever the Preferences are changed (including from changing Configuration Profiles), because that might change the max number of recent files. Add a few guards for putting too many items in the recent common file or the menu, for when the preference changes so that the maximum count is lower than it was previously. Fix #16782
Diffstat (limited to 'ui/recent_utils.h')
-rw-r--r--ui/recent_utils.h13
1 files changed, 10 insertions, 3 deletions
diff --git a/ui/recent_utils.h b/ui/recent_utils.h
index 711f80d1f1..466555e073 100644
--- a/ui/recent_utils.h
+++ b/ui/recent_utils.h
@@ -17,9 +17,16 @@
extern "C" {
#endif /* __cplusplus */
-/* Add a new recent capture filename to the "Recent Files" submenu
- (duplicates will be ignored) */
-extern void add_menu_recent_capture_file(const gchar *cf_name);
+/** Add a new recent capture filename to the "Recent Files" submenu
+ * (duplicates will be ignored)
+ *
+ * @param cf_name Capture filename to add
+ * @param force If true, then prefs.gui_recent_file_count_max will be
+ * ignored when adding the file. This is for startup, when the recent_common
+ * file is read before the prefs file. (It will be corrected later when
+ * prefs are read.)
+ */
+extern void add_menu_recent_capture_file(const gchar *cf_name, bool force);
/** Write all recent capture filenames to the user's recent file.
* @param rf recent file