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
This commit is contained in:
Angus Leeming 2003-10-14 21:30:23 +00:00
parent 6fc6d7e010
commit 50257b8690
34 changed files with 283 additions and 149 deletions

View File

@ -255,7 +255,7 @@ bool BufferView::Pimpl::loadLyXFile(string const & filename, bool tolastfiles)
bv_->showErrorList(_("Parse")); bv_->showErrorList(_("Parse"));
if (tolastfiles) if (tolastfiles)
lastfiles->newFile(b->fileName()); LyX::ref().lastfiles().newFile(b->fileName());
return true; return true;
} }

View File

@ -1,4 +1,20 @@
2003-10-14 Angus Leeming <leeming@lyx.org>
* 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 <poenitz@gmx.net> 2003-10-14 André Pönitz <poenitz@gmx.net>

View File

@ -375,9 +375,11 @@ string const limit_string_length(string const & str)
void expandLastfiles(Menu & tomenu, LyXView const * view) void expandLastfiles(Menu & tomenu, LyXView const * view)
{ {
LastFiles const & lastfiles = LyX::cref().lastfiles();
int ii = 1; int ii = 1;
LastFiles::const_iterator lfit = lastfiles->begin(); LastFiles::const_iterator lfit = lastfiles.begin();
LastFiles::const_iterator end = lastfiles->end(); LastFiles::const_iterator end = lastfiles.end();
for (; lfit != end && ii < 10; ++lfit, ++ii) { for (; lfit != end && ii < 10; ++lfit, ++ii) {
string const label = tostr(ii) + ". " string const label = tostr(ii) + ". "

View File

@ -40,7 +40,7 @@ void emergencyCleanup()
didCleanup = true; didCleanup = true;
LyX::emergencyCleanup(); LyX::cref().emergencyCleanup();
} }
} }

View File

@ -179,7 +179,7 @@ bool BufferList::close(Buffer * buf, bool ask)
if (!WriteAs(buf)) if (!WriteAs(buf))
return false; return false;
} else if (buf->save()) { } else if (buf->save()) {
lastfiles->newFile(buf->fileName()); LyX::ref().lastfiles().newFile(buf->fileName());
} else { } else {
return false; return false;
} }

View File

