[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
gdk_input_add() again: a bug in gdk?
- From: Tobias Peters <t-peters HRZ2 uni-oldenburg de>
- To: gtk-app-devel-list redhat com
- Subject: gdk_input_add() again: a bug in gdk?
- Date: Thu, 5 Aug 1999 23:21:07 +0200 (CEST)
Hello again,
my previous problem remains, now I wrote a little c program that
demonstrates the problem.
I want to know when a file descriptor is readable and when it is writable.
So I use gdk_input_add() and register two GdkInputFunction-s, one for
handling the read condition and the other one for the write condition.
My Problem is that the function for handling the read condition is
sometimes called with condition GDK_INPUT_WRITE. In my previous mail I was
wrong: This does not happen if I do not register the file descriptor for
writability. Gdk somehow mixes the two gdk_input_add() calls.
Could you please tell me if this is a bug in gdk or if this behaviour is
as it is by intention.
- - - - begin of demonstration program - - - - -
#include <gtk/gtk.h>
#include <assert.h>
const int fd = 2; /* File descriptor that is always writable. */
int read_tag = -1, write_tag = -1;
/* Handler functions of type GdkInputFunction: */
void reading_possible (gpointer, gint, GdkInputCondition);
void writing_possible (gpointer, gint, GdkInputCondition);
/* Functions calling gdk_input_add() and gdk_input_remove(): */
void register_reading (void)
{
printf ("register_reading() called.\n");
read_tag = gdk_input_add (fd, GDK_INPUT_READ, &reading_possible, NULL);
}
void register_writing (void)
{
printf ("register_writing() called.\n");
write_tag = gdk_input_add (fd, GDK_INPUT_WRITE, &writing_possible, NULL);
}
void deregister_reading (void)
{
printf ("deregister_reading() called.\n");
gdk_input_remove (read_tag);
read_tag = -1;
}
void deregister_writing (void)
{
printf ("deregister_writing() called.\n");
gdk_input_remove (write_tag);
write_tag = -1;
}
/* Handler functions implementation: */
void reading_possible (gpointer p, gint fd, GdkInputCondition cond)
{
printf ("reading_possible() called with condition %d\n", (int) cond);
assert ((cond & GDK_INPUT_READ) != 0);
gtk_main_quit();
}
void writing_possible (gpointer p, gint fd, GdkInputCondition cond)
{
printf ("writing_possible() called with condition %d\n", (int) cond);
assert ((cond & GDK_INPUT_WRITE) != 0);
deregister_writing();
}
int main (int argc, char **argv)
{
gtk_init (&argc, &argv);
register_reading();
register_writing();
gtk_main();
deregister_reading();
return 0;
}
- - - - end of demonstration program - - - - -
I get the following output:
register_reading() called.
register_writing() called.
writing_possible() called with condition 2
deregister_writing() called.
reading_possible() called with condition 2
gdk_input_bug: gdk_input_bug.c:40: reading_possible: Assertion `(cond &
GDK_INPUT_READ) != 0' failed.
Aborted
Please note that reading_possible is called with cond=2, which is
GDK_INPUT_WRITE. It should not have been called at all since (1) there is
no data to read and (2) I even do not want to be notified about
writeability any more, as deregister_writing() has been called already
which in turn called gdk_input_remove(write_tag).
Thank you for reading, do you have any comments?
Tobias
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]