gnucash stable: Multiple changes pushed

John Ralls jralls at code.gnucash.org
Tue Jun 25 16:59:00 EDT 2024


Updated	 via  https://github.com/Gnucash/gnucash/commit/88542381 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/422bfdf0 (commit)
	from  https://github.com/Gnucash/gnucash/commit/3482a488 (commit)



commit 8854238103c28f3635d2aa1fd15ef4b8ace695f2
Merge: 3482a488a9 422bfdf052
Author: John Ralls <jralls at ceridwen.us>
Date:   Tue Jun 25 13:56:23 2024 -0700

    Merge Bob Fewll's 'bug799334' into stable.


commit 422bfdf052ba39a1ebe69041638ef6fdbd3f2648
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Mon Jun 17 11:29:56 2024 +0100

    Bug 799334 - GnuCash re-opens to incorrect page
    
    If there are transient pages open on close, like search result pages,
    they are not restored which results in the wrong page being selected
    on restore.
    
    To fix this, remember the pages that are not restored so the position
    of pages in the saved order can be adjusted.

diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp
index f618d9c35b..09e59c3a41 100644
--- a/gnucash/gnome-utils/gnc-main-window.cpp
+++ b/gnucash/gnome-utils/gnc-main-window.cpp
@@ -435,13 +435,16 @@ gnc_main_window_foreach_page (GncMainWindowPageFunc fn, gpointer user_data)
  *  installed.
  *
  *  @param data A data structure containing state about the
- *  window/page restoration process. */
-static void
+ *  window/page restoration process.
+ * 
+ *  @return true if page was added else false.
+ *  */
+static gboolean
 gnc_main_window_restore_page (GncMainWindow *window,
                               GncMainWindowSaveData *data)
 {
     GncMainWindowPrivate *priv;
-    GncPluginPage *page;
+    GncPluginPage *page = nullptr;
     gchar *page_group, *page_type = nullptr, *name = nullptr;
     const gchar *class_type;
     GError *error = nullptr;
@@ -514,6 +517,8 @@ cleanup:
     if (page_type)
         g_free(page_type);
     g_free(page_group);
+
+    return (page ? true : false);
 }
 
 static bool
@@ -634,6 +639,8 @@ gnc_main_window_restore_window (GncMainWindow *window, GncMainWindowSaveData *da
     gsize length;
     gsize page_start, page_count, i;
     GError *error = nullptr;
+    GSList *added_page_offsets = nullptr;
+    gint offset = 0;
 
     /* Setup */
     ENTER("window %p, data %p (key file %p, window %d)",
@@ -777,7 +784,12 @@ gnc_main_window_restore_window (GncMainWindow *window, GncMainWindowSaveData *da
     {
         data->page_offset = page_start;
         data->page_num = i;
-        gnc_main_window_restore_page(window, data);
+        gboolean page_added = gnc_main_window_restore_page (window, data);
+
+        added_page_offsets = g_slist_append (added_page_offsets, GINT_TO_POINTER(offset));
+
+        if (!page_added) // if page not added, increase offset to compensate
+            offset ++;
 
         /* give the page a chance to display */
         while (gtk_events_pending ())
@@ -809,14 +821,15 @@ gnc_main_window_restore_window (GncMainWindow *window, GncMainWindowSaveData *da
         /* Now rebuild the list from the key file. */
         for (i = 0; i < length; i++)
         {
-            gpointer page = g_list_nth_data(priv->installed_pages, order[i] - 1);
+            gint offset = GPOINTER_TO_INT(g_slist_nth_data (added_page_offsets, order[i] - 1));
+            gpointer page = g_list_nth_data (priv->installed_pages, order[i] - 1 - offset);
             if (page)
             {
                 priv->usage_order = g_list_append(priv->usage_order, page);
             }
         }
         gtk_notebook_set_current_page (GTK_NOTEBOOK(priv->notebook),
-                                       order[0] - 1);
+                                       order[0] - 1 - offset);
 
         g_signal_emit_by_name (window, "page_changed",
                                g_list_nth_data (priv->usage_order, 0));
@@ -828,6 +841,7 @@ gnc_main_window_restore_window (GncMainWindow *window, GncMainWindowSaveData *da
 
     LEAVE("window %p", window);
 cleanup:
+    g_slist_free (added_page_offsets);
     if (error)
         g_error_free(error);
     g_free(window_group);



Summary of changes:
 gnucash/gnome-utils/gnc-main-window.cpp | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)



More information about the gnucash-changes mailing list