Commit 693f1d71 authored by Sebastian Ramacher's avatar Sebastian Ramacher

GObject references should be unref'd in dispose

Signed-off-by: Sebastian Ramacher's avatarSebastian Ramacher <sebastian+dev@ramacher.at>
parent 207f57b3
......@@ -60,6 +60,7 @@ typedef struct zathura_page_widget_private_s {
static gboolean zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo);
static void zathura_page_widget_finalize(GObject* object);
static void zathura_page_widget_dispose(GObject* object);
static void zathura_page_widget_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec);
static void zathura_page_widget_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec);
static void zathura_page_widget_size_allocate(GtkWidget* widget, GdkRectangle* allocation);
......@@ -114,6 +115,7 @@ zathura_page_widget_class_init(ZathuraPageClass* class)
widget_class->popup_menu = cb_zathura_page_widget_popup_menu;
GObjectClass* object_class = G_OBJECT_CLASS(class);
object_class->dispose = zathura_page_widget_dispose;
object_class->finalize = zathura_page_widget_finalize;
object_class->set_property = zathura_page_widget_set_property;
object_class->get_property = zathura_page_widget_get_property;
......@@ -218,6 +220,17 @@ zathura_page_widget_new(zathura_t* zathura, zathura_page_t* page)
return GTK_WIDGET(ret);
}
static void
zathura_page_widget_dispose(GObject* object)
{
ZathuraPage* widget = ZATHURA_PAGE(object);
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
g_clear_object(&priv->render_request);
G_OBJECT_CLASS(zathura_page_widget_parent_class)->dispose(object);
}
static void
zathura_page_widget_finalize(GObject* object)
{
......@@ -228,10 +241,6 @@ zathura_page_widget_finalize(GObject* object)
cairo_surface_destroy(priv->surface);
}
if (priv->render_request != NULL) {
g_object_unref(priv->render_request);
}
if (priv->search.list != NULL) {
girara_list_free(priv->search.list);
}
......
......@@ -21,6 +21,7 @@ G_DEFINE_TYPE(ZathuraRenderRequest, zathura_render_request, G_TYPE_OBJECT)
/* private methods for ZathuraRenderer */
static void renderer_finalize(GObject* object);
/* private methods for ZathuraRenderRequest */
static void render_request_dispose(GObject* object);
static void render_request_finalize(GObject* object);
static void render_job(void* data, void* user_data);
......@@ -203,6 +204,7 @@ zathura_render_request_class_init(ZathuraRenderRequestClass* class)
/* overwrite methods */
GObjectClass* object_class = G_OBJECT_CLASS(class);
object_class->dispose = render_request_dispose;
object_class->finalize = render_request_finalize;
request_signals[REQUEST_COMPLETED] = g_signal_new("completed",
......@@ -270,24 +272,34 @@ zathura_render_request_new(ZathuraRenderer* renderer, zathura_page_t* page)
}
static void
render_request_finalize(GObject* object)
render_request_dispose(GObject* object)
{
ZathuraRenderRequest* request = ZATHURA_RENDER_REQUEST(object);
request_private_t* priv = REQUEST_GET_PRIVATE(request);
if (priv->renderer) {
if (priv->renderer != NULL) {
/* unregister the request */
renderer_unregister_request(priv->renderer, request);
/* release our private reference to the renderer */
g_object_unref(priv->renderer);
g_clear_object(&priv->renderer);
}
G_OBJECT_CLASS(zathura_render_request_parent_class)->dispose(object);
}
static void
render_request_finalize(GObject* object)
{
ZathuraRenderRequest* request = ZATHURA_RENDER_REQUEST(object);
request_private_t* priv = REQUEST_GET_PRIVATE(request);
if (girara_list_size(priv->active_jobs) != 0) {
girara_error("This should not happen!");
}
girara_list_free(priv->active_jobs);
mutex_free(&priv->jobs_mutex);
GOBJECT_CLASS(render_request_parent_class)->finalize(object);
G_OBJECT_CLASS(zathura_render_request_parent_class)->finalize(object);
}
/* renderer methods */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment