]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/LyXView.cpp
* src/frontends/qt4/QListings.cpp:
[lyx.git] / src / frontends / LyXView.cpp
index 89d49dcd4d315de6bd20c72d24ae0f855b7de976..8086b69f656686133afd04fc0c81e0716d405b71 100644 (file)
 #include "Gui.h"
 
 #include "Buffer.h"
+//FIXME Bug 3701
+//#include "BufferList.h"
 #include "BufferParams.h"
 #include "BufferView.h"
 #include "bufferview_funcs.h"
-#include "LCursor.h"
+#include "Cursor.h"
 #include "debug.h"
 #include "ErrorList.h"
 #include "FuncRequest.h"
 #include "gettext.h"
 #include "Intl.h"
-#include "lyx_cb.h"
+#include "callback.h"
 #include "LyXFunc.h"
 #include "LyXRC.h"
-#include "LyXText.h"
+#include "Text.h"
 #include "MenuBackend.h"
 #include "Paragraph.h"
 
@@ -129,7 +131,8 @@ void LyXView::setBuffer(Buffer * b)
        if (work_area_->bufferView().buffer())
                disconnectBuffer();
 
-       if (!b)
+       //FIXME Bug 3701
+       if (!b) // && theBufferList().empty()
                getDialogs().hideBufferDependent();
 
        work_area_->bufferView().setBuffer(b);
@@ -163,10 +166,12 @@ bool LyXView::loadLyXFile(FileName const & filename, bool tolastfiles)
        busy(true);
 
        BOOST_ASSERT(work_area_);
-       if (work_area_->bufferView().buffer())
+       bool const hadBuffer = work_area_->bufferView().buffer();
+       if (hadBuffer)
                disconnectBuffer();
 
-       bool loaded = work_area_->bufferView().loadLyXFile(filename, tolastfiles);
+       bool const loaded =
+               work_area_->bufferView().loadLyXFile(filename, tolastfiles);
 
        updateToc();
        updateMenubar();
@@ -177,7 +182,9 @@ bool LyXView::loadLyXFile(FileName const & filename, bool tolastfiles)
        if (loaded) {
                connectBuffer(*work_area_->bufferView().buffer());
                showErrorList("Parse");
-       }
+       } else if (hadBuffer)
+               //Need to reconnect the buffer if the load failed
+               connectBuffer(*work_area_->bufferView().buffer());
        updateStatusBar();
        busy(false);
        work_area_->redraw();
@@ -196,7 +203,7 @@ void LyXView::connectBuffer(Buffer & buf)
                        boost::bind(&WorkArea::redraw, work_area_));
 
        bufferStructureChangedConnection_ =
-               buf.structureChanged.connect(
+               buf.getMasterBuffer()->structureChanged.connect(
                        boost::bind(&LyXView::updateToc, this));
 
        errorsConnection_ =
@@ -290,7 +297,7 @@ void LyXView::showDialogWithData(string const & name, string const & data)
 
 
 void LyXView::showInsetDialog(string const & name, string const & data,
-               InsetBase * inset)
+               Inset * inset)
 {
        getDialogs().show(name, data, inset);
 }
@@ -333,7 +340,7 @@ void LyXView::updateToolbars()
        bool const review =
                lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).enabled() &&
                lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).onoff(true);
-               
+
        toolbars_->update(math, table, review);
        // update redaonly status of open dialogs. This could also be in
        // updateMenubar(), but since updateToolbars() and updateMenubar()
@@ -394,7 +401,7 @@ void LyXView::updateLayoutChoice()
 
        // Update the layout display
        if (toolbars_->updateLayoutList(buffer()->params().textclass)) {
-               current_layout = buffer()->params().getLyXTextClass().defaultLayoutName();
+               current_layout = buffer()->params().getTextClass().defaultLayoutName();
        }
 
        BOOST_ASSERT(work_area_);
@@ -442,7 +449,7 @@ void LyXView::dispatch(FuncRequest const & cmd)
 }
 
 
-Buffer const * const LyXView::updateInset(InsetBase const * inset) const
+Buffer const * const LyXView::updateInset(Inset const * inset) const
 {
        Buffer const * buffer_ptr = 0;
        if (inset) {