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
This commit is contained in:
Abdelrazak Younes 2008-06-06 11:52:02 +00:00
parent 20b45450f6
commit 264f32ec37
4 changed files with 7 additions and 33 deletions

View File

@ -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;
}

View File

@ -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.

View File

@ -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<void()> 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;

View File

@ -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.