@eht16 commented on this pull request.


In src/callbacks.c:

> @@ -335,6 +335,21 @@ void on_toolbutton_reload_clicked(GtkAction *action, gpointer user_data)
 	document_reload_prompt(doc, NULL);
 }
 
+/* reload all files */
+void on_toolbutton_reload_all_clicked(GtkAction *action, gpointer user_data)
+{
+	guint i;
+	gint cur_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(main_widgets.notebook));
+	
+	foreach_document(i)
+	{
+		if (! (documents[i]->file_name == NULL))

After having a closer look and some testing, the logic and dialog response handling is a litte wrong:
combining the conditions to show the dialog and handling its response in a single if statement is error prone if not impossible. The current implementation doesn't work properly.

As a suggestion, I rewrote the condition handling as follows:

diff --git a/src/callbacks.c b/src/callbacks.c
index acbd8737..487c48ac 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -340,27 +340,35 @@ void on_reload_all(GtkAction *action, gpointer user_data)
 {
 	guint i;
 	gint cur_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(main_widgets.notebook));
-	
+
 	if (!file_prefs.keep_edit_history_on_reload)
 	{
+		GeanyDocument *doc;
 		foreach_document(i)
 		{
-			if (!(documents[i]->changed || (document_can_undo(documents[i]) ||
-			document_can_redo(documents[i]))) && dialogs_show_question_full(NULL,
-			_("_Reload"), GTK_STOCK_CANCEL, _("Any unsaved changes will be lost."),
-			_("Are you sure you want to reload all files?")))
-				break;
-			else
-				return;
+			doc = documents[i];
+			if (doc->changed || document_can_undo(doc) || document_can_redo(doc))
+			{
+				if (dialogs_show_question_full(NULL, _("_Reload"), GTK_STOCK_CANCEL,
+					_("Any unsaved changes will be lost."),
+					_("Are you sure you want to reload all files?")))
+				{
+					break; // break the loop and continue with reloading below
+				}
+				else
+				{
+					return; // cancel reloading
+				}
+			}
 		}
 	}
-	
+
 	foreach_document(i)
 	{
 		if (! (documents[i]->file_name == NULL))
 			document_reload_force(documents[i], documents[i]->encoding);
 	}
-	
+
 	gtk_notebook_set_current_page(GTK_NOTEBOOK(main_widgets.notebook), cur_page);
 } 

This is a bit more verbose but IMO easier to read and understand.

Btw, stripping trailing spaces is always a good idea (at least for Geany code :D).


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.