GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sat Aug 30, 2014 6:14 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: GdkDisplayManager assertions
PostPosted: Mon Apr 15, 2013 4:36 am 
Offline
Familiar Face

Joined: Thu Nov 01, 2012 5:48 am
Posts: 30
Hi , I built a gtk sample in which I created a simple top level window and a child button . I am managing its creation , display and destroy in a separate thread .
When I first time launched the application then it works file . But when I exit the thread and launched it again , the application crashed with the below assertions in gtk_init .

(exeAPP:104): GLib-GObject-WARNING **: cannot register existing type `GdkDisplayManager'

(exeAPP:104): GLib-CRITICAL **: g_once_init_leave: assertion `result != 0' failed

(exeAPP:104): GLib-GObject-CRITICAL **: g_type_register_static: assertion `parent_type > 0' failed

(exeAPP:104): GLib-CRITICAL **: g_once_init_leave: assertion `result != 0' failed

(exeAPP:104): GLib-GObject-CRITICAL **: g_object_new: assertion `G_TYPE_IS_OBJECT (object_type)' failed


Could any one please provide me the help .


Regards
hkishn


Top
 Profile  
 
 Post subject: Re: GdkDisplayManager assertions
PostPosted: Mon Apr 15, 2013 5:56 am 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 745
Location: UK
Hi,

GTK+/GDK can not cope with API calls to it from different threads without proper care being taken. If you can avoid calls to GTK/GDK from different threads all the better.

_________________
E.


Top
 Profile  
 
 Post subject: Re: GdkDisplayManager assertions
PostPosted: Mon Apr 15, 2013 6:32 am 
Offline
Familiar Face

Joined: Thu Nov 01, 2012 5:48 am
Posts: 30
Thanks for the replay .

But we I cannot avoid thread usage .

Even it is working fine in first time . After thread exit , it is not working .
Is there any issue with thread exit so that it is crashing in gtk_init .


Regards
hkishn


Top
 Profile  
 
 Post subject: Re: GdkDisplayManager assertions
PostPosted: Mon Apr 15, 2013 6:37 pm 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 745
Location: UK
Have you read the documentation on thread usage in GTK+. See https://developer.gnome.org/gdk3/stable/gdk3-Threads.html

You will need to initialise the global GDK lock and calls to GTK/GDK in the non main threads must lock the global GDK lock although this method is now deprecated since GTK+ 3.6. This method would also have the effect of slowing down the system as a global mutex lock has to be maintain, with constant locking and unlocking. It would be better to have worker threads that communicate to the main thread that does all the calls to GTK/GDK, with the worker threads telling the main thread what needs to be done.

Note that calling GTK/GDK functions from different threads is not portable to Microsoft Windows.

gtk_init() should only be called once on application initialisation.

_________________
E.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group