Op 23-5-2012 2:28, Pavel Sanda schreef:
Vincent van Ravesteijn wrote:
commit 0a33374c0d8125e27666fe513506fb6069df453c
Author: Vincent van Ravesteijn<v...@lyx.org>
Date:   Wed May 23 01:31:43 2012 +0200

     Fix bug #8166: Crash on clicking away from empty paragraph

     We rely on the 'or' operator to prevent us from calling
     'notifyCursorLeaves' if one of the two cursors is broken. This doesn't
     work when using the '|' operator. The compiler 'optimizes' the code in
     such a way that we always call notifyCursorLeaves anyway. Using the '||'
     operator fixes this.
My memory is not particularly good device, but IIRC notifyCursorLeavesOrEnters
call should _never_ be optimized-out when using single |.

Yes, you are right. The intention was to call all functions, but the erroneous part was that the compiler may change the order of execution when using '|'.

So what makes difference between Win X Linux noted in the bug would be the order
of function calls (which is undefined and thus nonportable by definition).
On Windows it only crashed when compiling in release mode.

Currently you rewrite it as:
if old.fixIfBroken()
        if cur.fixIfBroken()
                notifyCursorLeavesOrEnters(old, cur);

Maybe cur.fixIfBroken() should be called anyway -->  (fix|fix)||notify ?

Yes I fixed it in such a way that we always call all three functions, but making sure that the order is fixed.

I didn't notice that this was a recent change by Enrico, and I changed the logic indeed without good reason. Apologies to Enrico for that. The current fix doesn't change the logic.

Vincent


Reply via email to