Skip to content

Commit

Permalink
ofxThreadedImageLoader: bool return on cancelLoad
Browse files Browse the repository at this point in the history
  • Loading branch information
damian authored and damian committed Jul 2, 2012
1 parent 0205cf6 commit 5128068
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 5 additions & 5 deletions addons/ofxThreadedImageLoader/src/ofxThreadedImageLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ void ofxThreadedImageLoader::loadFromURL(ofImage* image, string url) {
images_to_load.push_back(entry);

unlock();
ofLogNotice("ofxThreadedImageLoader", "loading image from url "+url );

}

Expand All @@ -78,6 +77,7 @@ void ofxThreadedImageLoader::threadedFunction() {
unlock();

if(entry.type == OF_LOAD_FROM_DISK) {
ofLogVerbose("ofxThreadedImageLoader", "loading image from disk: " + entry.filename );
entry.image->loadImage(entry.filename);
lock();
images_to_update.push_back(entry);
Expand All @@ -86,7 +86,7 @@ void ofxThreadedImageLoader::threadedFunction() {
else if(entry.type == OF_LOAD_FROM_URL) {
lock();
images_loading_from_url.push_back(entry);
ofLogNotice("ofxThreadedImageLoader", "loading url " + entry.url + " (fname " + entry.filename + ")" );
ofLogNotice("ofxThreadedImageLoader", "loading image from url: " + entry.url );
unlock();
ofLoadURLAsync(entry.url, entry.name);
}
Expand Down Expand Up @@ -212,7 +212,6 @@ ofImageLoaderEntry ofxThreadedImageLoader::getNextImageToLoad() {
images_to_load.pop_front();
}
unlock();
ofLogNotice("ofxThreadedImageLoader", "loading image " + entry.filename );
return entry;
}

Expand All @@ -232,7 +231,7 @@ void ofxThreadedImageLoader::start()
startThread( false, false );
}

void ofxThreadedImageLoader::cancelLoad(ofImage *image)
bool ofxThreadedImageLoader::cancelLoad(ofImage *image)
{
lock();

Expand Down Expand Up @@ -274,9 +273,10 @@ void ofxThreadedImageLoader::cancelLoad(ofImage *image)
if ( found )
images_to_cancel.insert( image );
else {
ofLogWarning("ofxThreadedImageLoader") << "couldn't cancel image " << (unsigned long long)image << " because it was not found in any queue";
ofLogWarning("ofxThreadedImageLoader") << "couldn't cancel image* " << (unsigned long long)image << " because it was not found in any queue";
}
unlock();
return found;
}

void ofxThreadedImageLoader::logStatus()
Expand Down
3 changes: 2 additions & 1 deletion addons/ofxThreadedImageLoader/src/ofxThreadedImageLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ class ofxThreadedImageLoader : public ofThread {

void loadFromDisk(ofImage* image, string file);
void loadFromURL(ofImage* image, string url);
void cancelLoad(ofImage* image);
/// cancel a pending load. if the load has already completed, return false, else return true.
bool cancelLoad(ofImage* image);

/// start running
void start();
Expand Down

0 comments on commit 5128068

Please sign in to comment.