]> git.lyx.org Git - lyx.git/commitdiff
Fix the following sort of crash, reported on the list. This is also
authorRichard Heck <rgheck@comcast.net>
Tue, 2 Nov 2010 15:33:52 +0000 (15:33 +0000)
committerRichard Heck <rgheck@comcast.net>
Tue, 2 Nov 2010 15:33:52 +0000 (15:33 +0000)
#6884.

1. Open LyX. File>New. Document>Outline, to make sure the TOC is open.
That isn't necessary, but it helps you to see what is happening.
2. Create a section heading (alt-P, 2) with an x in it.
3. Split the screen.
4. File>New. You should now still see the TOC for the OLD buffer.
5. Click in the top screen. You now see an empty TOC (the one for the
empty buffer).
6. Click in the empty buffer. Other TOC!
7. Back to the "x" buffer. Empty TOC. Type something. Boom!

The problem is that teh setCurrentWorkArea() call eventually gets us to
structureChanged(), which accesses documentBufferView(). But that
doesn't get reset until later, and hence everything is out of sync.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35999 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiView.cpp

index eb689ce56b5d5291f78e22bd3d218c2766f397e9..65a1d3a6f65173bd2c84177a260488fb16682034 100644 (file)
@@ -1216,17 +1216,23 @@ void GuiView::setCurrentWorkArea(GuiWorkArea * wa)
 
        theGuiApp()->setCurrentView(this);
        d.current_work_area_ = wa;
+       
+       // We need to reset this now, because it will need to be
+       // right if the tabWorkArea gets reset in the for loop. We
+       // will change it back if we aren't in that case.
+       GuiWorkArea * const old_cmwa = d.current_main_work_area_;
+       d.current_main_work_area_ = wa;
+
        for (int i = 0; i != d.splitter_->count(); ++i) {
                if (d.tabWorkArea(i)->setCurrentWorkArea(wa)) {
-                       //if (d.current_main_work_area_)
-                       //      d.current_main_work_area_->setFrameStyle(QFrame::NoFrame);
-                       d.current_main_work_area_ = wa;
-                       //d.current_main_work_area_->setFrameStyle(QFrame::Box | QFrame::Plain);
-                       //d.current_main_work_area_->setLineWidth(2);
-                       LYXERR(Debug::DEBUG, "Current wa: " << currentWorkArea() << ", Current main wa: " << currentMainWorkArea());
+                       LYXERR(Debug::DEBUG, "Current wa: " << currentWorkArea() 
+                               << ", Current main wa: " << currentMainWorkArea());
                        return;
                }
        }
+       
+       d.current_main_work_area_ = old_cmwa;
+       
        LYXERR(Debug::DEBUG, "This is not a tabbed wa");
        on_currentWorkAreaChanged(wa);
        BufferView & bv = wa->bufferView();