Abdelrazak Younes wrote:
You may be right indeed. But it seems that updateLayoutChoice does a
setLayout. Is it necessary to do another one?

Maybe not. Actually it may well be that the BufferView::Pimpl::firstLayout() method can go altogether. updateLayoutChoice() will set the layout that match the current cursor position anyway. An the cursor is always valid right?

The attached patch should work, will test.

Yes it works, I will propose a full patch that gets rid of firstLayout() once I have committed my pending patch.

Here is the patch, objection?

Abdel.

Log:

* BufferView: delete firstLayout()

* LyXView: save two setLayout() calls that are done in updateLayoutChoice() anyway.
Index: BufferView.C
===================================================================
--- BufferView.C        (revision 14826)
+++ BufferView.C        (working copy)
@@ -93,12 +93,6 @@
 }
 
 
-string BufferView::firstLayout()
-{
-       return pimpl_->firstLayout();
-}
-
-
 bool BufferView::loadLyXFile(string const & fn, bool tl)
 {
        return pimpl_->loadLyXFile(fn, tl);
Index: BufferView.h
===================================================================
--- BufferView.h        (revision 14831)
+++ BufferView.h        (working copy)
@@ -98,8 +98,6 @@
        void setBuffer(Buffer * b);
        /// return the buffer being viewed
        Buffer * buffer() const;
-       /// return the first layout of the Buffer.
-       std::string firstLayout();
 
        /// return the owning main view
        LyXView * owner() const;
Index: BufferView_pimpl.C
===================================================================
--- BufferView_pimpl.C  (revision 14831)
+++ BufferView_pimpl.C  (working copy)
@@ -306,29 +306,7 @@
                lyx::graphics::Previews::get().generateBufferPreviews(*buffer_);
 }
 
-string BufferView::Pimpl::firstLayout()
-{
-       string firstlayout;
 
-       // This is done after the layout combox has been populated
-       if (buffer_) {
-               size_t i = cursor_.depth() - 1;
-               // we know we'll eventually find a paragraph
-               while (true) {
-                       CursorSlice const & slice = cursor_[i];
-                       if (!slice.inset().inMathed()) {
-                               LyXLayout_ptr const layout = 
slice.paragraph().layout();
-                               firstlayout = layout->name();
-                               break;
-                       }
-                       BOOST_ASSERT(i>0);
-                       --i;
-               }
-       }
-       return firstlayout;
-}
-
-
 void BufferView::Pimpl::resizeCurrentBuffer()
 {
        lyxerr[Debug::DEBUG] << BOOST_CURRENT_FUNCTION << endl;
Index: BufferView_pimpl.h
===================================================================
--- BufferView_pimpl.h  (revision 14826)
+++ BufferView_pimpl.h  (working copy)
@@ -46,8 +46,6 @@
        Pimpl(BufferView & bv, LyXView * owner);
        ///
        void setBuffer(Buffer * buf);
-       /// return the first layout of the Buffer.
-       std::string firstLayout();
        ///
        void resizeCurrentBuffer();
        //
Index: frontends/LyXView.C
===================================================================
--- frontends/LyXView.C (revision 14830)
+++ frontends/LyXView.C (working copy)
@@ -139,19 +139,17 @@
 
        work_area_->bufferView().setBuffer(b);
 
-       updateLayoutChoice();
-
        if (work_area_->bufferView().buffer()) {
                // Buffer-dependent dialogs should be updated or
                // hidden. This should go here because some dialogs (eg ToC)
                // require bv_->text.
                getDialogs().updateBufferDependent(true);
                connectBuffer(*work_area_->bufferView().buffer());
-               setLayout(work_area_->bufferView().firstLayout());
        }
 
        updateMenubar();
        updateToolbars();
+       updateLayoutChoice();
        updateWindowTitle();
        redrawWorkArea();
 }
@@ -170,7 +168,6 @@
        updateWindowTitle();
        if (loaded) {
                connectBuffer(*work_area_->bufferView().buffer());
-               setLayout(work_area_->bufferView().firstLayout());
                showErrorList("Parse");
        }
        redrawWorkArea();

Reply via email to