Re: A queer problem



"Nikhil Bhavadas K." <nijbhav@md5.vsnl.net.in> wrote:
>
>	I had written an application having a progress bar in a dialog window.
>As an illustration, I am sending a small GTK program that has a button, clicking
>on which a dialog window with a progress bar appears. 
>	My first problem might be very common. How to force response on a
>dialog window? A quick look of FAQ did not reveal much details.

  Use gdk_flush() to force the widget to draw. Or try the function
gtk_widget_draw() on the dialog box. One of these should work.

> In my
>program, every time you click on the button separate dialog windows appear.
>My requirement is that when a dialog window appears, a person should be able to
>click only on the dialog window and any click on the parent window should not
>have any affect. Let me say that many GTK+/GNOME programs show this behavior.
>My version of gnome-games(1.0.51) have some games like Same Gnome that show
>dialog windows every time you click on the close button on the top right
>window. Some programs like gEdit crashed when I clicked on the close button
>twice.
>	A queer problem seen when compiling and running this program is that
>when you create many dialog windows by clicking on the button, and killed some
>of them, error messages like
>> Gtk-CRITICAL **: file gtkprogress.c: line 554 (gtk_progress_set_value):
>> assertion `GTK_IS_PROGRESS (progress)' failed.
>
>> Gtk-WARNING **: invalid cast from `(unknown)' to `GtkProgress'
>
>appears. Now when trying to create another dialog window by clicking once more,
>the program segfaults with the message
>> Gtk-WARNING **: invalid cast from `GtkDialog' to `GtkProgress'
>The behavior is unpredictable. Sometimes this occurs when we just move the mouse
>over the button.   	
>	What is this `cast' problem? Where have I gone wrong? Or is this some
>bug? Sorry if the mail has become too long. I just wanted to state my
>problem clealry.
>	Thanks!
>Regards,
>   Nikhil.

  I think each time you press the button, you are creating the dialog widget
with gtk_*_new() and showing it. So, next time you press the button again, The
dialog widget is again created and I will bet, it has overwritten the previous
pointer to the dialog widget. Now, say you have two dialogs opened sharing 
the same pointer memory. Obviously, when you have destroyed the latest dilog
box and when your application refers to the objects in the dialog box 
(say the progress bar), it will be referencing to the already destroyed objects.
That is why gtk is warning you about the invalid pointers.

  You can avoid this by showing the dialog box as modal dialog box. This
will prevent the user to access the application (except the dialog box).

regards
-Naba

__________________________________________________
Do You Yahoo!?
Yahoo! Mail  Free email you can access from anywhere!
http://mail.yahoo.com/




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