From: Angus Leeming Date: Fri, 2 Aug 2002 09:21:50 +0000 (+0000) Subject: LyXView::view() now returns boost::shared_ptr const &. X-Git-Tag: 1.6.10~18705 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=eed7fcfdf4454e1c3c0f1e40667029a3feedae3e;p=features.git LyXView::view() now returns boost::shared_ptr const &. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4836 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/ChangeLog b/src/ChangeLog index 3ea146d3e7..4217ea24bd 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2002-08-02 Angus Leeming + + * 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 * text2.C (status): small cleanup, no logic change diff --git a/src/frontends/ChangeLog b/src/frontends/ChangeLog index 7bad432a83..d758bedc5c 100644 --- a/src/frontends/ChangeLog +++ b/src/frontends/ChangeLog @@ -1,3 +1,12 @@ +2002-08-02 Angus Leeming + + * LyXView.[Ch] (view): now returns shared_ptr 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 * Dialogs.h: diff --git a/src/frontends/LyXView.C b/src/frontends/LyXView.C index 65e42cf318..db4d1f2c75 100644 --- a/src/frontends/LyXView.C +++ b/src/frontends/LyXView.C @@ -86,9 +86,9 @@ Buffer * LyXView::buffer() const } -BufferView * LyXView::view() const +boost::shared_ptr 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()); } } diff --git a/src/frontends/LyXView.h b/src/frontends/LyXView.h index 24fb6c952f..51bebd9223 100644 --- a/src/frontends/LyXView.h +++ b/src/frontends/LyXView.h @@ -4,7 +4,7 @@ * Copyright 1995-2002 the LyX Team * Read the file COPYING * - * \author Lars Gullik Bjornes + * \author Lars Gullik Bjønnes * \author John Levon */ @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -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 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_; + boost::shared_ptr bufferview_; /// view's menubar boost::scoped_ptr menubar_; diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index f205e274f0..54344e958f 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,12 @@ +2002-08-02 Angus Leeming + + * 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 * ControlSendto.C: writeFile() change diff --git a/src/frontends/controllers/ControlCharacter.C b/src/frontends/controllers/ControlCharacter.C index 497e746b50..96de55bac5 100644 --- a/src/frontends/controllers/ControlCharacter.C +++ b/src/frontends/controllers/ControlCharacter.C @@ -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")); diff --git a/src/frontends/controllers/ControlERT.C b/src/frontends/controllers/ControlERT.C index 1125440686..76c87ce454 100644 --- a/src/frontends/controllers/ControlERT.C +++ b/src/frontends/controllers/ControlERT.C @@ -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); } diff --git a/src/frontends/controllers/ControlParagraph.C b/src/frontends/controllers/ControlParagraph.C index 1f6ed41ed9..1dbdd96a2b 100644 --- a/src/frontends/controllers/ControlParagraph.C +++ b/src/frontends/controllers/ControlParagraph.C @@ -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(), diff --git a/src/frontends/controllers/ControlSearch.C b/src/frontends/controllers/ControlSearch.C index 867ef54425..22a012a7bf 100644 --- a/src/frontends/controllers/ControlSearch.C +++ b/src/frontends/controllers/ControlSearch.C @@ -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); diff --git a/src/frontends/controllers/ControlThesaurus.C b/src/frontends/controllers/ControlThesaurus.C index 19e042e612..1dc8fc2509 100644 --- a/src/frontends/controllers/ControlThesaurus.C +++ b/src/frontends/controllers/ControlThesaurus.C @@ -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; diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 8e86e96765..5f660da64e 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,9 @@ +2002-08-02 Angus Leeming + + * FormTabular.C (input): + * XMiniBuffer.C (show_info): changes due to LyXView::view() now + returning a boost::shared_ptr. + 2002-08-01 John Levon * FormDocument.C: writeFile() change diff --git a/src/frontends/xforms/FormTabular.C b/src/frontends/xforms/FormTabular.C index cbe494842c..ac2133b2e3 100644 --- a/src/frontends/xforms/FormTabular.C +++ b/src/frontends/xforms/FormTabular.C @@ -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; diff --git a/src/frontends/xforms/XMiniBuffer.C b/src/frontends/xforms/XMiniBuffer.C index 5b72dc0605..c55eaa1dd7 100644 --- a/src/frontends/xforms/XMiniBuffer.C +++ b/src/frontends/xforms/XMiniBuffer.C @@ -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())); } diff --git a/src/importer.C b/src/importer.C index a0610964ef..749ff9b19c 100644 --- a/src/importer.C +++ b/src/importer.C @@ -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); } diff --git a/src/lyxfunc.C b/src/lyxfunc.C index ad16cef6a0..1d398844ab 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -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 (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( 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()); }