@ -1,3 +1,8 @@
2003-10-14 Angus Leeming <leeming@lyx.org>
* LyXView.[Ch] (updateInset): invoke BufferView::updateInset, returning
a pointer to the Buffer owning the inset.
2003-10-13 Joao Luis Meloni Assirati <assirati@fma.if.usp.br> 2003-10-13 Joao Luis Meloni Assirati <assirati@fma.if.usp.br>
* lyx_gui.h (set_datasocket_callback, set_serversocket_callback, * lyx_gui.h (set_datasocket_callback, set_serversocket_callback,

View File

@ -192,3 +192,14 @@ void LyXView::dispatch(FuncRequest const & req)
r.setView(view().get()); r.setView(view().get());
getLyXFunc().dispatch(r); 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;
}

View File

@ -21,6 +21,7 @@
class Buffer; class Buffer;
class Toolbar; class Toolbar;
class InsetOld;
class Intl; class Intl;
class Menubar; class Menubar;
class ControlCommandBuffer; class ControlCommandBuffer;
@ -131,6 +132,11 @@ public:
/// dispatch to current BufferView /// dispatch to current BufferView
void dispatch(FuncRequest const & req); 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: protected:
/// view of a buffer. Eventually there will be several. /// view of a buffer. Eventually there will be several.
boost::shared_ptr<BufferView> bufferview_; boost::shared_ptr<BufferView> bufferview_;

View File

@ -1,3 +1,7 @@
2003-10-14 Angus Leeming <leeming@lyx.org>
* lyx_gui.C (start): store the LyXView in the LyX list of all LyXViews.
2003-10-13 José Matos <jamatos@lyx.org> 2003-10-13 José Matos <jamatos@lyx.org>
* lyx_gui.C (set_datasocket_callback, set_serversocket_callback, * lyx_gui.C (set_datasocket_callback, set_serversocket_callback,

View File

@ -313,7 +313,11 @@ void lyx_gui::start(string const & batch, std::vector<string> const & files)
start_xforms(); start_xforms();
// just for debug // just for debug
XSynchronize(getDisplay(), true); XSynchronize(getDisplay(), true);
GView view;
boost::shared_ptr<GView> view_ptr(new GView);
LyX::ref().addLyXView(view_ptr);
GView & view = *view_ptr.get();
view.show(); view.show();
view.init(); view.init();

View File

@ -1,3 +1,7 @@
2003-10-14 Angus Leeming <leeming@lyx.org>
* lyx_gui.C (start): store the LyXView in the LyX list of all LyXViews.
2003-10-13 João Luis Meloni Assirati <assirati@fma.if.usp.br> 2003-10-13 João Luis Meloni Assirati <assirati@fma.if.usp.br>
* lyx_gui.C: Declared and allocated lyxsocket. * lyx_gui.C: Declared and allocated lyxsocket.

View File

@ -22,6 +22,7 @@
// FIXME: move this stuff out again // FIXME: move this stuff out again
#include "bufferlist.h" #include "bufferlist.h"
#include "lyx_main.h"
#include "LyXAction.h" #include "LyXAction.h"
#include "lyxfunc.h" #include "lyxfunc.h"
#include "lyxrc.h" #include "lyxrc.h"
@ -136,7 +137,10 @@ void start(string const & batch, vector<string> const & files)
unsigned int width = 690; unsigned int width = 690;
unsigned int height = 510; unsigned int height = 510;
QtView view(width, height); boost::shared_ptr<QtView> view_ptr(new QtView(width, height));
LyX::ref().addLyXView(view_ptr);
QtView & view = *view_ptr.get();
view.show(); view.show();
view.init(); view.init();

View File

@ -1,3 +1,9 @@
2003-10-14 Angus Leeming <leeming@lyx.org>
* 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 <assirati@fma.if.usp.br> 2003-10-13 Joao Luis Meloni Assirati <assirati@fma.if.usp.br>
* lyx_gui.C (set_datasocket_callback, set_serversocket_callback, * lyx_gui.C (set_datasocket_callback, set_serversocket_callback,

View File

@ -121,7 +121,7 @@ int LyX_XErrHandler(Display * display, XErrorEvent * xeev) {
} }
// emergency cleanup // emergency cleanup
LyX::emergencyCleanup(); LyX::cref().emergencyCleanup();
// Get the reason for the crash. // Get the reason for the crash.
char etxt[513]; char etxt[513];
@ -284,7 +284,10 @@ void start(string const & batch, vector<string> const & files)
lyxerr[Debug::GUI] << "Creating view: " << width << 'x' << height lyxerr[Debug::GUI] << "Creating view: " << width << 'x' << height
<< '+' << xpos << '+' << ypos << endl; << '+' << xpos << '+' << ypos << endl;
XFormsView view(width, height); boost::shared_ptr<XFormsView> view_ptr(new XFormsView(width, height));
LyX::ref().addLyXView(view_ptr);
XFormsView & view = *view_ptr.get();
view.show(xpos, ypos, "LyX"); view.show(xpos, ypos, "LyX");
view.init(); view.init();

View File

@ -1,3 +1,16 @@
2003-10-14 Angus Leeming <leeming@lyx.org>
* 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 <boost/weak_ptr.hpp>. Cruft from an
earlier clean-up.
2003-10-14 Angus Leeming <leeming@lyx.org> 2003-10-14 Angus Leeming <leeming@lyx.org>
* insetinclude.C (metrics, draw): only draw the preview when previews * insetinclude.C (metrics, draw): only draw the preview when previews

View File

@ -23,6 +23,7 @@
#include "gettext.h" #include "gettext.h"
#include "LaTeXFeatures.h" #include "LaTeXFeatures.h"
#include "latexrunparams.h" #include "latexrunparams.h"
#include "lyx_main.h"
#include "lyxlex.h" #include "lyxlex.h"
#include "lyxrc.h" #include "lyxrc.h"
#include "metricsinfo.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 void InsetExternal::statusChanged() const
{ {
BufferView * const bv = view(); LyX::cref().updateInset(this);
if (bv)
bv->updateInset(this);
} }
@ -449,7 +436,6 @@ void InsetExternal::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetExternal::draw(PainterInfo & pi, int x, int y) const void InsetExternal::draw(PainterInfo & pi, int x, int y) const
{ {
cache(pi.base.bv);
renderer_->draw(pi, x, y); renderer_->draw(pi, x, y);
} }

View File

@ -21,7 +21,6 @@
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
#include <boost/signals/trackable.hpp> #include <boost/signals/trackable.hpp>
#include <boost/weak_ptr.hpp>
/** No two InsetExternalParams variables can have the same temporary file. /** No two InsetExternalParams variables can have the same temporary file.
@ -129,8 +128,6 @@ public:
void setParams(InsetExternalParams const &, Buffer const &); void setParams(InsetExternalParams const &, Buffer const &);
private: private:
void cache(BufferView *) const;
BufferView * view() const;
/** This method is connected to the graphics loader, so we are /** This method is connected to the graphics loader, so we are
* informed when the image has been loaded. * informed when the image has been loaded.
*/ */
@ -140,9 +137,6 @@ private:
InsetExternalParams params_; InsetExternalParams params_;
/// The thing that actually draws the image on LyX's screen. /// The thing that actually draws the image on LyX's screen.
boost::scoped_ptr<RenderBase> renderer_; boost::scoped_ptr<RenderBase> renderer_;
/// Cached
mutable boost::weak_ptr<BufferView> view_;
}; };

View File

@ -64,6 +64,7 @@ TODO
#include "gettext.h" #include "gettext.h"
#include "LaTeXFeatures.h" #include "LaTeXFeatures.h"
#include "latexrunparams.h" #include "latexrunparams.h"
#include "lyx_main.h"
#include "lyxlex.h" #include "lyxlex.h"
#include "lyxrc.h" #include "lyxrc.h"
#include "metricsinfo.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 void InsetGraphics::statusChanged() const
{ {
BufferView * bv = view(); LyX::cref().updateInset(this);
if (bv)
bv->updateInset(this);
} }
@ -241,7 +228,6 @@ void InsetGraphics::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetGraphics::draw(PainterInfo & pi, int x, int y) const void InsetGraphics::draw(PainterInfo & pi, int x, int y) const
{ {
cache(pi.base.bv);
graphic_->draw(pi, x, y); graphic_->draw(pi, x, y);
} }

View File

@ -18,8 +18,6 @@
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
#include <boost/signals/trackable.hpp> #include <boost/signals/trackable.hpp>
#include <boost/weak_ptr.hpp>
class Dialogs; class Dialogs;
class RenderGraphic; class RenderGraphic;
@ -83,9 +81,6 @@ private:
/// ///
friend class InsetGraphicsMailer; friend class InsetGraphicsMailer;
void cache(BufferView *) const;
BufferView * view() const;
/** This method is connected to the graphics loader, so we are /** This method is connected to the graphics loader, so we are
* informed when the image has been loaded. * informed when the image has been loaded.
*/ */
@ -109,9 +104,6 @@ private:
/// The thing that actually draws the image on LyX's screen. /// The thing that actually draws the image on LyX's screen.
boost::scoped_ptr<RenderGraphic> const graphic_; boost::scoped_ptr<RenderGraphic> const graphic_;
/// Cached
mutable boost::weak_ptr<BufferView> view_;
}; };

