Author: rgheck
Date: Sat Dec  3 23:42:09 2011
New Revision: 40352
URL: http://www.lyx.org/trac/changeset/40352

Log:
Attempt to fix #7673 in a more "interesting" way than in branch (where
we will be cautious, of course). The problem was that we were issuing
the Buffer::changed() signal before we did updateBuffer(), and this
caused an inconsistency. The idea here is to defer issuing this signal
until we call processUpdateFlags(). We know we need a redraw if we've
deleted a whole paragraph.

This should work properly, so long as checkDepm is called from within
the dispatch mechanism. There may, however, be other paths, and I've
noted one explicitly with a FIXME in Text2.cpp. I've tested a few
different variations, however, and I haven't seen any problems. But if
we do run into problems, we can go ahead and do the update there that we
were previously doing in checkDepm itself.

Modified:
   lyx-devel/trunk/src/BufferView.cpp
   lyx-devel/trunk/src/Cursor.cpp
   lyx-devel/trunk/src/Cursor.h
   lyx-devel/trunk/src/Text2.cpp
   lyx-devel/trunk/src/Text3.cpp

Modified: lyx-devel/trunk/src/BufferView.cpp
==============================================================================
--- lyx-devel/trunk/src/BufferView.cpp  Sat Dec  3 23:24:58 2011        (r40351)
+++ lyx-devel/trunk/src/BufferView.cpp  Sat Dec  3 23:42:09 2011        (r40352)
@@ -2410,7 +2410,7 @@
        d->cursor_ = cur;
 
        cur.forceBufferUpdate();
-       buffer_.changed(true);
+       cur.screenUpdateFlags(Update::Force);
        return true;
 }
 

Modified: lyx-devel/trunk/src/Cursor.cpp
==============================================================================
--- lyx-devel/trunk/src/Cursor.cpp      Sat Dec  3 23:24:58 2011        (r40351)
+++ lyx-devel/trunk/src/Cursor.cpp      Sat Dec  3 23:42:09 2011        (r40352)
@@ -1968,8 +1968,12 @@
 
                        updateNeeded |= bv().checkDepm(dummy, *this);
                        updateTextTargetOffset();
-                       if (updateNeeded)
+                       if (updateNeeded) {
                                forceBufferUpdate();
+                               // DEPM may have requested a screen update
+                               this->screenUpdateFlags(
+                                       this->screenUpdate() | 
dummy.screenUpdate());
+                       }
                }
                return false;
        }
@@ -1994,7 +1998,8 @@
                        ++dummy.pos();
                if (bv().checkDepm(dummy, old)) {
                        updateNeeded = true;
-                       // Make sure that cur gets back whatever happened to 
dummy (Lgb) 
+                       // Make sure that cur gets back whatever happened to 
dummy (Lgb)
+                       // This will include any screen update requested by DEPM
                        operator=(dummy);
                }
        } else {

Modified: lyx-devel/trunk/src/Cursor.h
==============================================================================
--- lyx-devel/trunk/src/Cursor.h        Sat Dec  3 23:24:58 2011        (r40351)
+++ lyx-devel/trunk/src/Cursor.h        Sat Dec  3 23:42:09 2011        (r40352)
@@ -247,6 +247,8 @@
         * Not using noScreenUpdate() should never be wrong.
         */
        void noScreenUpdate() const;
+       ///
+       Update::flags screenUpdate() const { return disp_.screenUpdate(); }
        /// fix cursor in circumstances that should never happen.
        /// \retval true if a fix occured.
        bool fixIfBroken();

Modified: lyx-devel/trunk/src/Text2.cpp
==============================================================================
--- lyx-devel/trunk/src/Text2.cpp       Sat Dec  3 23:24:58 2011        (r40351)
+++ lyx-devel/trunk/src/Text2.cpp       Sat Dec  3 23:42:09 2011        (r40352)
@@ -535,6 +535,9 @@
        bool const update_needed = !tm.contains(par);
        Cursor old = cur;
        setCursorIntern(cur, par, pos, setfont, boundary);
+       // FIXME There is a chance that we'll miss a screen update here.
+       // If so, then do DEPM and then check if cur wants an update and
+       // go ahead and do it, if so.
        return cur.bv().checkDepm(cur, old) || update_needed;
 }
 

Modified: lyx-devel/trunk/src/Text3.cpp
==============================================================================
--- lyx-devel/trunk/src/Text3.cpp       Sat Dec  3 23:24:58 2011        (r40351)
+++ lyx-devel/trunk/src/Text3.cpp       Sat Dec  3 23:42:09 2011        (r40352)
@@ -630,8 +630,12 @@
                                // provide it with two different cursors.
                                Cursor dummy = cur;
                                dummy.pos() = dummy.pit() = 0;
-                               if (cur.bv().checkDepm(dummy, cur))
+                               if (cur.bv().checkDepm(dummy, cur)) {
                                        cur.forceBufferUpdate();
+                                       // DEPM may have requested a screen 
update
+                                       cur.screenUpdateFlags(
+                                               cur.screenUpdate() | 
dummy.screenUpdate());
+                               }
                        }
                }
                break;
@@ -657,8 +661,12 @@
                                Cursor dummy = cur;
                                dummy.pos() = cur.lastpos();
                                dummy.pit() = cur.lastpit();
-                               if (cur.bv().checkDepm(dummy, cur))
+                               if (cur.bv().checkDepm(dummy, cur)) {
                                        cur.forceBufferUpdate();
+                                       // DEPM may have requested a screen 
update
+                                       cur.screenUpdateFlags(
+                                               cur.screenUpdate() | 
dummy.screenUpdate());
+                               }
                        }
                }
                break;
@@ -841,8 +849,12 @@
                                // provide it with two different cursors.
                                Cursor dummy = cur;
                                dummy.pos() = dummy.pit() = 0;
-                               if (cur.bv().checkDepm(dummy, cur))
+                               if (cur.bv().checkDepm(dummy, cur)) {
                                        cur.forceBufferUpdate();
+                                       // DEPM may have requested a screen 
update
+                                       cur.screenUpdateFlags(
+                                               cur.screenUpdate() | 
dummy.screenUpdate());
+                               }
                        }
                }
                break;
@@ -891,8 +903,12 @@
                                Cursor dummy = cur;
                                dummy.pos() = cur.lastpos();
                                dummy.pit() = cur.lastpit();
-                               if (cur.bv().checkDepm(dummy, cur))
+                               if (cur.bv().checkDepm(dummy, cur)) {
                                        cur.forceBufferUpdate();
+                                       // DEPM may have requested a screen 
update
+                                       cur.screenUpdateFlags(
+                                               cur.screenUpdate() | 
dummy.screenUpdate());
+                               }
                        }
                }
                break;

Reply via email to