1

I have an important question. I am writing a medium scale program part of which displays current weather conditions in various areas of Turkey. Weather data is renewed with basically the following snippet of code which exist in a function of it's own

  g_object_set(wsrc[num]->statusImage, "file", wsrc[num]->image_path);
  set_text(wsrc[num]->text2, deg_temp);

This function is called with:

g_main_context_invoke()

from a separate thread that the one "gtk_main()" is called in. wsrc is the struct array in which weather data and the corresponding widgets displaying it are kept. Triggering the first snippet from a separate thread than the one gtk_main() runs in results in the following errors and no change

(dashboard:16664): GLib-GObject-CRITICAL **: g_object_set: assertion `G_IS_OBJECT (object)' failed

(dashboard:16664): Gtk-CRITICAL **: gtk_label_set_text: assertion `GTK_IS_LABEL (label)' failed

while I am able to access other elements in wsrc via printf but not the widgets. Does gtk unreference or destroy all references to all widgets when run? How do I keep the existing code rather than using signals to do these changes? Help is much appreciated.

whotheman
  • 117
  • 1
  • 2
  • 13
  • 1
    You should avoid using GTK+ from more than one thread, use `g_idle_add()` to schedule code for being run in the main thread. Regarding your question, it is impossible to tell what's wrong. Obviously `wsrc[num]->...` are not proper widgets, but I cannot say why --- maybe you destroyed the window they are contained in or the pointers are just wrong, etc. etc. –  Jan 23 '14 at 16:31

0 Answers0