Re: Why doesn't my label show up in the window



On Sat, 25 Aug 2012 11:35:27 -0600
Frank Cox wrote:

The more I look at this the less I understand it.

What I have discovered is that the subwindow appears as expected prior to
starting task x, but the label is missing (the subwindow is blank) until it
updates at the start of task y.

Playing around with this a bit more just now, I have discovered that the
behaviour of my demonstration program that I posted last night is inconsistent.

I'm pretty sure that it didn't show the label at all last night when I wrote
it, but today when I ran it again I get the label in the window the first time
I click the OK button but when I click it again (after the subwindow goes away)
all I get it a blank subwindow that's missing the label.

So what changes between the first click and the second click that causes the
label to work and then not work?

And now that I've spent two minutes writing this email, I went back and ran the
program again and now I'm back to the original behaviour:  No label on the
first click or the second or subsequent click.

I just noticed that the OK button in the main window also disappears when I
click on it, and it doesn't re-appear until the sleep() times out, as well.

Reading about "while (g_main_context_iteration (NULL, FALSE));" seems to
indicate that it does in fact do exactly what I thought it did, and what I want
it to do. 

You stated "You call sleep() in mainloop causes it block,".  Could you go into
more detail about this, since I think that's where my understanding of this is
going off the track.  Is it blocked prior to completing the "while
(g_main_context_iteration (NULL, FALSE));"?  If so, why?  If the "while
(g_main_context_iteration (NULL, FALSE));" did in fact complete before the sleep
() command, then why is the label not being consistently drawn?  And for that
matter, why is the window itself showing up?

Adding another "while (g_main_context_iteration (NULL, FALSE));" immediately
after "gtk_container_add(GTK_CONTAINER(subwindow),label);" didn't make any
difference in the behaviour; the label still didn't show up as it should.

If "while (g_main_context_iteration (NULL, FALSE));" does what I think it does,
then this should work.  Since it doesn't, it's obvious that it doesn't actually
do what I think it does.

And since it does occasionally work on the first click, but not always and less
than half of the time, why?  What changes between runs?  The only thing that I
can think of is some kind of a timing issue, but why would that matter in a
(supposedly) self-contained program that's not looking for external input other
than a click?

-- 
MELVILLE THEATRE ~ Real D 3D Digital Cinema ~ www.melvilletheatre.com
www.creekfm.com - FIFTY THOUSAND WATTS of POW WOW POWER!



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