diff --git a/objects/drawable.c b/objects/drawable.c index 0db78ca6a..ea09798da 100644 --- a/objects/drawable.c +++ b/objects/drawable.c @@ -193,6 +193,12 @@ static int luaA_drawable_refresh(lua_State *L) { drawable_t *drawable = luaA_checkudata(L, 1, &drawable_class); + + /* GC race condition where the drawin is gone, but the drawable as a + * refresh in a delayed call */ + if (!drawable->refresh_callback) + return 0; + drawable->refreshed = true; (*drawable->refresh_callback)(drawable->refresh_data); @@ -240,6 +246,12 @@ drawable_class_setup(lua_State *L) NULL); } +void drawable_invalidate(drawable_t *d) +{ + d->refresh_callback = NULL; + d->refresh_data = NULL; +} + /* @DOC_cobject_COMMON@ */ // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/objects/drawable.h b/objects/drawable.h index 86bd0b696..289a6cece 100644 --- a/objects/drawable.h +++ b/objects/drawable.h @@ -50,6 +50,7 @@ typedef struct drawable_t drawable_t; drawable_t *drawable_allocator(lua_State *, drawable_refresh_callback *, void *); void drawable_set_geometry(lua_State *, int, area_t); void drawable_class_setup(lua_State *); +void drawable_invalidate(drawable_t *d); #endif // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/objects/drawin.c b/objects/drawin.c index 3bbd93179..5c2fb699d 100644 --- a/objects/drawin.c +++ b/objects/drawin.c @@ -187,6 +187,7 @@ drawin_wipe(drawin_t *w) w->window = XCB_NONE; } /* No unref needed because we are being garbage collected */ + drawable_invalidate(w->drawable); w->drawable = NULL; }