[planner] Fix memory leak in PlannerView subclasses by freeing priv in finalize
- From: Maurice van der Pot <mvdpot src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [planner] Fix memory leak in PlannerView subclasses by freeing priv in finalize
- Date: Tue, 24 Nov 2009 20:04:34 +0000 (UTC)
commit 6f9c485cbbc4ed134f9a6a5b9e56187797cbdb79
Author: Maurice van der Pot <griffon26 kfk4ever com>
Date: Thu Nov 5 22:10:47 2009 +0100
Fix memory leak in PlannerView subclasses by freeing priv in finalize
src/planner-gantt-view.c | 23 +++++++++++++++++++++++
src/planner-resource-view.c | 21 +++++++++++++++++++++
src/planner-task-view.c | 22 ++++++++++++++++++++++
src/planner-usage-view.c | 28 +++++++++++++++++++++++++---
4 files changed, 91 insertions(+), 3 deletions(-)
---
diff --git a/src/planner-gantt-view.c b/src/planner-gantt-view.c
index d7df3b8..e9a763d 100644
--- a/src/planner-gantt-view.c
+++ b/src/planner-gantt-view.c
@@ -52,6 +52,7 @@ struct _PlannerGanttViewPriv {
gulong expose_id;
};
+static void gantt_view_finalize (GObject *object);
static GtkWidget * gantt_view_create_widget (PlannerGanttView *view);
static void gantt_view_insert_task_cb (GtkAction *action,
gpointer data);
@@ -130,6 +131,9 @@ static void gantt_view_print (PlannerView *vi
static gint gantt_view_print_get_n_pages (PlannerView *view);
static void gantt_view_print_cleanup (PlannerView *view);
+
+static PlannerViewClass *parent_class = NULL;
+
static const GtkActionEntry entries[] = {
{ "InsertTask", "planner-stock-insert-task", N_("_Insert Task"),
"<control>i", N_("Insert a new task"),
@@ -228,10 +232,16 @@ gantt_view_chart_scroll_event (GtkWidget * gki, GdkEventScroll * event, PlannerG
static void
planner_gantt_view_class_init (PlannerGanttViewClass *klass)
{
+ GObjectClass *o_class;
PlannerViewClass *view_class;
+ parent_class = g_type_class_peek_parent (klass);
+
+ o_class = (GObjectClass *) klass;
view_class = PLANNER_VIEW_CLASS (klass);
+ o_class->finalize = gantt_view_finalize;
+
view_class->setup = gantt_view_setup;
view_class->get_label = gantt_view_get_label;
view_class->get_menu_label = gantt_view_get_menu_label;
@@ -253,6 +263,19 @@ planner_gantt_view_init (PlannerGanttView *view)
}
static void
+gantt_view_finalize (GObject *object)
+{
+ PlannerGanttView *view;
+
+ view = PLANNER_GANTT_VIEW (object);
+ g_free (view->priv);
+
+ if (G_OBJECT_CLASS (parent_class)->finalize) {
+ (*G_OBJECT_CLASS (parent_class)->finalize) (object);
+ }
+}
+
+static void
gantt_view_activate (PlannerView *view)
{
PlannerGanttViewPriv *priv;
diff --git a/src/planner-resource-view.c b/src/planner-resource-view.c
index 6fe88d8..3a9bd59 100644
--- a/src/planner-resource-view.c
+++ b/src/planner-resource-view.c
@@ -67,6 +67,7 @@ enum {
NUM_OF_COLS
};
+static void resource_view_finalize (GObject *object);
static void resource_view_insert_resource_cb (GtkAction *action,
gpointer data);
static void resource_view_insert_resources_cb (GtkAction *action,
@@ -226,6 +227,7 @@ static const gchar * resource_view_get_type_string (MrpResourceType
static void resource_view_save_columns (PlannerResourceView *view);
static void resource_view_load_columns (PlannerResourceView *view);
+static PlannerViewClass *parent_class = NULL;
static const GtkActionEntry entries[] = {
{ "InsertResource", "planner-stock-insert-resource", N_("_Insert Resource"),
@@ -319,10 +321,16 @@ G_DEFINE_TYPE (PlannerResourceView, planner_resource_view, PLANNER_TYPE_VIEW);
static void
planner_resource_view_class_init (PlannerResourceViewClass *klass)
{
+ GObjectClass *o_class;
PlannerViewClass *view_class;
+ parent_class = g_type_class_peek_parent (klass);
+
+ o_class = (GObjectClass *) klass;
view_class = PLANNER_VIEW_CLASS (klass);
+ o_class->finalize = resource_view_finalize;
+
view_class->setup = resource_view_setup;
view_class->get_label = resource_view_get_label;
view_class->get_menu_label = resource_view_get_menu_label;
@@ -344,6 +352,19 @@ planner_resource_view_init (PlannerResourceView *view)
}
static void
+resource_view_finalize (GObject *object)
+{
+ PlannerResourceView *view;
+
+ view = PLANNER_RESOURCE_VIEW (object);
+ g_free (view->priv);
+
+ if (G_OBJECT_CLASS (parent_class)->finalize) {
+ (*G_OBJECT_CLASS (parent_class)->finalize) (object);
+ }
+}
+
+static void
resource_view_activate (PlannerView *view)
{
PlannerResourceViewPriv *priv;
diff --git a/src/planner-task-view.c b/src/planner-task-view.c
index cdcfcd4..e6fd45b 100644
--- a/src/planner-task-view.c
+++ b/src/planner-task-view.c
@@ -48,6 +48,7 @@ struct _PlannerTaskViewPriv {
guint merged_id;
};
+static void task_view_finalize (GObject *object);
static void task_view_activate (PlannerView *view);
static void task_view_deactivate (PlannerView *view);
static void task_view_setup (PlannerView *view,
@@ -112,6 +113,8 @@ static void task_view_save_columns (PlannerView *vi
static void task_view_load_columns (PlannerView *view);
+static PlannerViewClass *parent_class = NULL;
+
static const GtkActionEntry entries[] = {
{ "InsertTask", "planner-stock-insert-task", N_("_Insert Task"),
"<Control>i", N_("Insert a new task"),
@@ -173,10 +176,16 @@ G_DEFINE_TYPE (PlannerTaskView, planner_task_view, PLANNER_TYPE_VIEW);
static void
planner_task_view_class_init (PlannerTaskViewClass *klass)
{
+ GObjectClass *o_class;
PlannerViewClass *view_class;
+ parent_class = g_type_class_peek_parent (klass);
+
+ o_class = (GObjectClass *) klass;
view_class = PLANNER_VIEW_CLASS (klass);
+ o_class->finalize = task_view_finalize;
+
view_class->setup = task_view_setup;
view_class->get_label = task_view_get_label;
view_class->get_menu_label = task_view_get_menu_label;
@@ -198,6 +207,19 @@ planner_task_view_init (PlannerTaskView *view)
}
static void
+task_view_finalize (GObject *object)
+{
+ PlannerTaskView *view;
+
+ view = PLANNER_TASK_VIEW (object);
+ g_free (view->priv);
+
+ if (G_OBJECT_CLASS (parent_class)->finalize) {
+ (*G_OBJECT_CLASS (parent_class)->finalize) (object);
+ }
+}
+
+static void
task_view_activate (PlannerView *view)
{
PlannerTaskViewPriv *priv;
diff --git a/src/planner-usage-view.c b/src/planner-usage-view.c
index c4b55bd..e4645d0 100644
--- a/src/planner-usage-view.c
+++ b/src/planner-usage-view.c
@@ -47,6 +47,7 @@ struct _PlannerUsageViewPriv {
gulong expose_id;
};
+static void usage_view_finalize (GObject *object);
static void usage_view_zoom_out_cb (GtkAction *action,
gpointer data);
static void usage_view_zoom_in_cb (GtkAction *action,
@@ -102,6 +103,8 @@ static void usage_view_save_columns (PlannerUsageView *view)
static void usage_view_load_columns (PlannerUsageView *view);
+static PlannerViewClass *parent_class = NULL;
+
static const GtkActionEntry entries[] = {
{ "ZoomOut", GTK_STOCK_ZOOM_OUT, N_("Zoom out"),
NULL, N_("Zoom out"),
@@ -150,10 +153,16 @@ usage_view_chart_scroll_event (GtkWidget * gki, GdkEventScroll * event, PlannerV
static void
planner_usage_view_class_init (PlannerUsageViewClass *klass)
{
+ GObjectClass *o_class;
PlannerViewClass *view_class;
+ parent_class = g_type_class_peek_parent (klass);
+
+ o_class = (GObjectClass *) klass;
view_class = PLANNER_VIEW_CLASS (klass);
+ o_class->finalize = usage_view_finalize;
+
view_class->setup = usage_view_setup;
view_class->get_label = usage_view_get_label;
view_class->get_menu_label = usage_view_get_menu_label;
@@ -175,6 +184,20 @@ planner_usage_view_init (PlannerUsageView *view)
}
static void
+usage_view_finalize (GObject *object)
+{
+ PlannerUsageView *view;
+
+ view = PLANNER_USAGE_VIEW (object);
+
+ g_free (view->priv);
+
+ if (G_OBJECT_CLASS (parent_class)->finalize) {
+ (*G_OBJECT_CLASS (parent_class)->finalize) (object);
+ }
+}
+
+static void
usage_view_activate (PlannerView *view)
{
PlannerUsageViewPriv *priv;
@@ -212,11 +235,10 @@ usage_view_deactivate (PlannerView *view)
static void
usage_view_setup (PlannerView *view, PlannerWindow *main_window)
{
- PlannerUsageViewPriv *priv;
+ PlannerUsageViewPriv *priv;
- priv = g_new0 (PlannerUsageViewPriv, 1);
+ priv = PLANNER_USAGE_VIEW (view)->priv;
- PLANNER_USAGE_VIEW (view)->priv = priv;
priv->ui_manager = planner_window_get_ui_manager(main_window);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]