/gpump/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/gpump/trunk

« back to all changes in this revision

Viewing changes to src/GPumpApp.c

  • Committer: Gustav Hatvigsson
  • Date: 2014-04-21 20:19:41 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20140421201941-vdr964wrn5miwzm4
* added gpump_app_dispose
* trying to figure out why GPumpApp needs to be freed thee times
* trying to figure out why GPumpSettingsData is not freed as it should...w

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
  
30
30
  /* List store */
31
31
  GtkListStore * post_list_store;
 
32
 
 
33
  /* hold a reference to the settings for propper dispotiour */
 
34
  GPumpSettingsData * settings;
32
35
};
33
36
 
34
37
typedef enum {
42
45
void gpump_app_class_init (GPumpAppClass * klass);
43
46
void gpump_app_activate (GApplication * application);
44
47
void gpump_app_init (GPumpApp * self);
 
48
void gpump_app_dispose (GObject * object);
45
49
 
46
50
void _prepere_window (GPumpApp * self);
47
51
void _prepere_gear_menu (GPumpApp * self);
67
71
 
68
72
void gpump_app_init (GPumpApp * self) {
69
73
  g_print ("init\n");
 
74
  
70
75
  self->priv = GPUMP_APP_GET_PRIVATE (self);
71
76
  
 
77
  /* We have to keep an instance of GPumpSettigsData alive
 
78
   * It is later freed in *_dispose ()
 
79
   * 
 
80
   * Keep in mind that when ever an instance of GPumpSettingsData is
 
81
   * gotten it _will_ run g_object_ref () on it, meaning that it has to be
 
82
   * unrefed.
 
83
   *
 
84
   * When the GPumpApp is disposed of the last reference should be freed.
 
85
   */
 
86
  self->priv->settings = gpump_settings_data_get_default ();
72
87
}
73
88
 
74
89
void gpump_app_class_init (GPumpAppClass * klass) {
75
90
  g_print("GPumpApp class init.\n");
76
91
  
77
 
  // GObject * object_class = G_OBJECT_CLASS (klass);
 
92
  g_type_class_add_private (klass, sizeof(GPumpAppPrivate));
 
93
 
78
94
  GApplicationClass * application_class = G_APPLICATION_CLASS (klass);
79
95
  
80
96
  application_class->activate = gpump_app_activate;
81
97
  
82
 
  g_type_class_add_private (klass, sizeof(GPumpAppPrivate));
 
98
  GObjectClass * object_class = G_OBJECT_CLASS (application_class);
 
99
  object_class->dispose = gpump_app_dispose;
83
100
  
84
101
  g_print ("GPumpApp class init done.\n");
85
102
}
86
103
 
 
104
void gpump_app_dispose (GObject * object) {
 
105
  g_print ("Disponsing of Application...\n");
 
106
  
 
107
  GPumpApp * self = GPUMP_APP (object);
 
108
  
 
109
  /* Dispose of the widgets... */
 
110
  
 
111
  /* Dispose of the GPumpSettingsData object */
 
112
  g_object_unref (self->priv->settings);
 
113
  
 
114
  if (self->priv->settings) {
 
115
    g_print ("there was a dangling reference to GPumpSettingsData somewhare,"
 
116
             "pleace check that all \"*_get_default_instance ()\" calles have"
 
117
             "an g_object_unref () at the end of the scope!\n");
 
118
  }
 
119
  
 
120
  G_OBJECT_CLASS (gpump_app_parent_class)->dispose (object);
 
121
}
87
122
 
88
123
void gpump_app_activate (GApplication * application) {
89
124
  g_print ("GPumpApp activate.\n");
105
140
  _prepere_refresh_button (GPUMP_APP (application));
106
141
  
107
142
  /* Init the settings object */
108
 
  GPumpSettingsData * settings = gpump_settings_data_get_default ();
109
143
  
110
144
  /* Show it! */
111
145
  gtk_widget_show_all (GTK_WIDGET(GPUMP_APP(application)->priv->window));
112
146
  
113
 
  g_object_unref (G_OBJECT(settings));
114
147
  
115
148
  g_print ("done GPumpApp activate.\n");
116
149
}