Re: Gio & memory management



On Tue, 14 Oct 2008 18:03:05 +0200
nico <nico yojik eu> wrote:

Thank you Nicola,

And you're also g_freeing a GFileInfo, which is a GObject. Try
to use g_object_unref() instead.

Ciao
  
When I use g_object_unref()  instead of  g_free(file_info); I've got  
this error :

(process:30949): GLib-GObject-CRITICAL **: g_object_unref: assertion 
`G_IS_OBJECT (object)' failed

Because you are unrefing it in the wrong place. Now you have:

while ((file_info = g_file_enumerator_next_file()) != NULL) {
    ...
}
g_object_unref(file_info);

Here file_info is surely NULL and you're lacking tons of refs.
You must do instead:

while ((file_info = g_file_enumerator_next_file()) != NULL) {
    ...
    g_object_unref(file_info);
}

Ciao
-- 
Nicola



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]