[geany/geany] 624c11: Do not change notebook tab in document-close callback

Jiří Techet git-noreply at xxxxx
Thu Jul 26 00:02:24 UTC 2012


Branch:      refs/heads/document-messages
Author:      Jiří Techet <techet at gmail.com>
Committer:   Jiří Techet <techet at gmail.com>
Date:        Sat, 24 Dec 2011 11:31:22
Commit:      624c11cec07c7eec88fc9212c55352fb383835d3
             https://github.com/geany/geany/commit/624c11cec07c7eec88fc9212c55352fb383835d3

Log Message:
-----------
Do not change notebook tab in document-close callback

This can lead to unpredictable behavior of document_get_current()


Modified Paths:
--------------
    src/notebook.c

Modified: src/notebook.c
39 files changed, 19 insertions(+), 20 deletions(-)
===================================================================
@@ -112,26 +112,6 @@ static void on_document_close(GObject *obj, GeanyDocument *doc)
 {
 	if (! main_status.quitting)
 	{
-		/* switch to appropriate page when closing current doc */
-		if (document_get_current() == doc)
-		{
-			gint page;
-
-			page = gtk_notebook_get_current_page(GTK_NOTEBOOK(main_widgets.notebook)) +
-				(file_prefs.tab_order_ltr ? 1 : -1);
-
-			if (file_prefs.tab_close_switch_to_mru)
-			{
-				GeanyDocument *last_doc;
-
-				last_doc = g_queue_peek_nth(mru_docs, 1);
-				if (DOC_VALID(last_doc))
-					page = document_get_notebook_page(last_doc);
-			}
-
-			gtk_notebook_set_current_page(GTK_NOTEBOOK(main_widgets.notebook), page);
-		}
-
 		g_queue_remove(mru_docs, doc);
 		/* this prevents the pop up window from showing when there's a single
 		 * document */
@@ -752,6 +732,25 @@ gint notebook_new_tab(GeanyDocument *this)
 /* Always use this instead of gtk_notebook_remove_page(). */
 void notebook_remove_page(gint page_num)
 {
+	gint page = gtk_notebook_get_current_page(GTK_NOTEBOOK(main_widgets.notebook));
+
+	if (page_num == page)
+	{
+		page += (file_prefs.tab_order_ltr) ? 1 : -1;
+
+		if (file_prefs.tab_close_switch_to_mru)
+		{
+			GeanyDocument *last_doc;
+
+			last_doc = g_queue_peek_nth(mru_docs, 0);
+			if (DOC_VALID(last_doc))
+				page = document_get_notebook_page(last_doc);
+		}
+
+		gtk_notebook_set_current_page(GTK_NOTEBOOK(main_widgets.notebook), page);
+	}
+
+	/* now remove the page (so we don't temporarily switch to the previous page) */
 	gtk_notebook_remove_page(GTK_NOTEBOOK(main_widgets.notebook), page_num);
 
 	tab_count_changed();


@@ Diff output truncated at 100000 characters. @@


--------------
This E-Mail was brought to you by github_commit_mail.py (Source: TBD).



More information about the Commits mailing list