]> git.lyx.org Git - features.git/commitdiff
LyXView::view() now returns boost::shared_ptr<BufferView> const &.
authorAngus Leeming <leeming@lyx.org>
Fri, 2 Aug 2002 09:21:50 +0000 (09:21 +0000)
committerAngus Leeming <leeming@lyx.org>
Fri, 2 Aug 2002 09:21:50 +0000 (09:21 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4836 a592a061-630c-0410-9148-cb99ea01b6c8

15 files changed:
src/ChangeLog
src/frontends/ChangeLog
src/frontends/LyXView.C
src/frontends/LyXView.h
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlCharacter.C
src/frontends/controllers/ControlERT.C
src/frontends/controllers/ControlParagraph.C
src/frontends/controllers/ControlSearch.C
src/frontends/controllers/ControlThesaurus.C
src/frontends/xforms/ChangeLog
src/frontends/xforms/FormTabular.C
src/frontends/xforms/XMiniBuffer.C
src/importer.C
src/lyxfunc.C

index 3ea146d3e7cfc08d284f015bab967c15bf166549..4217ea24bde2e70b3c036abfbc0860892e859f7d 100644 (file)
@@ -1,3 +1,9 @@
+2002-08-02  Angus Leeming  <leeming@lyx.org>
+
+       * importer.C (Import):
+       * lyxfunc.C (moveCursorUpdate, dispatch, view_status_message):
+       changes due to LyXView::view() now returning a boost::shared_ptr.
+
 2002-08-02  John Levon  <levon@movementarian.org>
 
        * text2.C (status): small cleanup, no logic change
index 7bad432a839002b2c1995e79d5dd927ea3144c1c..d758bedc5cca4a9a095be1d4823135b3d593d9b0 100644 (file)
@@ -1,3 +1,12 @@
+2002-08-02  Angus Leeming  <leeming@lyx.org>
+
+       * LyXView.[Ch] (view): now returns shared_ptr<BufferView> const &
+       so that anything wanting to cache the buffer view can do so safely
+       using a boost::weak_ptr.
+
+       * LyXView.h: store bufferview_ as a shared_ptr, not as a scoped_ptr.
+       Spell Bjønnes correctly.
+
 2002-08-01  John Levon  <levon@movementarian.org>
 
        * Dialogs.h:
index 65e42cf318fb466fda96476aeb5c722cfa543eb1..db4d1f2c75ba32d379622f431fa33fa4c445ed54 100644 (file)
@@ -86,9 +86,9 @@ Buffer * LyXView::buffer() const
 }
 
 
-BufferView * LyXView::view() const
+boost::shared_ptr<BufferView> const & LyXView::view() const
 {
-       return bufferview_.get();
+       return bufferview_;
 }
 
 
@@ -139,7 +139,7 @@ void LyXView::autoSave()
        lyxerr[Debug::INFO] << "Running autoSave()" << endl;
 
        if (view()->available()) {
-               ::AutoSave(view());
+               ::AutoSave(view().get());
        }
 }
 
index 24fb6c952fa658ee7b693d5dae978569843e8b23..51bebd9223d82e19a86477a13b5141a5048547f0 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright 1995-2002 the LyX Team
  * Read the file COPYING
  *
- * \author Lars Gullik Bjornes <larsbj@lyx.org>
+ * \author Lars Gullik Bjønnes <larsbj@lyx.org>
  * \author John Levon <moz@compsoc.man.ac.uk>
  */
 
@@ -21,6 +21,7 @@
 
 #include <boost/utility.hpp>
 #include <boost/scoped_ptr.hpp>
+#include <boost/shared_ptr.hpp>
 #include <boost/signals/trackable.hpp>
 #include <boost/signals/signal0.hpp>
 
@@ -70,8 +71,11 @@ public:
 
        //@{ generic accessor functions
 
-       /// return the current buffer view
-       BufferView * view() const;
+       /** return the current buffer view
+           Returned as a shared_ptr so that anything wanting to cache the
+           buffer view can do so safely using a boost::weak_ptr.
+        */
+       boost::shared_ptr<BufferView> const & view() const;
 
        /// return the LyX function handler for this view
        LyXFunc * getLyXFunc() const;
@@ -120,7 +124,7 @@ public:
 
 protected:
        /// view of a buffer. Eventually there will be several.
