From 50257b86904437b6695a7a9a823fbe4301ba0ce3 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Tue, 14 Oct 2003 21:30:23 +0000 Subject: [PATCH] Turn LyX into a singleton class. Kill the BufferView cache. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7922 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView_pimpl.C | 2 +- src/ChangeLog | 16 +++++++ src/MenuBackend.C | 6 ++- src/boost.C | 2 +- src/bufferlist.C | 2 +- src/frontends/ChangeLog | 5 ++ src/frontends/LyXView.C | 11 +++++ src/frontends/LyXView.h | 6 +++ src/frontends/gtk/ChangeLog | 4 ++ src/frontends/gtk/lyx_gui.C | 6 ++- src/frontends/qt2/ChangeLog | 4 ++ src/frontends/qt2/lyx_gui.C | 6 ++- src/frontends/xforms/ChangeLog | 6 +++ src/frontends/xforms/lyx_gui.C | 7 ++- src/insets/ChangeLog | 13 +++++ src/insets/insetexternal.C | 18 +------ src/insets/insetexternal.h | 6 --- src/insets/insetgraphics.C | 18 +------ src/insets/insetgraphics.h | 8 ---- src/insets/insetinclude.C | 35 ++++---------- src/insets/insetinclude.h | 6 --- src/insets/insetlabel.h | 2 - src/lyx_cb.C | 4 +- src/lyx_main.C | 86 ++++++++++++++++++++++++++++++---- src/lyx_main.h | 39 +++++++++++---- src/main.C | 2 +- src/mathed/ChangeLog | 6 +++ src/mathed/formula.C | 6 +-- src/mathed/formulabase.C | 33 +++++-------- src/mathed/formulabase.h | 9 ---- src/tex2lyx/ChangeLog | 10 ++++ src/tex2lyx/Makefile.am | 2 +- src/tex2lyx/boost.C | 41 ++++++++++++++++ src/tex2lyx/tex2lyx.C | 3 -- 34 files changed, 282 insertions(+), 148 deletions(-) create mode 100644 src/tex2lyx/boost.C diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index b51094424b..4e917e76f5 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -255,7 +255,7 @@ bool BufferView::Pimpl::loadLyXFile(string const & filename, bool tolastfiles) bv_->showErrorList(_("Parse")); if (tolastfiles) - lastfiles->newFile(b->fileName()); + LyX::ref().lastfiles().newFile(b->fileName()); return true; } diff --git a/src/ChangeLog b/src/ChangeLog index 62ba735680..88bc9e7823 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,4 +1,20 @@ +2003-10-14 Angus Leeming + * lyx_main.[Ch]: make LyX a singleton class, accessible though the new + static member functions LyX::ref() and LyX::cref. + (lastfiles): new accessor functions for the new lastfiles_ member var. + (addLyXView, views_): add a new LyXView to the list of views_. + (updateInset): loop over all LyXViews to call their own updateInset + member function, returning a pointer to the Buffer owning the inset. + + * BufferView_pimpl.C (loadLyXFile): + * MenuBackend.C (expandLastfiles): + * bufferlist.C (MenuWrite, QuitLyX): + lastfiles is no longer a global variable. + Access through LyX::ref().lastfiles(), LyX::cref().lastfiles(). + + * boost.C (emergencyCleanup): LyX::emergencyCleanup is no longer a + static function. Access through LyX::cref().emergencyCleanup(). 2003-10-14 André Pönitz diff --git a/src/MenuBackend.C b/src/MenuBackend.C index 9614260e58..dcd90ba517 100644 --- a/src/MenuBackend.C +++ b/src/MenuBackend.C @@ -375,9 +375,11 @@ string const limit_string_length(string const & str) void expandLastfiles(Menu & tomenu, LyXView const * view) { + LastFiles const & lastfiles = LyX::cref().lastfiles(); + int ii = 1; - LastFiles::const_iterator lfit = lastfiles->begin(); - LastFiles::const_iterator end = lastfiles->end(); + LastFiles::const_iterator lfit = lastfiles.begin(); + LastFiles::const_iterator end = lastfiles.end(); for (; lfit != end && ii < 10; ++lfit, ++ii) { string const label = tostr(ii) + ". " diff --git a/src/boost.C b/src/boost.C index 440b4ffd93..2a6570d881 100644 --- a/src/boost.C +++ b/src/boost.C @@ -40,7 +40,7 @@ void emergencyCleanup() didCleanup = true; - LyX::emergencyCleanup(); + LyX::cref().emergencyCleanup(); } } diff --git a/src/bufferlist.C b/src/bufferlist.C index 0bd23d364d..aeb2d32a0c 100644 --- a/src/bufferlist.C +++ b/src/bufferlist.C @@ -179,7 +179,7 @@ bool BufferList::close(Buffer * buf, bool ask) if (!WriteAs(buf)) return false; } else if (buf->save()) { - lastfiles->newFile(buf->fileName()); + LyX::ref().lastfiles().newFile(buf->fileName()); } else { return false; } diff --git a/src/frontends/ChangeLog b/src/frontends/ChangeLog index cf56889bf2..fc2d2c30a9 100644 --- a/src/frontends/ChangeLog +++ b/src/frontends/ChangeLog @@ -1,3 +1,8 @@ +2003-10-14 Angus Leeming + + * LyXView.[Ch] (updateInset): invoke BufferView::updateInset, returning + a pointer to the Buffer owning the inset. + 2003-10-13 Joao Luis Meloni Assirati * lyx_gui.h (set_datasocket_callback, set_serversocket_callback, diff --git a/src/frontends/LyXView.C b/src/frontends/LyXView.C index b05c6a4a6d..658a4a25f7 100644 --- a/src/frontends/LyXView.C +++ b/src/frontends/LyXView.C @@ -192,3 +192,14 @@ void LyXView::dispatch(FuncRequest const & req) r.setView(view().get()); getLyXFunc().dispatch(r); } + + +Buffer const * const LyXView::updateInset(InsetOld const * inset) const +{ + Buffer const * buffer_ptr = 0; + if (inset) { + buffer_ptr = bufferview_->buffer(); + bufferview_->updateInset(inset); + } + return buffer_ptr; +} diff --git a/src/frontends/LyXView.h b/src/frontends/LyXView.h index 08a094539a..c16c7a9a33 100644 --- a/src/frontends/LyXView.h +++ b/src/frontends/LyXView.h @@ -21,6 +21,7 @@ class Buffer; class Toolbar; +class InsetOld; class Intl; class Menubar; class ControlCommandBuffer; @@ -131,6 +132,11 @@ public: /// dispatch to current BufferView void dispatch(FuncRequest const & req); + /** redraw \c inset in all the BufferViews in which it is currently + * visible. If successful return a pointer to the owning Buffer. + */ + Buffer const * const updateInset(InsetOld const *) const; + protected: /// view of a buffer. Eventually there will be several. boost::shared_ptr bufferview_; diff --git a/src/frontends/gtk/ChangeLog b/src/frontends/gtk/ChangeLog index 40c3c5834d..773bddf886 100644 --- a/src/frontends/gtk/ChangeLog +++ b/src/frontends/gtk/ChangeLog @@ -1,3 +1,7 @@ +2003-10-14 Angus Leeming + + * lyx_gui.C (start): store the LyXView in the LyX list of all LyXViews. + 2003-10-13 José Matos * lyx_gui.C (set_datasocket_callback, set_serversocket_callback, diff --git a/src/frontends/gtk/lyx_gui.C b/src/frontends/gtk/lyx_gui.C index 20a620b305..99aeab7445 100644 --- a/src/frontends/gtk/lyx_gui.C +++ b/src/frontends/gtk/lyx_gui.C @@ -313,7 +313,11 @@ void lyx_gui::start(string const & batch, std::vector const & files) start_xforms(); // just for debug XSynchronize(getDisplay(), true); - GView view; + + boost::shared_ptr view_ptr(new GView); + LyX::ref().addLyXView(view_ptr); + + GView & view = *view_ptr.get(); view.show(); view.init(); diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 6f8faa2525..6de9680e83 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,7 @@ +2003-10-14 Angus Leeming + + * lyx_gui.C (start): store the LyXView in the LyX list of all LyXViews. + 2003-10-13 João Luis Meloni Assirati * lyx_gui.C: Declared and allocated lyxsocket. diff --git a/src/frontends/qt2/lyx_gui.C b/src/frontends/qt2/lyx_gui.C index d470bdad20..5c7132f533 100644 --- a/src/frontends/qt2/lyx_gui.C +++ b/src/frontends/qt2/lyx_gui.C @@ -22,6 +22,7 @@ // FIXME: move this stuff out again #include "bufferlist.h" +#include "lyx_main.h" #include "LyXAction.h" #include "lyxfunc.h" #include "lyxrc.h" @@ -136,7 +137,10 @@ void start(string const & batch, vector const & files) unsigned int width = 690; unsigned int height = 510; - QtView view(width, height); + boost::shared_ptr view_ptr(new QtView(width, height)); + LyX::ref().addLyXView(view_ptr); + + QtView & view = *view_ptr.get(); view.show(); view.init(); diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index d9801ed0d1..05149c6a37 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,9 @@ +2003-10-14 Angus Leeming + + * lyx_gui.C (start): store the LyXView in the LyX list of all LyXViews. + (LyX_XErrHandler): LyX::emergencyCleanup is no longer a static function. + Access through LyX::cref().emergencyCleanup(). + 2003-10-13 Joao Luis Meloni Assirati * lyx_gui.C (set_datasocket_callback, set_serversocket_callback, diff --git a/src/frontends/xforms/lyx_gui.C b/src/frontends/xforms/lyx_gui.C index bf3bb46e47..aff7700353 100644 --- a/src/frontends/xforms/lyx_gui.C +++ b/src/frontends/xforms/lyx_gui.C @@ -121,7 +121,7 @@ int LyX_XErrHandler(Display * display, XErrorEvent * xeev) { } // emergency cleanup - LyX::emergencyCleanup(); + LyX::cref().emergencyCleanup(); // Get the reason for the crash. char etxt[513]; @@ -284,7 +284,10 @@ void start(string const & batch, vector const & files) lyxerr[Debug::GUI] << "Creating view: " << width << 'x' << height << '+' << xpos << '+' << ypos << endl; - XFormsView view(width, height); + boost::shared_ptr view_ptr(new XFormsView(width, height)); + LyX::ref().addLyXView(view_ptr); + + XFormsView & view = *view_ptr.get(); view.show(xpos, ypos, "LyX"); view.init(); diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index c8fe12abc0..1959ddc91f 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,16 @@ +2003-10-14 Angus Leeming + + * insetexternal.[Ch] (view, cache, view_): + * insetgraphics.[Ch] (view, cache, view_): + * insetinclude.[Ch] (view, cache, view_): remove the BufferView cache. + (statusChanged): call LyX::cref().updateInset. + + * insetinclude.C (fileChanged): use LyX::cref().updateInset rather than + the BufferView cache. + + * insetlabel.h: remove #include . Cruft from an + earlier clean-up. + 2003-10-14 Angus Leeming * insetinclude.C (metrics, draw): only draw the preview when previews diff --git a/src/insets/insetexternal.C b/src/insets/insetexternal.C index 14b95c7fde..479fa9e08b 100644 --- a/src/insets/insetexternal.C +++ b/src/insets/insetexternal.C @@ -23,6 +23,7 @@ #include "gettext.h" #include "LaTeXFeatures.h" #include "latexrunparams.h" +#include "lyx_main.h" #include "lyxlex.h" #include "lyxrc.h" #include "metricsinfo.h" @@ -380,23 +381,9 @@ InsetExternal::~InsetExternal() } -void InsetExternal::cache(BufferView * view) const -{ - BOOST_ASSERT(view); - view_ = view->owner()->view(); -} - -BufferView * InsetExternal::view() const -{ - return view_.lock().get(); -} - - void InsetExternal::statusChanged() const { - BufferView * const bv = view(); - if (bv) - bv->updateInset(this); + LyX::cref().updateInset(this); } @@ -449,7 +436,6 @@ void InsetExternal::metrics(MetricsInfo & mi, Dimension & dim) const void InsetExternal::draw(PainterInfo & pi, int x, int y) const { - cache(pi.base.bv); renderer_->draw(pi, x, y); } diff --git a/src/insets/insetexternal.h b/src/insets/insetexternal.h index 31d2b9ae33..93d0e678c0 100644 --- a/src/insets/insetexternal.h +++ b/src/insets/insetexternal.h @@ -21,7 +21,6 @@ #include #include -#include /** No two InsetExternalParams variables can have the same temporary file. @@ -129,8 +128,6 @@ public: void setParams(InsetExternalParams const &, Buffer const &); private: - void cache(BufferView *) const; - BufferView * view() const; /** This method is connected to the graphics loader, so we are * informed when the image has been loaded. */ @@ -140,9 +137,6 @@ private: InsetExternalParams params_; /// The thing that actually draws the image on LyX's screen. boost::scoped_ptr renderer_; - - /// Cached - mutable boost::weak_ptr view_; }; diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index 4312834269..a54703a921 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -64,6 +64,7 @@ TODO #include "gettext.h" #include "LaTeXFeatures.h" #include "latexrunparams.h" +#include "lyx_main.h" #include "lyxlex.h" #include "lyxrc.h" #include "metricsinfo.h" @@ -183,23 +184,9 @@ InsetGraphics::~InsetGraphics() } -void InsetGraphics::cache(BufferView * view) const -{ - BOOST_ASSERT(view); - view_ = view->owner()->view(); -} - -BufferView * InsetGraphics::view() const -{ - return view_.lock().get(); -} - - void InsetGraphics::statusChanged() const { - BufferView * bv = view(); - if (bv) - bv->updateInset(this); + LyX::cref().updateInset(this); } @@ -241,7 +228,6 @@ void InsetGraphics::metrics(MetricsInfo & mi, Dimension & dim) const void InsetGraphics::draw(PainterInfo & pi, int x, int y) const { - cache(pi.base.bv); graphic_->draw(pi, x, y); } diff --git a/src/insets/insetgraphics.h b/src/insets/insetgraphics.h index 2ac1afc35b..6559752142 100644 --- a/src/insets/insetgraphics.h +++ b/src/insets/insetgraphics.h @@ -18,8 +18,6 @@ #include #include -#include - class Dialogs; class RenderGraphic; @@ -83,9 +81,6 @@ private: /// friend class InsetGraphicsMailer; - void cache(BufferView *) const; - BufferView * view() const; - /** This method is connected to the graphics loader, so we are * informed when the image has been loaded. */ @@ -109,9 +104,6 @@ private: /// The thing that actually draws the image on LyX's screen. boost::scoped_ptr const graphic_; - - /// Cached - mutable boost::weak_ptr view_; }; diff --git a/src/insets/insetinclude.C b/src/insets/insetinclude.C index 1a3a5090c2..3a5cbda597 100644 --- a/src/insets/insetinclude.C +++ b/src/insets/insetinclude.C @@ -22,6 +22,7 @@ #include "gettext.h" #include "LaTeXFeatures.h" #include "latexrunparams.h" +#include "lyx_main.h" #include "lyxlex.h" #include "metricsinfo.h" @@ -540,16 +541,15 @@ void InsetInclude::metrics(MetricsInfo & mi, Dimension & dim) const void InsetInclude::draw(PainterInfo & pi, int x, int y) const { - cache(pi.base.bv); - if (!RenderPreview::activated() || !preview_->previewReady()) { button_.draw(pi, x + button_.box().x1, y); return; } - if (!preview_->monitoring()) { - string const included_file = - includedFilename(*view()->buffer(), params_); + BOOST_ASSERT(pi.base.bv); + Buffer const * const buffer = pi.base.bv->buffer(); + if (!preview_->monitoring() && buffer) { + string const included_file = includedFilename(*buffer, params_); preview_->startMonitoring(included_file); } @@ -557,40 +557,23 @@ void InsetInclude::draw(PainterInfo & pi, int x, int y) const } -void InsetInclude::cache(BufferView * view) const -{ - BOOST_ASSERT(view); - view_ = view->owner()->view(); -} - -BufferView * InsetInclude::view() const -{ - return view_.lock().get(); -} - - // // preview stuff // void InsetInclude::statusChanged() const { - if (view()) - view()->updateInset(this); + LyX::cref().updateInset(this); } void InsetInclude::fileChanged() const { - BufferView * const bv = view(); - if (!bv) - return; - bv->updateInset(this); - - if (!bv->buffer()) + Buffer const * const buffer_ptr = LyX::cref().updateInset(this); + if (!buffer_ptr) return; - Buffer const & buffer = *bv->buffer(); + Buffer const & buffer = *buffer_ptr; preview_->removePreview(buffer); generate_preview(*preview_.get(), *this, buffer); } diff --git a/src/insets/insetinclude.h b/src/insets/insetinclude.h index 9fda837950..5e96daea32 100644 --- a/src/insets/insetinclude.h +++ b/src/insets/insetinclude.h @@ -16,8 +16,6 @@ #include "insetcommandparams.h" #include "render_button.h" #include -#include - class Buffer; class Dimension; @@ -82,9 +80,6 @@ public: void addPreview(lyx::graphics::PreviewLoader &) const; private: - void cache(BufferView *) const; - BufferView * view() const; - /// Slot receiving a signal that the preview is ready to display. void statusChanged() const; /** Slot receiving a signal that the external file has changed @@ -112,7 +107,6 @@ private: boost::scoped_ptr const preview_; /// cache - mutable boost::weak_ptr view_; mutable bool set_label_; mutable RenderButton button_; }; diff --git a/src/insets/insetlabel.h b/src/insets/insetlabel.h index c9db1eea30..d42255e93b 100644 --- a/src/insets/insetlabel.h +++ b/src/insets/insetlabel.h @@ -12,9 +12,7 @@ #ifndef INSET_LABEL_H #define INSET_LABEL_H - #include "insetcommand.h" -#include class InsetLabel : public InsetCommand { public: diff --git a/src/lyx_cb.C b/src/lyx_cb.C index e9dbaccf92..ca6afd6dcc 100644 --- a/src/lyx_cb.C +++ b/src/lyx_cb.C @@ -90,7 +90,7 @@ bool quitting; // flag, that we are quitting the program bool MenuWrite(Buffer * buffer) { if (buffer->save()) { - lastfiles->newFile(buffer->fileName()); + LyX::ref().lastfiles().newFile(buffer->fileName()); return true; } @@ -184,7 +184,7 @@ void QuitLyX() if (!bufferlist.quitWriteAll()) return; - lastfiles->writeFile(lyxrc.lastfiles); + LyX::cref().lastfiles().writeFile(lyxrc.lastfiles); } // Set a flag that we do quitting from the program, diff --git a/src/lyx_main.C b/src/lyx_main.C index a96bf63db3..eb5d7b0289 100644 --- a/src/lyx_main.C +++ b/src/lyx_main.C @@ -40,6 +40,7 @@ #include "frontends/Alert.h" #include "frontends/lyx_gui.h" +#include "frontends/LyXView.h" #include "support/FileInfo.h" #include "support/filetools.h" @@ -87,8 +88,6 @@ extern void QuitLyX(); extern LyXServer * lyxserver; -boost::scoped_ptr lastfiles; - // This is the global bufferlist object BufferList bufferlist; @@ -105,9 +104,80 @@ void showFileError(string const & error) exit(EXIT_FAILURE); } +} // namespace anon + + +boost::scoped_ptr LyX::singleton_; + +void LyX::exec(int & argc, char * argv[]) +{ + BOOST_ASSERT(!singleton_.get()); + // We must return from this before launching the gui so that + // other parts of the code can access singleton_ through + // LyX::ref and LyX::cref. + singleton_.reset(new LyX); + // Start the real execution loop. + singleton_->priv_exec(argc, argv); +} + + +LyX & LyX::ref() +{ + BOOST_ASSERT(singleton_.get()); + return *singleton_.get(); } -LyX::LyX(int & argc, char * argv[]) + +LyX const & LyX::cref() +{ + BOOST_ASSERT(singleton_.get()); + return *singleton_.get(); +} + + +LyX::LyX() + : first_start(false) +{} + + +LastFiles & LyX::lastfiles() +{ + BOOST_ASSERT(lastfiles_.get()); + return *lastfiles_.get(); +} + + +LastFiles const & LyX::lastfiles() const +{ + BOOST_ASSERT(lastfiles_.get()); + return *lastfiles_.get(); +} + + +void LyX::addLyXView(boost::shared_ptr const & lyxview) +{ + views_.push_back(lyxview); +} + + +Buffer const * const LyX::updateInset(InsetOld const * inset) const +{ + if (!inset) + return 0; + + Buffer const * buffer_ptr = 0; + ViewList::const_iterator it = views_.begin(); + ViewList::const_iterator const end = views_.end(); + for (; it != end; ++it) { + Buffer const * ptr = (*it)->updateInset(inset); + if (ptr) + buffer_ptr = ptr; + } + return buffer_ptr; +} + + +void LyX::priv_exec(int & argc, char * argv[]) { // Here we need to parse the command line. At least // we need to parse for "-dbg" and "-help" @@ -226,7 +296,7 @@ static void error_handler(int err_sig) signal(SIGTERM, SIG_DFL); signal(SIGPIPE, SIG_DFL); - LyX::emergencyCleanup(); + LyX::cref().emergencyCleanup(); lyxerr << "Bye." << endl; if (err_sig!= SIGHUP && @@ -327,9 +397,9 @@ void LyX::init(bool gui) lyxerr[Debug::INIT] << "Reading lastfiles `" << lyxrc.lastfiles << "'..." << endl; - lastfiles.reset(new LastFiles(lyxrc.lastfiles, - lyxrc.check_lastfiles, - lyxrc.num_lastfiles)); + lastfiles_.reset(new LastFiles(lyxrc.lastfiles, + lyxrc.check_lastfiles, + lyxrc.num_lastfiles)); } @@ -391,7 +461,7 @@ void LyX::defaultKeyBindings(kb_keymap * kbmap) } -void LyX::emergencyCleanup() +void LyX::emergencyCleanup() const { // what to do about tmpfiles is non-obvious. we would // like to delete any we find, but our lyxdir might diff --git a/src/lyx_main.h b/src/lyx_main.h index c9cdf781bf..4929f141f1 100644 --- a/src/lyx_main.h +++ b/src/lyx_main.h @@ -15,31 +15,46 @@ #define LYX_MAIN_H #include +#include #include +#include #include - +class Buffer; class ErrorItem; -class LyXRC; +class InsetOld; class LastFiles; -class Buffer; +class LyXView; class kb_keymap; -/// last files loaded -extern boost::scoped_ptr lastfiles; - - /// initial startup class LyX : boost::noncopyable { public: - LyX(int & argc, char * argv[]); + static void exec(int & argc, char * argv[]); + static LyX & ref(); + static LyX const & cref(); /// in the case of failure - static void emergencyCleanup(); + void emergencyCleanup() const; + + LastFiles & lastfiles(); + LastFiles const & lastfiles() const; + + void addLyXView(boost::shared_ptr const & lyxview); + + /** redraw \c inset in all the BufferViews in which it is currently + * visible. If successful return a pointer to the owning Buffer. + */ + Buffer const * const updateInset(InsetOld const *) const; private: + static boost::scoped_ptr singleton_; + + LyX(); + void priv_exec(int & argc, char * argv[]); + /// initial LyX set up void init(bool); /// set up the default key bindings @@ -65,6 +80,12 @@ private: bool first_start; /// the parsed command line batch command if any std::string batch_command; + + /// last files loaded + boost::scoped_ptr lastfiles_; + /// + typedef std::list > ViewList; + ViewList views_; }; #endif // LYX_MAIN_H diff --git a/src/main.C b/src/main.C index 3dbd1ea067..b6366d73e6 100644 --- a/src/main.C +++ b/src/main.C @@ -34,6 +34,6 @@ int main(int argc, char * argv[]) // initialize for internationalized version *EK* locale_init(); - LyX lyx(argc, argv); + LyX::exec(argc, argv); return 0; } diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index f015e04706..d2f91ba06a 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,9 @@ +2003-10-14 Angus Leeming + + * insetformulabase.[Ch] (view, cache, view_): remove the BufferView cache. + + * insetformula.C (statusChanged): call LyX::cref().updateInset. + 2003-10-14 Angus Leeming * formula.C (metrics, draw): only draw the preview when previews diff --git a/src/mathed/formula.C b/src/mathed/formula.C index fb2f0a96ce..e6c7cf1939 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -22,6 +22,7 @@ #include "debug.h" #include "latexrunparams.h" #include "LColor.h" +#include "lyx_main.h" #include "frontends/Painter.h" @@ -191,8 +192,6 @@ bool editing_inset(InsetFormula const * inset) void InsetFormula::draw(PainterInfo & pi, int x, int y) const { - cache(pi.base.bv); - // The previews are drawn only when we're not editing the inset. bool const use_preview = (!editing_inset(this) && RenderPreview::activated() && @@ -300,8 +299,7 @@ void InsetFormula::mutate(string const & type) void InsetFormula::statusChanged() const { - if (view()) - view()->updateInset(this); + LyX::cref().updateInset(this); } diff --git a/src/mathed/formulabase.C b/src/mathed/formulabase.C index 15331df22b..25c3bc8a26 100644 --- a/src/mathed/formulabase.C +++ b/src/mathed/formulabase.C @@ -14,12 +14,6 @@ #include "formulabase.h" #include "formula.h" #include "formulamacro.h" -#include "funcrequest.h" -#include "BufferView.h" -#include "bufferview_funcs.h" -#include "lyxtext.h" -#include "gettext.h" -#include "debug.h" #include "math_support.h" #include "math_arrayinset.h" #include "math_deliminset.h" @@ -28,17 +22,24 @@ #include "math_hullinset.h" #include "math_parser.h" #include "math_spaceinset.h" -#include "undo.h" #include "ref_inset.h" + +#include "BufferView.h" +#include "bufferview_funcs.h" +#include "debug.h" +#include "funcrequest.h" +#include "gettext.h" #include "LColor.h" +#include "lyxtext.h" +#include "undo.h" + +#include "frontends/LyXView.h" +#include "frontends/Dialogs.h" #include "support/std_sstream.h" #include "support/lstrings.h" #include "support/lyxlib.h" -#include "frontends/LyXView.h" -#include "frontends/Dialogs.h" - using lyx::support::atoi; using lyx::support::split; using lyx::support::token; @@ -139,18 +140,6 @@ void InsetFormulaBase::handleFont2(BufferView * bv, string const & arg) -void InsetFormulaBase::cache(BufferView * view) const -{ - BOOST_ASSERT(view); - view_ = view->owner()->view(); -} - -BufferView * InsetFormulaBase::view() const -{ - return view_.lock().get(); -} - - void InsetFormulaBase::validate(LaTeXFeatures &) const {} diff --git a/src/mathed/formulabase.h b/src/mathed/formulabase.h index c00a9a4da0..904f46e18b 100644 --- a/src/mathed/formulabase.h +++ b/src/mathed/formulabase.h @@ -15,8 +15,6 @@ #define INSET_FORMULABASE_H #include "insets/updatableinset.h" -#include - class Buffer; class BufferView; @@ -98,10 +96,6 @@ private: /// dispatch_result lfunMouseMotion(FuncRequest const &); -protected: - void cache(BufferView *) const; - BufferView * view() const; - protected: /** Find the PreviewLoader, add a LaTeX snippet to it and @@ -121,9 +115,6 @@ protected: mutable int xo_; /// mutable int yo_; -private: - // Cache - mutable boost::weak_ptr view_; }; // We don't really mess want around with mathed stuff outside mathed. diff --git a/src/tex2lyx/ChangeLog b/src/tex2lyx/ChangeLog index 545f64fb7a..e307beb66f 100644 --- a/src/tex2lyx/ChangeLog +++ b/src/tex2lyx/ChangeLog @@ -1,3 +1,13 @@ +2003-10-14 Angus Leeming + + * Makefile.am: move boost.C from the linked_files section + to the tex2lyx_SOURCES section. + + * boost.C: new file. Simpler than the version in the main lyx source. + No reference to the emergencyCleanup stuff. + + * tex2lyx.C: remove emergencyCleanup() stuff. + 2003-10-08 Angus Leeming Fix doxygen warnings. diff --git a/src/tex2lyx/Makefile.am b/src/tex2lyx/Makefile.am index 8eb294b56d..ffa371e66b 100644 --- a/src/tex2lyx/Makefile.am +++ b/src/tex2lyx/Makefile.am @@ -16,7 +16,6 @@ bin_PROGRAMS = tex2lyx linked_files = \ FloatList.C \ Floating.C \ - boost.C \ counters.C \ lyxlayout.h \ lyxlayout.C \ @@ -28,6 +27,7 @@ linked_files = \ tex2lyx_SOURCES = \ $(linked_files) \ Spacing.h \ + boost.C \ context.C \ context.h \ gettext.C \ diff --git a/src/tex2lyx/boost.C b/src/tex2lyx/boost.C new file mode 100644 index 0000000000..f923302c37 --- /dev/null +++ b/src/tex2lyx/boost.C @@ -0,0 +1,41 @@ +/** + * \file boost.C + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Lars Gullik Bjønnes + * + * Full author contact details are available in file CREDITS. + */ + +#include + +#include "debug.h" + +#include + +#include +#include + +using std::endl; + +namespace boost { + +void throw_exception(std::exception const & e) +{ + lyxerr << "Exception caught:\n" + << e.what() << endl; + BOOST_ASSERT(false); +} + + +void assertion_failed(char const * expr, char const * function, + char const * file, long line) +{ + lyxerr << "Assertion triggered in " << function + << " by failing check \"" << expr << "\"" + << " in file " << file << ":" << line << endl; + ::abort(); +} + +} // namespace boost diff --git a/src/tex2lyx/tex2lyx.C b/src/tex2lyx/tex2lyx.C index c59ae90625..da40cb21cd 100644 --- a/src/tex2lyx/tex2lyx.C +++ b/src/tex2lyx/tex2lyx.C @@ -16,7 +16,6 @@ #include "context.h" #include "debug.h" -#include "lyx_main.h" #include "lyxtextclass.h" #include "support/path_defines.h" #include "support/os.h" @@ -43,8 +42,6 @@ using std::vector; // Hacks to allow the thing to link in the lyxlayout stuff LyXErr lyxerr(std::cerr.rdbuf()); -void LyX::emergencyCleanup() {} - void handle_comment(Parser & p) { string s; -- 2.39.2