Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 March 20, 2008 23:05:51

Jonh W.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

RecentManager, singleton


Hi, folks.

In GtkRecentManager we have a singleton, by using _get_default() API.

My doubt is: When is the static singleton object freed? The
documentation says to not ref or unref it, and that it will be destroyed
when application terminates.

Looking through its source code (gtkrecentmanager.c), I haven't found
where it is unref'd.

Could you guys tell when it is destroyed?

Thanks,
--
Jonh Wendell
www.bani.com.br


_______________________________________________
gtk-list mailing list
gtk-list@gnome.orghttp://mail.gnome.org/mailman/listinfo/gtk-list

Offline

#2 March 21, 2008 01:25:14

Emmanuele B.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

RecentManager, singleton


On Thu, 2008-03-20 at 19:05 -0300, Jonh Wendell wrote:
> Hi, folks.
>
> In GtkRecentManager we have a singleton, by using _get_default() API.
>
> My doubt is: When is the static singleton object freed? The
> documentation says to not ref or unref it, and that it will be destroyed
> when application terminates.

yes.

> Looking through its source code (gtkrecentmanager.c), I haven't found
> where it is unref'd.

the RecentManager singleton is synchronised when the depth of the main
loop reaches 0 (which is usually when an application quits); the state
of the recent files list is, thus, always consistent.

the memory is reclaimed by the operating system, along with the rest of
the data that is a one-shot creation of the glib, pango and gtk+
libraries; if you look at the valgrind output, you'll notice it - but
it's easily filtered using the appropriate "skin": as I said, the memory
is effectively reclaimed by the OS.

if you want to personally manage the memory and lifetime of a
RecentManager instance you can create one using gtk_recent_manager_new()
and then use g_object_unref() when needed.
gtk_recent_manager_get_default() is there so that you don't need to do
the bookkeeping yourself, and so that you are guaranteed to have the
same instance throughout your application.

ciao,
Emmanuele.

--
Emmanuele Bassi,
W:http://www.emmanuelebassi.netB:http://log.emmanuelebassi.net_______________________________________________
gtk-list mailing list
gtk-list@gnome.orghttp://mail.gnome.org/mailman/listinfo/gtk-list

Offline

Board footer

Moderator control

Enjoy the 16th of December
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support