From 264f32ec376b04538d9d0a2d1664de7527772f79 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Fri, 6 Jun 2008 11:52:02 +0000 Subject: [PATCH] Simplify image loading on screen which is not asynchronous, never was... git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25162 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiImage.cpp | 10 ++++------ src/frontends/qt4/GuiImage.h | 4 +--- src/graphics/GraphicsCacheItem.cpp | 24 +----------------------- src/graphics/GraphicsImage.h | 2 +- 4 files changed, 7 insertions(+), 33 deletions(-) diff --git a/src/frontends/qt4/GuiImage.cpp b/src/frontends/qt4/GuiImage.cpp index 4e747808b2..9f45680e5d 100644 --- a/src/frontends/qt4/GuiImage.cpp +++ b/src/frontends/qt4/GuiImage.cpp @@ -64,21 +64,19 @@ unsigned int GuiImage::height() const } -void GuiImage::load(FileName const & filename) +bool GuiImage::load(FileName const & filename) { if (!original_.isNull()) { LYXERR(Debug::GRAPHICS, "Image is loaded already!"); - finishedLoading(false); - return; + return false; } if (!original_.load(toqstr(filename.absFilename()))) { LYXERR(Debug::GRAPHICS, "Unable to open image"); - finishedLoading(false); - return; + return false; } transformed_ = original_; - finishedLoading(true); + return true; } diff --git a/src/frontends/qt4/GuiImage.h b/src/frontends/qt4/GuiImage.h index 57406188ce..cf6ec622dc 100644 --- a/src/frontends/qt4/GuiImage.h +++ b/src/frontends/qt4/GuiImage.h @@ -44,10 +44,8 @@ private: virtual bool isDrawable() const { return true; } /** * Load the image file into memory. - * The process is asynchronous, so this method starts the loading. - * When finished, the Image::finishedLoading signal is emitted. */ - virtual void load(support::FileName const & filename); + bool load(support::FileName const & filename); /** * Finishes the process of modifying transformed_, using * \c params to decide on color, grayscale etc. diff --git a/src/graphics/GraphicsCacheItem.cpp b/src/graphics/GraphicsCacheItem.cpp index 7448f2318e..592e51c525 100644 --- a/src/graphics/GraphicsCacheItem.cpp +++ b/src/graphics/GraphicsCacheItem.cpp @@ -67,12 +67,6 @@ public: */ void imageConverted(bool); - /** Get a notification when the image loading is done. - * Connected to a signal on_finish_ which is passed to - * lyx::graphics::Image::loadImage. - */ - void imageLoaded(bool); - /** Sets the status of the loading process. Also notifies * listeners that the status has changed. */ @@ -116,9 +110,6 @@ public: /// This signal is emitted when the image loading status changes. boost::signal statusChanged; - /// The connection to the signal Image::finishedLoading - boost::signals::connection cl_; - /// The connection of the signal ConvProcess::finishedConversion, boost::signals::connection cc_; @@ -230,9 +221,6 @@ void CacheItem::Impl::reset() status_ = WaitingToLoad; - if (cl_.connected()) - cl_.disconnect(); - if (cc_.connected()) cc_.disconnect(); @@ -289,15 +277,7 @@ void CacheItem::Impl::loadImage() image_.reset(Image::newImage()); - cl_.disconnect(); - cl_ = image_->finishedLoading.connect( - boost::bind(&Impl::imageLoaded, this, _1)); - image_->load(file_to_load_); -} - - -void CacheItem::Impl::imageLoaded(bool success) -{ + bool success = image_->load(file_to_load_); string const text = success ? "succeeded" : "failed"; LYXERR(Debug::GRAPHICS, "Image loading " << text << '.'); @@ -308,8 +288,6 @@ void CacheItem::Impl::imageLoaded(bool success) if (remove_loaded_file_ && unzipped_filename_ != file_to_load_) file_to_load_.removeFile(); - cl_.disconnect(); - if (!success) { setStatus(ErrorLoading); return; diff --git a/src/graphics/GraphicsImage.h b/src/graphics/GraphicsImage.h index 28eef96647..7a90876e2d 100644 --- a/src/graphics/GraphicsImage.h +++ b/src/graphics/GraphicsImage.h @@ -72,7 +72,7 @@ public: * The caller should expect this process to be asynchronous and * so should connect to the "finished" signal above. */ - virtual void load(support::FileName const & filename) = 0; + virtual bool load(support::FileName const & filename) = 0; /** Generate the pixmap. * Uses the params to decide on color, grayscale etc. -- 2.39.2