Re: problem refreshing cairo surface
Kalle Vahlman <[email protected]>
| Newsgroups | gmane.comp.lib.cairo |
|---|---|
| Message-ID | <CAOPOHQMqTYooLDKSScT+yC=imBOY+dqnGU_qbtk+RwBDXQENiQ@mail.gmail.com> |
2011/11/13 Zoltán Vörös <[email protected]>: > On 11/13/2011 06:47 AM, Kalle Vahlman wrote: >> >> I don't immediately spot the error, though there is a possible race >> condition between configure_event (which is an asynchronous event by nature) >> and trying to use the context it creates in on_load(). That should probably >> give an error though. > > I think your suspicion was correct. This works, although I am not sure > whether this is how it should be done: > > self.DA = Preview() > self.widget('box_preview').pack_start(self.DA.da, True, True, 0) > while Gtk.events_pending(): > Gtk.main_iteration() > self.draw_note(self.DA.da, self.DA.surface) What I meant was that you should not create the context in configure_event, but only when you draw (and destroy it when finished). Contexes are lightweight enough to make any drawing operation drown the (potentially frequent) creation performance-wise, so there is no reason to keep it around. And many not to, for example this problem you are having, also the fact that if the context goes into an error state (wrong parameters etc), you need to re-create it or you won't be able to draw anything anymore. > What is a bit odd, however, is that if I move the Gtk.main_iteration() to > the __init__ or the configuration function, then it doesn't work. > Anyway, I would still be interested in the "proper" way of handling this. I suppose what happens in those stages is that the event queue is not flushed yet so there are no events pending to process, but that's just a guess... -- Kalle Vahlman, [email protected] Powered by http://movial.com Interesting stuff at http://sandbox.movial.com -- cairo mailing list [email protected] http://lists.cairographics.org/mailman/listinfo/cairo