GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Tue Sep 23, 2014 12:20 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: GTK application crash
PostPosted: Sun Jul 07, 2013 4:59 pm 
Offline
Familiar Face

Joined: Wed Jan 23, 2013 5:18 pm
Posts: 26
Hi,

I started using GTK+ 2.15.5 with DirectFB 1.6.3 in the begging for my powerPc target board.
I have created LCD driver and mapped the derive to /dev/fb0,
The lcd driver will read the fb0 in every 500ms time interval and update the display.

With GTK+ 2.15.5 and DirectFB 1.6.3 the target board was working fine,
than i used glade tool to create the GUI front for my application.
My application has a 15 different window(created with glade) which scrolls in sequence with time intervals.
all went well and the out put came very well as expected.

but when I tested it for long time(2 hours) the application is getting killed with or without error messages.

Error as below
Quote:
(gtkdisplay:1020): GLib-GObject-WARNING **: invalid uninstantiatable type `(null)' in cast to `GdkWindow'
(gtkdisplay:1020): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed
(gtkdisplay:1020): GLib-GObject-CRITICAL **: g_object_ref: assertion `G_IS_OBJECT (object)' failed
(gtkdisplay:1020): GLib-GObject-WARNING **: invalid uninstantiatable type `(null)' in cast to `GdkWindow'
(gtkdisplay:1020): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed
(gtkdisplay:1020): GLib-GObject-CRITICAL **: g_object_ref: assertion `G_IS_OBJECT (object)' failed
(gtkdisplay:1020): GLib-GObject-WARNING **: invalid uninstantiatable type `(null)' in cast to `GdkWindow'
(gtkdisplay:1020): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed
(gtkdisplay:1020): GLib-GObject-CRITICAL **: g_object_ref: assertion `G_IS_OBJECT (object)' failed


I am using pthread to switch between windows with some time interval
my code as below for 2 windows switching:
Code:
int main( int argc, char **argv )
{
   GError *error = NULL;
   int thread_err = 0;
   /* init threads */
   g_thread_init (NULL);
   gdk_threads_init ();
   gdk_threads_enter ();

       //Initialise GTK+
   gtk_init( &argc, &argv );

   //Create new GtkBuilder object
   builder = gtk_builder_new();

   //Load UI from file. If error occurs, report it and quit application.
   if( ! gtk_builder_add_from_file( builder, "/jem/registers.glade", &error ) )
      {
         g_warning( "%s", error->message );
         g_free( error );
         return( 1 );
      }
   //Connect the main screens to the callback functions
        // Get call back for window1 and window2
   g_signal_connect (G_OBJECT (window1), "show",
                     G_CALLBACK (show_callback), NULL);

   g_signal_connect (G_OBJECT (window2), "show",
                     G_CALLBACK (show_callback), NULL);
   
   //Initialize the thread
   thread_err = pthread_create(&tid, NULL, &display_update, NULL);
   if (thread_err != 0)
      printf("Display: Can't create thread :[%s]\n", strerror(thread_err));
   else
      printf("Display: Thread created successfully.\n");

   //Connect signals
   gtk_builder_connect_signals( builder, NULL );

   //Destroy builder, since we don't need it anymore
   g_object_unref( G_OBJECT( builder ) );

   //Start main loop
   gtk_main();
   gdk_threads_leave ();
   return( 0 );
}

//Thread for window switching
void* display_update(void *arg)
{
   pthread_t id = pthread_self();
   //give some time for other process
   sleep(2);
        //Hide all window first
   g_signal_emit_by_name(G_OBJECT(window1), "hide");
   g_signal_emit_by_name(G_OBJECT(window2), "hide");
   
        //work loop
   while(1)
      {
                        //show the window1 on the display
         g_signal_emit_by_name(G_OBJECT(window1), "show");
         g_signal_emit_by_name(G_OBJECT(window2), "hide");
         sleep(1);
                        //Show the window2 on the display
         g_signal_emit_by_name(G_OBJECT(window1), "hide");
         g_signal_emit_by_name(G_OBJECT(window2), "show");
         sleep(1);
      }
}

//call back for every window switch
//display text in labels which is in window1 or window2
static void show_callback (GtkWidget *window,gpointer data)
{
   if (window1 is active)
   {
      gtk_label_set_text(window1_label, "some text");
   }
   else if if (window2 is active)
   {
      gtk_label_set_text(window2_label, "some text");
   }
}
   


When i started discussing about this issue Errol suggested me to move to higher version of GTK, That was a good Idea, Now I started building the GTK 2.24.19 which I am expecting my application crash problem will get solved.

But this time i have a another problem with building GTK 2.24.19, I have posted the new problem with subject no: command not found.

Please guide me to come out of my build problems.

_________________
Thanks,
Arief.
None of us is stronger than all of us


Top
 Profile  
 
 Post subject: Re: GTK application crash
PostPosted: Tue Jul 16, 2013 6:56 am 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 747
Location: UK
Calling GTK/GDK API from multiple threads is only supported with the X11 back end only, so I would expect this to fail. This example does not need threads and would work better by using time outs instead. Look up the functions g_time_out_add().

_________________
E.


Top
 Profile  
 
 Post subject: Re: GTK application crash
PostPosted: Thu Jul 25, 2013 8:28 am 
Offline
Familiar Face

Joined: Wed Jan 23, 2013 5:18 pm
Posts: 26
Hi Errol,

Thanks a lot.

I have moved to GTK 2.24.19 and using g_time_out_add() as you suggested, perfect suggestion.

Now my code is working perfectly with your help.

Note: E I would like to contribute to this forum in terms of technical things, (I am not good in document) , can you guide me to start?.

_________________
Thanks,
Arief.
None of us is stronger than all of us


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

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 4 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