-       boost::scoped_ptr<BufferView> bufferview_;
+       boost::shared_ptr<BufferView> bufferview_;
 
        /// view's menubar
        boost::scoped_ptr<Menubar> menubar_;
index f205e274f0e313d4c7fd9305d14c362c9b0a9965..54344e958f562f6dc1f7f39a1285fbd7b076fb60 100644 (file)
@@ -1,3 +1,12 @@
+2002-08-02  Angus Leeming  <leeming@lyx.org>
+
+       * ControlCharacter.C (apply):
+       * ControlERT.C (applyParamsToInset):
+       * ControlParagraph.C (apply):
+       * ControlSearch.C (find, replace):
+       * ControlThesaurus.C (replace): changes due to LyXView::view() now
+       returning a boost::shared_ptr.
+
 2002-08-01  John Levon  <levon@movementarian.org>
 
        * ControlSendto.C: writeFile() change
index 497e746b5068d4d11fc98cb1035ef08bec5f0ed7..96de55bac5f77211b25b15bc30fac493fd223395 100644 (file)
@@ -62,7 +62,7 @@ void ControlCharacter::apply()
        if (lv_.view()->available())
                view().apply();
 
-       toggleAndShow(lv_.view(), *(font_.get()), toggleall_);
+       toggleAndShow(lv_.view().get(), *(font_.get()), toggleall_);
        lv_.view_state_changed();
        lv_.buffer()->markDirty();
        setMinibuffer(&lv_, _("Character set"));
index 1125440686d8d6b8e3e046a4ab3ab51050d3df7a..76c87ce454f519321778838f23d9bb7cf333ce26 100644 (file)
@@ -30,7 +30,7 @@ ControlERT::ControlERT(LyXView & lv, Dialogs & d)
 
 void ControlERT::applyParamsToInset()
 {
-       inset()->status(lv_.view(), params().status);
+       inset()->status(lv_.view().get(), params().status);
 }
 
 
index 1f6ed41ed9489530e38db348c9a457e34a6df45b..1dbdd96a2b0339f0c62f4550eb2b083cc8ea5800 100644 (file)
@@ -63,7 +63,7 @@ void ControlParagraph::apply()
        view().apply();
 
        LyXText * text(lv_.view()->getLyXText());
