Hi Taha Ali,
On Sun, 9 Sep 2007 you sent me a message saying :
>
>Thanks for the reply.
You should reply always to the list, not to me personally. I'm far from
an expert and even if I was I might miss things. Reply to the list to
get the benefit of a far wider knowledge base.
> Actually, the API that I am using wants me to
>register a callback function that would report to me the progress of
>the function that I have called in my thread. This callback is not able
>to see the Glib::Dispatcher variable from my application class.
Is it actually not possible to make it see it? Surely you could use
libsigc++ to pass a method of your application instance as the
call-back?
> The
>pseudo code is like this:
>
>class Application
>{
> ...................
> -------------------
> Glib::Dispatcher report_message_signal;
> static some_callback_func(arg1, arg2, arg3);
> ...................
> -------------------
> ...................
> -------------------
>}
>
>main()
>{
>----------
>----------
>Register_API_Callback_func(some_callback_func, .......);
>----------
>---------
>}
>
>
>on_button_clicked()
>{
>Glib::Thread::create(thread_function ......);
>}
>
>thread_function()
>{
>---------
>---------
>API_Function(); //Takes around 10 seconds
>----------
>----------
>
>}
>
>some_callback_func(Message)
>{
>
>//This function is internally called by the API giving info about the
>progress that API_Function
>//is making and it is from here that I have to set text, in order to
>report guiding messages, in the
>//label. I know that this is not right but what other options do you
>think I have.
>
>}
>
>Thanks and Regards,
>Taha
>
>On 9/8/07, Robert Pearce <[EMAIL PROTECTED]> wrote:
> On Sat, 8 Sep 2007, Taha Ali <[EMAIL PROTECTED]> wrote :
> >I am facing problem in calling a gui function from a thread.
>
> Don't do that.
>
> >I am trying to set_text these messages in a label but after
> >first normal execution of this thread, the gui hangs on the next
> call.
>
> So don't do that.
>
> >When I dont try to set_text any
> >thing from this callback function, it works just fine showing me
> the
> >display (std::cout) on the screen.
>
> So don't do that!
>
> >Need help.
>
> OK, incase you haven't already guessed, the answer is DON'T call GTK
> from a thread. It doesn't like it at all.
>
> The function in your thread should use Glib::Dispatcher (or
> g_idle_add)
> to ask the main (gui) thread to set the text.
> --
> Rob Pearce http://www.bdt-home.demon.co.uk
>
> The contents of this | Windows NT crashed.
> message are purely | I am the Blue Screen of Death.
> my opinion. Don't | No one hears your screams.
> believe a word. |
> _______________________________________________
> gtkmm-list mailing list
> [email protected]
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
--
Rob Pearce http://www.bdt-home.demon.co.uk
The contents of this | Windows NT crashed.
message are purely | I am the Blue Screen of Death.
my opinion. Don't | No one hears your screams.
believe a word. |
_______________________________________________
gtkmm-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtkmm-list