View File

@ -22,6 +22,7 @@
#include "gettext.h" #include "gettext.h"
#include "LaTeXFeatures.h" #include "LaTeXFeatures.h"
#include "latexrunparams.h" #include "latexrunparams.h"
#include "lyx_main.h"
#include "lyxlex.h" #include "lyxlex.h"
#include "metricsinfo.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 void InsetInclude::draw(PainterInfo & pi, int x, int y) const
{ {
cache(pi.base.bv);
if (!RenderPreview::activated() || !preview_->previewReady()) { if (!RenderPreview::activated() || !preview_->previewReady()) {
button_.draw(pi, x + button_.box().x1, y); button_.draw(pi, x + button_.box().x1, y);
return; return;
} }
if (!preview_->monitoring()) { BOOST_ASSERT(pi.base.bv);
string const included_file = Buffer const * const buffer = pi.base.bv->buffer();
includedFilename(*view()->buffer(), params_); if (!preview_->monitoring() && buffer) {
string const included_file = includedFilename(*buffer, params_);
preview_->startMonitoring(included_file); 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 // preview stuff
// //
void InsetInclude::statusChanged() const void InsetInclude::statusChanged() const
{ {
if (view()) LyX::cref().updateInset(this);
view()->updateInset(this);
} }
void InsetInclude::fileChanged() const void InsetInclude::fileChanged() const
{ {
BufferView * const bv = view(); Buffer const * const buffer_ptr = LyX::cref().updateInset(this);
if (!bv) if (!buffer_ptr)
return; return;
bv->updateInset(this);
if (!bv->buffer())
return;
Buffer const & buffer = *bv->buffer();
Buffer const & buffer = *buffer_ptr;
preview_->removePreview(buffer); preview_->removePreview(buffer);
generate_preview(*preview_.get(), *this, buffer); generate_preview(*preview_.get(), *this, buffer);
} }

View File

@ -16,8 +16,6 @@
#include "insetcommandparams.h" #include "insetcommandparams.h"
#include "render_button.h" #include "render_button.h"
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
#include <boost/weak_ptr.hpp>
class Buffer; class Buffer;
class Dimension; class Dimension;
@ -82,9 +80,6 @@ public:
void addPreview(lyx::graphics::PreviewLoader &) const; void addPreview(lyx::graphics::PreviewLoader &) const;
private: private:
void cache(BufferView *) const;
BufferView * view() const;
/// Slot receiving a signal that the preview is ready to display. /// Slot receiving a signal that the preview is ready to display.
void statusChanged() const; void statusChanged() const;
/** Slot receiving a signal that the external file has changed /** Slot receiving a signal that the external file has changed
@ -112,7 +107,6 @@ private:
boost::scoped_ptr<RenderMonitoredPreview> const preview_; boost::scoped_ptr<RenderMonitoredPreview> const preview_;
/// cache /// cache
mutable boost::weak_ptr<BufferView> view_;
mutable bool set_label_; mutable bool set_label_;
mutable RenderButton button_; mutable RenderButton button_;
}; };

View File

@ -12,9 +12,7 @@
#ifndef INSET_LABEL_H #ifndef INSET_LABEL_H
#define INSET_LABEL_H #define INSET_LABEL_H
#include "insetcommand.h" #include "insetcommand.h"
#include <boost/weak_ptr.hpp>
class InsetLabel : public InsetCommand { class InsetLabel : public InsetCommand {
public: public:

View File

@ -90,7 +90,7 @@ bool quitting; // flag, that we are quitting the program
bool MenuWrite(Buffer * buffer) bool MenuWrite(Buffer * buffer)
{ {
if (buffer->save()) { if (buffer->save()) {
lastfiles->newFile(buffer->fileName()); LyX::ref().lastfiles().newFile(buffer->fileName());
return true; return true;
} }
@ -184,7 +184,7 @@ void QuitLyX()
if (!bufferlist.quitWriteAll()) if (!bufferlist.quitWriteAll())
return; return;
lastfiles->writeFile(lyxrc.lastfiles); LyX::cref().lastfiles().writeFile(lyxrc.lastfiles);
} }
// Set a flag that we do quitting from the program, // Set a flag that we do quitting from the program,

View File

@ -40,6 +40,7 @@
#include "frontends/Alert.h" #include "frontends/Alert.h"
#include "frontends/lyx_gui.h" #include "frontends/lyx_gui.h"
#include "frontends/LyXView.h"
#include "support/FileInfo.h" #include "support/FileInfo.h"
#include "support/filetools.h" #include "support/filetools.h"
@ -87,8 +88,6 @@ extern void QuitLyX();
extern LyXServer * lyxserver; extern LyXServer * lyxserver;
boost::scoped_ptr<LastFiles> lastfiles;
// This is the global bufferlist object // This is the global bufferlist object
BufferList bufferlist; BufferList bufferlist;
@ -105,9 +104,80 @@ void showFileError(string const & error)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} // namespace anon
boost::scoped_ptr<LyX> 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<LyXView> 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 // Here we need to parse the command line. At least
// we need to parse for "-dbg" and "-help" // we need to parse for "-dbg" and "-help"
@ -226,7 +296,7 @@ static void error_handler(int err_sig)
signal(SIGTERM, SIG_DFL); signal(SIGTERM, SIG_DFL);
signal(SIGPIPE, SIG_DFL); signal(SIGPIPE, SIG_DFL);
LyX::emergencyCleanup(); LyX::cref().emergencyCleanup();
lyxerr << "Bye." << endl; lyxerr << "Bye." << endl;
if (err_sig!= SIGHUP && if (err_sig!= SIGHUP &&
@ -327,9 +397,9 @@ void LyX::init(bool gui)
lyxerr[Debug::INIT] << "Reading lastfiles `" lyxerr[Debug::INIT] << "Reading lastfiles `"
<< lyxrc.lastfiles << "'..." << endl; << lyxrc.lastfiles << "'..." << endl;
lastfiles.reset(new LastFiles(lyxrc.lastfiles, lastfiles_.reset(new LastFiles(lyxrc.lastfiles,
lyxrc.check_lastfiles, lyxrc.check_lastfiles,
lyxrc.num_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 // what to do about tmpfiles is non-obvious. we would
// like to delete any we find, but our lyxdir might // like to delete any we find, but our lyxdir might

View File

@ -15,31 +15,46 @@
#define LYX_MAIN_H #define LYX_MAIN_H
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/utility.hpp> #include <boost/utility.hpp>
#include <list>
#include <string> #include <string>
class ErrorItem;
class LyXRC;
class LastFiles;
class Buffer; class Buffer;
class ErrorItem;
class InsetOld;
class LastFiles;
class LyXView;
class kb_keymap; class kb_keymap;
/// last files loaded
extern boost::scoped_ptr<LastFiles> lastfiles;
/// initial startup /// initial startup
class LyX : boost::noncopyable { class LyX : boost::noncopyable {
public: 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 /// in the case of failure
static void emergencyCleanup(); void emergencyCleanup() const;
LastFiles & lastfiles();
LastFiles const & lastfiles() const;
void addLyXView(boost::shared_ptr<LyXView> 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: private:
static boost::scoped_ptr<LyX> singleton_;
LyX();
void priv_exec(int & argc, char * argv[]);
/// initial LyX set up /// initial LyX set up
void init(bool); void init(bool);
/// set up the default key bindings /// set up the default key bindings
@ -65,6 +80,12 @@ private:
bool first_start; bool first_start;
/// the parsed command line batch command if any /// the parsed command line batch command if any
std::string batch_command; std::string batch_command;
/// last files loaded
boost::scoped_ptr<LastFiles> lastfiles_;
///
typedef std::list<boost::shared_ptr<LyXView> > ViewList;
ViewList views_;
}; };
#endif // LYX_MAIN_H #endif // LYX_MAIN_H

View File

@ -34,6 +34,6 @@ int main(int argc, char * argv[])
// initialize for internationalized version *EK* // initialize for internationalized version *EK*
locale_init(); locale_init();
LyX lyx(argc, argv); LyX::exec(argc, argv);
return 0; return 0;
} }

View File

@ -1,3 +1,9 @@
2003-10-14 Angus Leeming <leeming@lyx.org>
* insetformulabase.[Ch] (view, cache, view_): remove the BufferView cache.
* insetformula.C (statusChanged): call LyX::cref().updateInset.
2003-10-14 Angus Leeming <leeming@lyx.org> 2003-10-14 Angus Leeming <leeming@lyx.org>
* formula.C (metrics, draw): only draw the preview when previews * formula.C (metrics, draw): only draw the preview when previews

View File

@ -22,6 +22,7 @@
#include "debug.h" #include "debug.h"
#include "latexrunparams.h" #include "latexrunparams.h"
#include "LColor.h" #include "LColor.h"
#include "lyx_main.h"
#include "frontends/Painter.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 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. // The previews are drawn only when we're not editing the inset.
bool const use_preview = (!editing_inset(this) && bool const use_preview = (!editing_inset(this) &&
RenderPreview::activated() && RenderPreview::activated() &&
@ -300,8 +299,7 @@ void InsetFormula::mutate(string const & type)
void InsetFormula::statusChanged() const void InsetFormula::statusChanged() const
{ {
if (view()) LyX::cref().updateInset(this);
view()->updateInset(this);
} }

View File

@ -14,12 +14,6 @@
#include "formulabase.h" #include "formulabase.h"
#include "formula.h" #include "formula.h"
#include "formulamacro.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_support.h"
#include "math_arrayinset.h" #include "math_arrayinset.h"
#include "math_deliminset.h" #include "math_deliminset.h"
@ -28,17 +22,24 @@
#include "math_hullinset.h" #include "math_hullinset.h"
#include "math_parser.h" #include "math_parser.h"
#include "math_spaceinset.h" #include "math_spaceinset.h"
#include "undo.h"
#include "ref_inset.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 "LColor.h"
#include "lyxtext.h"
#include "undo.h"
#include "frontends/LyXView.h"
#include "frontends/Dialogs.h"
#include "support/std_sstream.h" #include "support/std_sstream.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "support/lyxlib.h" #include "support/lyxlib.h"
#include "frontends/LyXView.h"
#include "frontends/Dialogs.h"
using lyx::support::atoi; using lyx::support::atoi;
using lyx::support::split; using lyx::support::split;
using lyx::support::token; 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 void InsetFormulaBase::validate(LaTeXFeatures &) const
{} {}

View File

@ -15,8 +15,6 @@
#define INSET_FORMULABASE_H #define INSET_FORMULABASE_H
#include "insets/updatableinset.h" #include "insets/updatableinset.h"
#include <boost/weak_ptr.hpp>
class Buffer; class Buffer;
class BufferView; class BufferView;
@ -98,10 +96,6 @@ private:
/// ///
dispatch_result lfunMouseMotion(FuncRequest const &); dispatch_result lfunMouseMotion(FuncRequest const &);
protected:
void cache(BufferView *) const;
BufferView * view() const;
protected: protected:
/** Find the PreviewLoader, add a LaTeX snippet to it and /** Find the PreviewLoader, add a LaTeX snippet to it and
@ -121,9 +115,6 @@ protected:
mutable int xo_; mutable int xo_;
/// ///
mutable int yo_; mutable int yo_;
private:
// Cache
mutable boost::weak_ptr<BufferView> view_;
}; };
// We don't really mess want around with mathed stuff outside mathed. // We don't really mess want around with mathed stuff outside mathed.

View File

@ -1,3 +1,13 @@
2003-10-14 Angus Leeming <leeming@lyx.org>
* 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 <leeming@lyx.org> 2003-10-08 Angus Leeming <leeming@lyx.org>
Fix doxygen warnings. Fix doxygen warnings.

View File

@ -16,7 +16,6 @@ bin_PROGRAMS = tex2lyx
linked_files = \ linked_files = \
FloatList.C \ FloatList.C \
Floating.C \ Floating.C \
boost.C \
counters.C \ counters.C \
lyxlayout.h \ lyxlayout.h \
lyxlayout.C \ lyxlayout.C \
@ -28,6 +27,7 @@ linked_files = \
tex2lyx_SOURCES = \ tex2lyx_SOURCES = \
$(linked_files) \ $(linked_files) \
Spacing.h \ Spacing.h \
boost.C \
context.C \ context.C \
context.h \ context.h \
gettext.C \ gettext.C \

41
src/tex2lyx/boost.C Normal file
View File

@ -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 <config.h>
#include "debug.h"
#include <boost/assert.hpp>
#include <cstdlib>
#include <exception>
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

View File

@ -16,7 +16,6 @@
#include "context.h" #include "context.h"
#include "debug.h" #include "debug.h"
#include "lyx_main.h"
#include "lyxtextclass.h" #include "lyxtextclass.h"
#include "support/path_defines.h" #include "support/path_defines.h"
#include "support/os.h" #include "support/os.h"
@ -43,8 +42,6 @@ using std::vector;
// Hacks to allow the thing to link in the lyxlayout stuff // Hacks to allow the thing to link in the lyxlayout stuff
LyXErr lyxerr(std::cerr.rdbuf()); LyXErr lyxerr(std::cerr.rdbuf());
void LyX::emergencyCleanup() {}
void handle_comment(Parser & p) void handle_comment(Parser & p)
{ {
string s; string s;