On Tue, 2005-02-08 at 02:30 +0000, John Levon wrote:
> On Tue, Feb 08, 2005 at 01:41:55AM +0100, Andreas Vox wrote:
> 
> > Why do I think LyX is multithreaded? Well, not strictly, but the method
> > sync_events() can cause similar effects. What I haven't figured out yet 
> 
> One of the perils of event-based programming is that you suddenly find
> yourself dealing with race conditions :)
> 
> > is the exact sequence which could cause this crash, but the following
> > micro-patch repairs this bug for me.
> 
> I wouldn't be really happy with this patch without knowing exactly what
> the problem is...

        // FIXME! Should check that the dialog IS an inset dialog.
-       dialog->show(data);
        open_insets_[name] = inset;
+       dialog->show(data);

That seems rather clear to me. As I understand (Angus would know) this
open_insets_ table keeps track of which insets have their dialog open,
so it doesn't try to open the same dialogue a second time.

Before the patch, the first opening process starts before the dialog is
registered, and as it takes a little time (especially the first time,
when the code has to be loaded into memory), the second click manages to
start a second opening process *for the same inset* -- a race condition.
(This is precisely what I remember seeing happening on the screen.) The
patch registers the dialogue *before* starting to open it, preventing
this scenario.

BTW the name "open_insets" is a bit misleading if, as it seems, it
includes "insets_with_dialogs_open".

> john

- Martin

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to