Re: GTK Widget assertion problem



On Thu, Jun 10, 2010 at 01:31:33PM +0200, Michael T. wrote:
In case anyone's interested I solved the problem with a little hack.
I create the progress bar this way:

progBar = gtk_progress_bar_new();  
gtk_box_pack_start (GTK_BOX (vboxGr), GTK_PROGRESS_BAR(progBar), FALSE, FALSE, 0);
gtk_widget_show (progBar));
progressBarHack(progBar);

the function progressBarHack() looks like this:

void progressBarHack(GtkWidget* bar)
{
    progBar = bar; 
}

progBar is a global variable. I get an assertion error when I try to work with it outside the function 
where the bar was created.
When I use my hack, which does nothing except some pointer work, everything works fine.
I don't know why the hack was needed because I've worked with several widgets with no problems at all. But 
this thing works.

Hello, this all looks like utter voodoo.  You have probably a trivial
bug somewhere (elsewhere) in your code, maybe some
extern/static/initialization confusion?  Or you overwrite the stack and
calling progressBarHack() causes a change of the layout so that you
overwrite a less sensitive place now?   Anyway, it is recommended fix to
avoid global variables, they are evil, and externs are double-evil.  But
perhaps if you show a minimal *complete* example that exhibits the error
some will be able to help you.  Or, likely, you will find the root cause
while trying to extract the bad behaviour into a simple example...

Yeti




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