[geany/geany-plugins] afcb2a: debugger: Disconnect signals on the Scintilla widget more cautiously

Colomban Wendling git-noreply at xxxxx
Sun Apr 13 00:09:13 UTC 2014


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Sun, 13 Apr 2014 00:09:13 UTC
Commit:      afcb2a137c8d20a26d69166ed6a4326990c3526c
             https://github.com/geany/geany-plugins/commit/afcb2a137c8d20a26d69166ed6a4326990c3526c

Log Message:
-----------
debugger: Disconnect signals on the Scintilla widget more cautiously

No signal handler on a Scintilla widget should ever be left on a plugin
unload, otherwise unloaded code from the callback could get called.

So, although the code was probably good enough in most normal
situations, be a little more cautious about removing existing handlers
in any cases.


Modified Paths:
--------------
    debugger/src/callbacks.c

Modified: debugger/src/callbacks.c
15 files changed, 12 insertions(+), 3 deletions(-)
===================================================================
@@ -157,13 +157,17 @@ void on_document_open(GObject *obj, GeanyDocument *doc, gpointer user_data)
 /*
  * 	Handles mouse leave event to check if a calltip is still present and hides it if yes 
  */
-static gint leave_signal;
+static gulong leave_signal = 0;
 static gboolean on_mouse_leave(GtkWidget *widget, GdkEvent *event, gpointer user_data)
 {
 	ScintillaObject *so = (ScintillaObject*)widget;
-	if (scintilla_send_message (so, SCI_CALLTIPACTIVE, 0, 0))
+	if (leave_signal > 0)
 	{
 		g_signal_handler_disconnect(G_OBJECT(widget), leave_signal);
+		leave_signal = 0;
+	}
+	if (scintilla_send_message (so, SCI_CALLTIPACTIVE, 0, 0))
+	{
 		scintilla_send_message (so, SCI_CALLTIPCANCEL, 0, 0);
 	}
 	return FALSE;
@@ -234,12 +238,17 @@ gboolean on_editor_notify(
 		}
 		case SCN_DWELLEND:
 		{
+			if (leave_signal > 0)
+			{
+				g_signal_handler_disconnect(G_OBJECT(editor->sci), leave_signal);
+				leave_signal = 0;
+			}
+
 			if (DBS_STOPPED != debug_get_state ())
 				break;
 
 			if (scintilla_send_message (editor->sci, SCI_CALLTIPACTIVE, 0, 0))
 			{
-				g_signal_handler_disconnect(G_OBJECT(editor->sci), leave_signal);
 				scintilla_send_message (editor->sci, SCI_CALLTIPCANCEL, 0, 0);
 			}
 			break;



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Plugins-Commits mailing list