A Geany user reported a crash in some specific scenario: https://github.com/geany/geany/issues/1385
I'm not certain why that scenario happens, but it's valid: if the acessible object is destroyed, but the associated widget isn't for some reason, it can lead to receiving a signal on a detsroyed accessible instance, thus to a crash.
Attached are 2 patches:
g_signal_handlers_disconnect_by_data(), which disconnects all handlers matching the instance and the user data. This is great because it's simple and the logic of disconnecting any signal having a pointer to the destroyed object makes sense (although we oly have 1 currently); but g_signal_handlers_disconnect_by_data() is new in GLib 2.32 (March 24th, 2012). So you'll have to see whether this is an acceptable minimal dependency.
It appears that g_signal_handlers_disconnect_by_data is just an easy-to-use macro over g_signal_handlers_disconnect_matched which is marked GLIB_AVAILABLE_IN_ALL so a call to g_signal_handlers_disconnect_matched could be used to avoid any dependency problems.
Yes, but I'm afraid that it wasn't valid to only match by data before 2.32, but I'm not sure. Though I don't have a system old enough to have 2.32 to check… maybe checking the code, I'll see if I can check that.
I seem wrong, the code doesn't seem to have changed in that regard, so
using
disconnect_matches()seems like a good idea.I still couldn't test though.
FTR, the upstream report that lead to the implementation of
disconnect_by_data(): https://bugzilla.gnome.org/show_bug.cgi?id=668269I still couldn't find something old enough not to have GLib 2.32 (Ubuntu 12.04 is too recent, which is the oldest thing I could still find a download for), but as said reading GLib's code suggests it should work with earlier versions too. Attached patch uses
g_signal_handlers_disconnect_matched()and work fine for me.Last edit: Colomban Wendling 2017-02-07
Comment updated, apparently it was empty the first time.
Committed as [54cc0c].
On my oldest system, Ubuntu 10.4, which no longer builds Scintilla for GTK+ 2.18 for other reasons, that line is OK.
Related
Commit: [54cc0c]
Oh boy. I'm sorry, but I introduced another crasher bug under GTK < 3.3.6 (GTK2 or GTK3) with this patch, see https://github.com/geany/geany/issues/1410
Attached patch fixes it, and contains detailed explanation (so does the commit on Geany: https://github.com/geany/geany/commit/1421a3f9c59a41074636a26cca6b431c3af40226)
Sorry :(
Committed as [809112].
Related
Commit: [809112]