From dd2a6c36b2a8960d05b81d46fb6b1cc063222497 Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Fri, 4 May 2018 21:29:13 +0200 Subject: Don't crash on multiple calls to GObject.Value.__del__. See !66 After chaining up accessing anything on the instance will crash like accessing self.g_type in this case. Guard against that by exposing if the wrapped boxed is still there. Ideally we shouldn't invalidate the object in __del__, but various things depend on it atm. For another time.. --- gi/pygi-boxed.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'gi/pygi-boxed.c') diff --git a/gi/pygi-boxed.c b/gi/pygi-boxed.c index d4823263..6a48159f 100644 --- a/gi/pygi-boxed.c +++ b/gi/pygi-boxed.c @@ -193,6 +193,12 @@ boxed_get_free_on_dealloc(PyGIBoxed *self, void *closure) return pygi_gboolean_to_py( ((PyGBoxed *)self)->free_on_dealloc ); } +static PyObject * +boxed_get_is_valid (PyGIBoxed *self, void *closure) +{ + return pygi_gboolean_to_py (pyg_boxed_get_ptr (self) != NULL); +} + /** * pygi_boxed_copy_in_place: * @@ -219,6 +225,7 @@ pygi_boxed_copy_in_place (PyGIBoxed *self) static PyGetSetDef pygi_boxed_getsets[] = { { "_free_on_dealloc", (getter)boxed_get_free_on_dealloc, (setter)0 }, + { "_is_valid", (getter)boxed_get_is_valid, (setter)0 }, { NULL, 0, 0 } }; -- cgit v1.2.1