[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: trying to launch a dialog from outside the main gui thread by emiting a signal to the thread.
- From: James Scott Jr <skoona verizon net>
- To: Kevin Lambert <kl lapis com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: trying to launch a dialog from outside the main gui thread by emiting a signal to the thread.
- Date: Tue, 06 Mar 2007 19:23:21 -0500
On Tue, 2007-03-06 at 12:45 -0500, Kevin Lambert wrote:
> I am currently working on a multithreaded application which has a primary
> GUI that is always running and I need to be able to get that GUI to show a
> popup to put images in. The problem I am having is how do I tell the GUI to
> show the popup from outside of its own code?
>
> As a test I connected the "keys-changed" signal for the GUI's window so that
> if that signal gets emitted it launches my dialog. I then added an external
> function which emits that signal which, when called, crashes the application
> with:
>
> Xlib: unexpected async reply (sequence 0x995)!
> Xlib: sequence lost (0x108c7 > 0xfd) in reply type 0x8!
> Xlib: sequence lost (0x10000 > 0xfd) in reply type 0x0!
>
> I do know that only the primary GUI thread is allowed to handle X calls
> which is why I had the signal handler launching my dialog. I have tried
> googling for information but Im not finding much.
>
> Thanks,
>
> Kevin
>
Kevin,
There several ways to communication between threads, and there are some
design options available which depending on what your doing may not
require you to create a formal thread. First communications between
threads:
GASyncQueue
This glib allows api allows you to allocate a structure or pointer,
fill it with the logical message, and post it asynchronously to the
foreground GUI thread for formatting into a displayed message. This
approch assumes async messages are ok. If its not1. , create a second
queue, and after posting to display_que have the background thread read
from the done_que - it will sleep until the foreground displays the
message and post the original (or any) pointer to the Done_que.
How does the foreground pickup the message. Start a g_timeout_add()
function to peak at the queue every x seconds, then read que if peak
counts is more than 0. Be sure to return true to keep the
g_timeout_add() routine running, otherwise false will make it stop.
Alternates to formal threads.
g_idle_add()
g_io_watch()
g_io_timeout_add()
Hopefully you have the application devhelp and can look up these api's.
James,
>
> _______________________________________________
> gtk-app-devel-list mailing list
> gtk-app-devel-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
James Scott, Jr.
Registered Linux User #270764
FC6 on Dual AMD-MP 2400+
Author: {gfhcm, gkrellfah2,gapcmon,giw}.sourceforge.net
http://mysite.verizon.net/skoona/index.html
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]