[gnet-dev] Another glib(windows) bug



--On Tuesday, May 15, 2001 4:39 PM -0700 wroberts1 home com wrote:

And at the same time, it would be best to ask about why gtk event messages
are being passed to your gnet_MainCallBack().  I have it working ok
for me with a PeekMessage().

It turns out to be a problem in glib. I've submited the following patch to Tor. I've also commited some error checking code [below] to make things work with a buggy glib dll to GNet's CVS.
There should (hopefully) not be any more problems with using GNet with GTK.
Andy

GLIB PATCH:
Original:
static gboolean
g_io_win32_check (GSource *source)
{
 GIOWin32Watch *watch = (GIOWin32Watch *)source;
 GIOWin32Channel *channel = (GIOWin32Channel *)watch->channel;

 if (channel->debug)
   g_print ("g_io_win32_check: for thread %#x:\n"
"\twatch->pollfd.events:%#x, watch->pollfd.revents:%#x, channel->revents:%#x\n",
	     channel->thread_id,
	     watch->pollfd.events, watch->pollfd.revents, channel->revents);

 if (channel->type != G_IO_WIN32_WINDOWS_MESSAGES)
   watch->pollfd.revents = (watch->pollfd.events & channel->revents);
etc...

FIXED:

static gboolean
g_io_win32_check (GSource *source)
{
 MSG msg;
 GIOWin32Watch *watch = (GIOWin32Watch *)source;
 GIOWin32Channel *channel = (GIOWin32Channel *)watch->channel;

 if (channel->debug)
   g_print ("g_io_win32_check: for thread %#x:\n"
"\twatch->pollfd.events:%#x, watch->pollfd.revents:%#x, channel->revents:%#x\n",
	     channel->thread_id,
	     watch->pollfd.events, watch->pollfd.revents, channel->revents);

 if (channel->type != G_IO_WIN32_WINDOWS_MESSAGES)
{
 watch->pollfd.revents = (watch->pollfd.events & channel->revents);
}
else
{
 return (PeekMessage (&msg, channel->hwnd, 0, 0, PM_NOREMOVE));
}
etc...

WORKAROUND:
Original,
int
gnet_MainCallBack(GIOChannel *iochannel, GIOCondition condition, void *nodata)
{
 MSG msg;

 gpointer data;
 GInetAddrAsyncState *IAstate;
 GInetAddrReverseAsyncState *IARstate;
 GTcpSocketAsyncState *TCPNEWstate;
 SocketWatchAsyncState *WatchState;

 /*Take the msg off the message queue */
 GetMessage (&msg, NULL, 0, 0);
etc...

Fixed:
int
gnet_MainCallBack(GIOChannel *iochannel, GIOCondition condition, void *nodata)
{
 MSG msg;

 gpointer data;
 GInetAddrAsyncState *IAstate;
 GInetAddrReverseAsyncState *IARstate;
 GTcpSocketAsyncState *TCPNEWstate;
 SocketWatchAsyncState *WatchState;

	int i;

 /*Take the msg off the message queue */
 i = PeekMessage (&msg, gnet_hWnd, 0, 0, PM_REMOVE);
	if (!i)
return 1; /* you have a buggy version of glib that is calling this func when it shouldn't*/

etc...





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