-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix intern.Box being freed before finalizers are called
Related issue: #130
- Loading branch information
1 parent
feb2025
commit a1bfe15
Showing
5 changed files
with
67 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include "intern.h" | ||
|
||
const gchar *gotk4_object_type_name(gpointer obj) { | ||
return G_OBJECT_TYPE_NAME(obj); | ||
}; | ||
|
||
gboolean gotk4_intern_remove_toggle_ref(gpointer obj) { | ||
// First, remove the toggle reference. This forces the object to be freed, | ||
// calling any necessary finalizers. | ||
g_object_remove_toggle_ref(G_OBJECT(obj), (GToggleNotify)goToggleNotify, | ||
NULL); | ||
|
||
// Only once the object is freed, we can remove it from the weak reference | ||
// registry, since now the finalizers will not be called anymore. | ||
goFinishRemovingToggleRef(obj); | ||
|
||
return FALSE; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include <glib-object.h> | ||
|
||
extern void goToggleNotify(gpointer, GObject *, gboolean); | ||
extern void goFinishRemovingToggleRef(gpointer); | ||
const gchar *gotk4_object_type_name(gpointer obj); | ||
gboolean gotk4_intern_remove_toggle_ref(gpointer obj); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters