Fix racy glib assertion failure

Use g_signal_connect_object() to establish automatic and race-free signal
disconnection instead of the hand-crafted mechanism.
This commit is contained in:
Thomas Martitz 2014-06-06 22:11:11 +02:00
parent 35a212dffc
commit ab42662309

View File

@ -3207,19 +3207,14 @@ static gboolean on_sci_key(GtkWidget *widget, GdkEventKey *event, gpointer data)
}
}
/* g_signal_handlers_disconnect_by_data is a macro that cannot be used as GCallback */
static void on_bar_unrealize(GtkWidget *bar, ScintillaObject *sci)
{
g_signal_handlers_disconnect_by_func(sci, on_sci_key, bar);
}
/* Sets up a signal handler to intercept some keys during the lifetime of the GtkInfoBar */
static void enable_key_intercept(GeanyDocument *doc, GtkWidget *bar)
{
g_signal_connect(doc->editor->sci, "key-press-event", G_CALLBACK(on_sci_key), bar);
/* make the signal disconnect automatically */
g_signal_connect(bar, "unrealize", G_CALLBACK(on_bar_unrealize), doc->editor->sci);
g_signal_connect_object(doc->editor->sci, "key-press-event", G_CALLBACK(on_sci_key), bar, 0);
}
static void monitor_reload_file(GeanyDocument *doc)
{
gchar *base_name = g_path_get_basename(doc->file_name);