Re: gdk_threads_leave is possible to cause segmentation fault?



Thanks!
So i could replate enter and leave to g_iddle_add, right?

gdk_threads_enter();
 g_printf("UpdateConfigNow\n");
 iUpdateConfigNow();
gdk_threads_leave();

To

g_idle_add((GCallback)iUpdateConfigNow, NULL);

Why i get this error?

Main.c:1824: undefined reference to `g_iddle_add'

Thanks


Às 11:49 de 28/03/2017, Gabriele Greco escreveu:

In gdk manual i see thath gdk_threads_enter and leave has been
deprecated and alll gdk and gtk+ calls should be made from main thread.
How we do this? Someone have any example?

You have to call g_idle_add (that is thread safe) every time you need to update one or more widgets from an 
external thread.

Let's think about a common situation, for instance you are encoding a video file and you want to update a 
progress bar:

[from encoding thread]
struct progress {
    char label[50];
    float value;
};

myprg = malloc(sizeof(struct progress));
myprg->value = 75.0;
strncpy(myprg->label, "Second pass", sizeof(myprg->label));
g_idle_add((GCallback)progress_update, myprg);

gboolean progress_update(struct progress *p);
{
     gtk_progress_bar_set_text(p->label);
     gtk_progress_bar_set_fraction(p->value);
     free(p);
     return FALSE; // it means that you want to run this only once
}

--
Bye,
 Gabry


[https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif]<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient>
      Sem vírus. 
www.avast.com<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient>


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