From a67816b7285d8cf6ba1e4b8e71ac8b7f1f9a7536 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Wed, 26 Feb 2003 11:41:23 +0000 Subject: [PATCH] Alfredo's patch to get rid of insets in the graphics code. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6277 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/graphics/ChangeLog | 6 ++++++ src/graphics/GraphicsLoader.C | 24 +++--------------------- src/graphics/GraphicsLoader.h | 5 +---- src/graphics/PreviewImage.C | 10 +++++----- src/graphics/PreviewImage.h | 2 +- src/graphics/PreviewedInset.C | 2 +- src/insets/ChangeLog | 6 ++++++ src/insets/insetgraphics.C | 2 +- src/insets/insetinclude.C | 2 +- src/mathed/ChangeLog | 7 ++++++- src/mathed/formula.C | 2 +- 11 files changed, 32 insertions(+), 36 deletions(-) diff --git a/src/graphics/ChangeLog b/src/graphics/ChangeLog index c7605830e7..0fb4207ad2 100644 --- a/src/graphics/ChangeLog +++ b/src/graphics/ChangeLog @@ -1,3 +1,9 @@ +2003-02-26 Alfredo Braunstein + + * GraphicsLoader.[Ch], + * PreviewImage.[Ch], + * PreviewedInset.C: Removed unneeded list of owner insets + 2003-02-25 Alfredo Braunstein * GraphicsConverter (startConversion): add the call to diff --git a/src/graphics/GraphicsLoader.C b/src/graphics/GraphicsLoader.C index 02f99da749..5da53f9b84 100644 --- a/src/graphics/GraphicsLoader.C +++ b/src/graphics/GraphicsLoader.C @@ -40,7 +40,7 @@ struct Loader::Impl : boost::signals::trackable { void createPixmap(); /// - void startLoading(Inset const &); + void startLoading(); /// The loading status of the image. ImageStatus status_; @@ -62,10 +62,6 @@ private: /// Params params_; - // Multiple Insets can share the same image - typedef std::list InsetList; - /// - InsetList insets; }; @@ -122,15 +118,7 @@ void Loader::startLoading() const { if (pimpl_->status_ != WaitingToLoad || !pimpl_->cached_item_.get()) return; - pimpl_->cached_item_->startLoading(); -} - - -void Loader::startLoading(Inset const & inset) const -{ - if (pimpl_->status_ != WaitingToLoad || !pimpl_->cached_item_.get()) - return; - pimpl_->startLoading(inset); + pimpl_->startLoading(); } @@ -281,17 +269,11 @@ void Loader::Impl::createPixmap() } -void Loader::Impl::startLoading(Inset const & inset) +void Loader::Impl::startLoading() { if (status_ != WaitingToLoad) return; - InsetList::const_iterator it = insets.begin(); - InsetList::const_iterator end = insets.end(); - it = std::find(it, end, &inset); - if (it == end) - insets.push_back(&inset); - LoaderQueue::get().touch(cached_item_); } diff --git a/src/graphics/GraphicsLoader.h b/src/graphics/GraphicsLoader.h index 2fcd23a262..893070919a 100644 --- a/src/graphics/GraphicsLoader.h +++ b/src/graphics/GraphicsLoader.h @@ -63,13 +63,10 @@ public: /// bool empty() const { return filename().empty(); } - /// We are explicit about when we begin the loading process. - void startLoading() const; - /** starting loading of the image is done by a urgency-based * decision. Here we only call LoaderQueue::touch to request it. */ - void startLoading(Inset const &) const; + void startLoading() const; /** Monitor any changes to the file. * There is no point monitoring the file before startLoading() is diff --git a/src/graphics/PreviewImage.C b/src/graphics/PreviewImage.C index 2dde30b979..bd96232e73 100644 --- a/src/graphics/PreviewImage.C +++ b/src/graphics/PreviewImage.C @@ -30,7 +30,7 @@ struct PreviewImage::Impl : public boost::signals::trackable { /// ~Impl(); /// - Image const * image(Inset const &); + Image const * image(); /// void statusChanged(); @@ -93,9 +93,9 @@ int PreviewImage::width() const } -Image const * PreviewImage::image(Inset const & inset) const +Image const * PreviewImage::image() const { - return pimpl_->image(inset); + return pimpl_->image(); } @@ -116,10 +116,10 @@ PreviewImage::Impl::~Impl() } -Image const * PreviewImage::Impl::image(Inset const & inset) +Image const * PreviewImage::Impl::image() { if (iloader_.status() == WaitingToLoad) - iloader_.startLoading(inset); + iloader_.startLoading(); return iloader_.image(); } diff --git a/src/graphics/PreviewImage.h b/src/graphics/PreviewImage.h index bc12bfb81b..4c459756d0 100644 --- a/src/graphics/PreviewImage.h +++ b/src/graphics/PreviewImage.h @@ -47,7 +47,7 @@ public: /** If the image is not yet loaded (WaitingToLoad), then this method * triggers that. */ - Image const * image(Inset const & inset) const; + Image const * image() const; private: /// Use the Pimpl idiom to hide the internals. diff --git a/src/graphics/PreviewedInset.C b/src/graphics/PreviewedInset.C index 89604d6747..fca6369910 100644 --- a/src/graphics/PreviewedInset.C +++ b/src/graphics/PreviewedInset.C @@ -105,7 +105,7 @@ bool PreviewedInset::previewReady() const if (!pimage_) return false; - return pimage_->image(inset_); + return pimage_->image(); } diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 92953044f3..74b82a4239 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,9 @@ +2003-02-26 Alfredo Braunstein + + * insetgraphics.C (draw) + * insetinclude.C (draw): Eliminate also the other argument (owner + inset inset) in the call to PreviewImage::image + 2003-02-25 Alfredo Braunstein * insetgraphics.C (draw) diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index f344ead2a4..68cca4efef 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -348,7 +348,7 @@ void InsetGraphics::draw(BufferView * bv, LyXFont const & font, if (gparams.display != grfx::NoDisplay && cache_->loader.status() == grfx::WaitingToLoad) - cache_->loader.startLoading(*this); + cache_->loader.startLoading(); if (!cache_->loader.monitoring()) cache_->loader.startMonitoring(); diff --git a/src/insets/insetinclude.C b/src/insets/insetinclude.C index 93efb6d10f..ba360a63d8 100644 --- a/src/insets/insetinclude.C +++ b/src/insets/insetinclude.C @@ -534,7 +534,7 @@ void InsetInclude::draw(BufferView * bv, LyXFont const & font, int y, int const h = a + d; bv->painter().image(x, y - a, w, h, - *(preview_->pimage()->image(*this))); + *(preview_->pimage()->image())); xx += w; } diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index d08cf4d442..c7498033a8 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,4 +1,9 @@ -003-02-26 Angus Leeming +2003-02-26 Alfredo Braunstein + + * formula.C (draw): strip also the other argument (the owner inset) in + the call to PreviewImage::image + +2003-02-26 Angus Leeming * ref_inset.[Ch]: add a localDispatch method to RefInset. add a string2RefInset function to 'translate' the string passed to the diff --git a/src/mathed/formula.C b/src/mathed/formula.C index be88b35c58..3ce28a819e 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -211,7 +211,7 @@ void InsetFormula::draw(BufferView * bv, LyXFont const & font, if (use_preview) { pi.pain.image(x + 1, y - a, w, h, // one pixel gap in front - *(preview_->pimage()->image(*this))); + *(preview_->pimage()->image())); } else { pi.base.style = LM_ST_TEXT; pi.base.font = font;