-       text->setParagraph(lv_.view(),
+       text->setParagraph(lv_.view().get(),
                           pp_->lineTop(),
                           pp_->lineBottom(),
                           pp_->pagebreakTop(),
index 867ef54425a9f521b0c1276b7bd96bcffa9aa1ee..22a012a7bf66c3f3b9147cf67ecbaae6410449b3 100644 (file)
@@ -39,7 +39,7 @@ ControlSearch::ControlSearch(LyXView & lv, Dialogs & d)
 void ControlSearch::find(string const & search,
                         bool casesensitive, bool matchword, bool forward) const
 {
-       bool const found = lyxfind::LyXFind(lv_.view(), search,
+       bool const found = lyxfind::LyXFind(lv_.view().get(), search,
                                            forward, casesensitive,
                                            matchword);
 
@@ -56,7 +56,7 @@ void ControlSearch::replace(string const & search, string const & replace,
        // changed
        bool const once = !all;
        int const replace_count =
-               lyxfind::LyXReplace(lv_.view(),
+               lyxfind::LyXReplace(lv_.view().get(),
                                    search, replace, true, casesensitive,
                                    matchword, all, once);
 
index 19e042e6124802bb5233cdb6083fce1a312a5cc0..1dc8fc25090a2eafd61c762a252042c9cba7d036 100644 (file)
@@ -43,7 +43,7 @@ void ControlThesaurus::replace(string const & newstr)
         * deletion/change !
         */
        int const replace_count =
-               lyxfind::LyXReplace(lv_.view(), oldstr_, newstr,
+               lyxfind::LyXReplace(lv_.view().get(), oldstr_, newstr,
                                    true, true, true, false, true);
 
        oldstr_ = newstr;
index 8e86e967652dc25a7c2abcc1589dc546880a37f5..5f660da64eac6639ab2cecce4b4697c6db0fd13c 100644 (file)
@@ -1,3 +1,9 @@
+2002-08-02  Angus Leeming  <leeming@lyx.org>
+
+       * FormTabular.C (input):
+       * XMiniBuffer.C (show_info): changes due to LyXView::view() now
+       returning a boost::shared_ptr.
+
 2002-08-01  John Levon  <levon@movementarian.org>
 
        * FormDocument.C: writeFile() change
index cbe494842c00d72c1e99359d724823754cc0454e..ac2133b2e3b2763f9025a331383a1482e3cf81aa 100644 (file)
@@ -558,7 +558,7 @@ bool FormTabular::input(FL_OBJECT * ob, long)
                string const str =
                        getLengthFromWidgets(column_options_->input_column_width,
                                             column_options_->choice_value_column_width);
-               inset_->tabularFeatures(lv_->view(), LyXTabular::SET_PWIDTH, str);
+               inset_->tabularFeatures(lv_->view().get(), LyXTabular::SET_PWIDTH, str);
 
                //check if the input is valid
                string const input =
@@ -577,7 +577,7 @@ bool FormTabular::input(FL_OBJECT * ob, long)
                string const str =
                        getLengthFromWidgets(cell_options_->input_mcolumn_width,
                                             cell_options_->choice_value_mcolumn_width);
-               inset_->tabularFeatures(lv_->view(), LyXTabular::SET_MPWIDTH, str);
+               inset_->tabularFeatures(lv_->view().get(), LyXTabular::SET_MPWIDTH, str);
 
                //check if the input is valid
                string const input =
@@ -690,7 +690,7 @@ bool FormTabular::input(FL_OBJECT * ob, long)
        else
                return false;
 
-       inset_->tabularFeatures(lv_->view(), num, special);
+       inset_->tabularFeatures(lv_->view().get(), num, special);
        update();
 
        return true;
index 5b72dc0605b4ab8be8869024ec80514403ac1c0a..c55eaa1dd74e4736d76a78ec3c1da8f4aa025a7f 100644 (file)
@@ -230,7 +230,7 @@ void XMiniBuffer::show_info(string const & info, string const & input, bool appe
 
 void XMiniBuffer::idle_timeout()
 {
-       set_input(currentState(view_->view()));
+       set_input(currentState(view_->view().get()));
 }
 
 
index a0610964ef3b53041bb65cc1e0bc6075f0495f40..749ff9b19c7e85bbfd167e9488366e3ebd250212 100644 (file)
@@ -77,7 +77,7 @@ bool Importer::Import(LyXView * lv, string const & filename,
                string filename2 = (loader_format == format) ? filename
                        : ChangeExtension(filename,
                                          formats.extension(loader_format));
-               InsertAsciiFile(lv->view(), filename2, as_paragraphs);
+               InsertAsciiFile(lv->view().get(), filename2, as_paragraphs);
                lv->getLyXFunc()->dispatch(LFUN_MARK_OFF);
        }
 
index ad16cef6a018c836bdf95bd9186e9a3d54e5376b..1d398844abd2003016759986ffb57247b0e44f89 100644 (file)
@@ -148,7 +148,7 @@ inline
 void LyXFunc::moveCursorUpdate(bool flag, bool selecting)
 {
        if (selecting || TEXT(flag)->selection.mark()) {
-               TEXT(flag)->setSelection(owner->view());
+               TEXT(flag)->setSelection(owner->view().get());
                if (TEXT(flag)->bv_owner)
                    owner->view()->toggleToggle();
        }
@@ -760,7 +760,7 @@ void LyXFunc::dispatch(kb_action action, string argument, bool verbose)
 #if 1
                        int inset_x;
                        int dummy_y;
-                       inset->getCursorPos(owner->view(), inset_x, dummy_y);
+                       inset->getCursorPos(owner->view().get(), inset_x, dummy_y);
 #endif
                        if ((action == LFUN_UNKNOWN_ACTION)
                            && argument.empty()) {
@@ -775,7 +775,7 @@ void LyXFunc::dispatch(kb_action action, string argument, bool verbose)
                                goto exit_with_message;
                        } else if (((result=inset->
                                     // Hand-over to inset's own dispatch:
-                                    localDispatch(owner->view(), action, argument)) ==
+                                    localDispatch(owner->view().get(), action, argument)) ==
                                    UpdatableInset::DISPATCHED) ||
                                   (result == UpdatableInset::DISPATCHED_NOUPDATE))
                                goto exit_with_message;
@@ -786,7 +786,7 @@ void LyXFunc::dispatch(kb_action action, string argument, bool verbose)
                                // FINISHED means that the cursor should be
                                // one position after the inset.
                        } else if (result == UpdatableInset::FINISHED_RIGHT) {
-                               TEXT()->cursorRight(owner->view());
+                               TEXT()->cursorRight(owner->view().get());
                                moveCursorUpdate(true, false);
                                owner->view_state_changed();
                                goto exit_with_message;
@@ -794,12 +794,12 @@ void LyXFunc::dispatch(kb_action action, string argument, bool verbose)
                                if (TEXT()->cursor.irow()->previous()) {
 #if 1
                                        TEXT()->setCursorFromCoordinates(
-                                               owner->view(), TEXT()->cursor.ix() + inset_x,
+                                               owner->view().get(), TEXT()->cursor.ix() + inset_x,
                                                TEXT()->cursor.iy() -
                                                TEXT()->cursor.irow()->baseline() - 1);
                                        TEXT()->cursor.x_fix(TEXT()->cursor.x());
 #else
-                                       TEXT()->cursorUp(owner->view());
+                                       TEXT()->cursorUp(owner->view().get());
 #endif
                                        moveCursorUpdate(true, false);
                                        owner->view_state_changed();
@@ -811,16 +811,16 @@ void LyXFunc::dispatch(kb_action action, string argument, bool verbose)
                                if (TEXT()->cursor.irow()->next()) {
 #if 1
                                        TEXT()->setCursorFromCoordinates(
-                                               owner->view(), TEXT()->cursor.ix() + inset_x,
+                                               owner->view().get(), TEXT()->cursor.ix() + inset_x,
                                                TEXT()->cursor.iy() -
                                                TEXT()->cursor.irow()->baseline() +
                                                TEXT()->cursor.irow()->height() + 1);
                                        TEXT()->cursor.x_fix(TEXT()->cursor.x());
 #else
-                                       TEXT()->cursorDown(owner->view());
+                                       TEXT()->cursorDown(owner->view().get());
 #endif
                                } else {
-                                       TEXT()->cursorRight(owner->view());
+                                       TEXT()->cursorRight(owner->view().get());
                                }
                                moveCursorUpdate(true, false);
                                owner->view_state_changed();
@@ -833,29 +833,29 @@ void LyXFunc::dispatch(kb_action action, string argument, bool verbose)
                                case LFUN_UNKNOWN_ACTION:
                                case LFUN_BREAKPARAGRAPH:
                                case LFUN_BREAKLINE:
-                                       TEXT()->cursorRight(owner->view());
+                                       TEXT()->cursorRight(owner->view().get());
                                        owner->view()->switchKeyMap();
                                        owner->view_state_changed();
                                        break;
                                case LFUN_RIGHT:
                                        if (!TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
-                                               TEXT()->cursorRight(owner->view());
+                                               TEXT()->cursorRight(owner->view().get());
                                                moveCursorUpdate(true, false);
                                                owner->view_state_changed();
                                        }
                                        goto exit_with_message;
                                case LFUN_LEFT:
                                        if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
-                                               TEXT()->cursorRight(owner->view());
+                                               TEXT()->cursorRight(owner->view().get());
                                                moveCursorUpdate(true, false);
                                                owner->view_state_changed();
                                        }
                                        goto exit_with_message;
                                case LFUN_DOWN:
                                        if (TEXT()->cursor.row()->next())
-                                               TEXT()->cursorDown(owner->view());
+                                               TEXT()->cursorDown(owner->view().get());
                                        else
-                                               TEXT()->cursorRight(owner->view());
+                                               TEXT()->cursorRight(owner->view().get());
                                        moveCursorUpdate(true, false);
                                        owner->view_state_changed();
                                        goto exit_with_message;
@@ -879,11 +879,11 @@ void LyXFunc::dispatch(kb_action action, string argument, bool verbose)
 
                        if (tli == lock) {
                                owner->view()->unlockInset(tli);
-                               TEXT()->cursorRight(owner->view());
+                               TEXT()->cursorRight(owner->view().get());
                                moveCursorUpdate(true, false);
                                owner->view_state_changed();
                        } else {
-                               tli->unlockInsetInInset(owner->view(),
+                               tli->unlockInsetInInset(owner->view().get(),
                                                        lock,
                                                        true);
                        }
@@ -908,7 +908,7 @@ void LyXFunc::dispatch(kb_action action, string argument, bool verbose)
                }
                bool fw = (action == LFUN_WORDFINDBACKWARD);
                if (!searched_string.empty()) {
-                       lyxfind::LyXFind(owner->view(), searched_string, fw);
+                       lyxfind::LyXFind(owner->view().get(), searched_string, fw);
                }
 //             owner->view()->showCursor();
        }
@@ -977,15 +977,15 @@ void LyXFunc::dispatch(kb_action action, string argument, bool verbose)
                        s1 << _("Saving document") << ' '
                           << MakeDisplayPath(owner->buffer()->fileName() + "...");
                        owner->message(s1.str().c_str());
-                       MenuWrite(owner->view(), owner->buffer());
+                       MenuWrite(owner->view().get(), owner->buffer());
                        s1 << _(" done.");
                        owner->message(s1.str().c_str());
                } else
-                       WriteAs(owner->view(), owner->buffer());
+                       WriteAs(owner->view().get(), owner->buffer());
                break;
 
        case LFUN_WRITEAS:
-               WriteAs(owner->view(), owner->buffer(), argument);
+               WriteAs(owner->view().get(), owner->buffer(), argument);
                break;
 
        case LFUN_MENURELOAD:
@@ -1057,7 +1057,7 @@ void LyXFunc::dispatch(kb_action action, string argument, bool verbose)
                break;
 
        case LFUN_AUTOSAVE:
-               AutoSave(owner->view());
+               AutoSave(owner->view().get());
                break;
 
        case LFUN_UNDO:
@@ -1081,11 +1081,11 @@ void LyXFunc::dispatch(kb_action action, string argument, bool verbose)
                break;
 
        case LFUN_DEPTH_MIN:
-               changeDepth(owner->view(), TEXT(false), -1);
+               changeDepth(owner->view().get(), TEXT(false), -1);
                break;
 
        case LFUN_DEPTH_PLUS:
-               changeDepth(owner->view(), TEXT(false), 1);
+               changeDepth(owner->view().get(), TEXT(false), 1);
                break;
 
        case LFUN_FREE:
@@ -1093,7 +1093,7 @@ void LyXFunc::dispatch(kb_action action, string argument, bool verbose)
                break;
 
        case LFUN_RECONFIGURE:
-               Reconfigure(owner->view());
+               Reconfigure(owner->view().get());
                break;
 
 #if 0
@@ -1226,12 +1226,12 @@ void LyXFunc::dispatch(kb_action action, string argument, bool verbose)
                if (owner->view()->theLockingInset()->lyxCode()==Inset::TABULAR_CODE) {
                    InsetTabular * inset = static_cast<InsetTabular *>
                        (owner->view()->theLockingInset());
-                   inset->openLayoutDialog(owner->view());
+                   inset->openLayoutDialog(owner->view().get());
                } else if (owner->view()->theLockingInset()->
                           getFirstLockingInsetOfType(Inset::TABULAR_CODE)!=0) {
                    InsetTabular * inset = static_cast<InsetTabular *>(
                        owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE));
-                   inset->openLayoutDialog(owner->view());
+                   inset->openLayoutDialog(owner->view().get());
                }
            }
            break;
@@ -1313,10 +1313,10 @@ void LyXFunc::dispatch(kb_action action, string argument, bool verbose)
                if (owner->view()->theLockingInset())
                        owner->view()->unlockInset(owner->view()->theLockingInset());
                if (par->inInset()) {
-                       par->inInset()->edit(owner->view());
+                       par->inInset()->edit(owner->view().get());
                }
                // Set the cursor
-               owner->view()->getLyXText()->setCursor(owner->view(), par, 0);
+               owner->view()->getLyXText()->setCursor(owner->view().get(), par, 0);
                owner->view()->switchKeyMap();
                owner->view_state_changed();
 
@@ -1879,5 +1879,5 @@ string const LyXFunc::view_status_message()
        if (!owner->view()->available())
                return _("Welcome to LyX!");
 
-       return currentState(owner->view());
+       return currentState(owner->view().get());
 }