Solving issue 2045: "Batch queue pp3's conflicts with main pp3's"

This commit is contained in:
Hombre
2013-12-02 00:59:28 +01:00
parent 9a17e9780d
commit b549ecf5a8
5 changed files with 52 additions and 34 deletions

View File

@@ -74,7 +74,18 @@ BatchQueue::BatchQueue () : processing(NULL), sequence(0), listener(NULL) {
BatchQueue::~BatchQueue () BatchQueue::~BatchQueue ()
{ {
delete pmenu; #if PROTECT_VECTORS
MYWRITERLOCK(l, entryRW);
#endif
// The listener merges parameters with old values, so delete afterwards
for (size_t i=0; i<fd.size(); i++)
{
delete fd.at(i);
}
fd.clear ();
delete pmenu;
} }
void BatchQueue::resizeLoadedQueue() { void BatchQueue::resizeLoadedQueue() {
@@ -349,15 +360,16 @@ bool BatchQueue::loadBatchQueue( )
if( pparams.load( paramsFile ) ) if( pparams.load( paramsFile ) )
continue; continue;
::Thumbnail *thumb = cacheMgr->getEntry( source, &pparams ); ::Thumbnail *thumb = cacheMgr->getEntry( source );
if( thumb ){ if( thumb ){
rtengine::ProcessingJob* job = rtengine::ProcessingJob::create(source, thumb->getType() == FT_Raw, pparams); rtengine::ProcessingJob* job = rtengine::ProcessingJob::create(source, thumb->getType() == FT_Raw, pparams);
int prevh = getMaxThumbnailHeight(); int prevh = getMaxThumbnailHeight();
int prevw = prevh; int prevw = prevh;
thumb->getThumbnailSize (prevw, prevh); thumb->getThumbnailSize (prevw, prevh, &pparams);
BatchQueueEntry *entry = new BatchQueueEntry(job, pparams,source, prevw, prevh, thumb); BatchQueueEntry *entry = new BatchQueueEntry(job, pparams,source, prevw, prevh, thumb);
thumb->decreaseRef(); // Removing the refCount acquired by cacheMgr->getEntry
entry->setParent(this); entry->setParent(this);
// BatchQueueButtonSet HAVE TO be added before resizing to take them into account // BatchQueueButtonSet HAVE TO be added before resizing to take them into account
@@ -661,7 +673,7 @@ rtengine::ProcessingJob* BatchQueue::imageReady (rtengine::IImage16* img) {
MYREADERLOCK_RELEASE(l); MYREADERLOCK_RELEASE(l);
#endif #endif
std::vector<Glib::ustring> names; std::vector<Glib::ustring> names;
Glib::ustring batchdir = options.rtdir+"/batch/"; Glib::ustring batchdir = Glib::build_filename(options.rtdir, "batch");
Glib::RefPtr<Gio::File> dir = Gio::File::create_for_path (batchdir); Glib::RefPtr<Gio::File> dir = Gio::File::create_for_path (batchdir);
safe_build_file_list (dir, names, batchdir); safe_build_file_list (dir, names, batchdir);
for(std::vector<Glib::ustring>::iterator iter=names.begin(); iter != names.end();iter++ ) for(std::vector<Glib::ustring>::iterator iter=names.begin(); iter != names.end();iter++ )
@@ -885,7 +897,6 @@ void BatchQueue::redrawNeeded (LWButton* button) {
void BatchQueue::error (Glib::ustring msg) { void BatchQueue::error (Glib::ustring msg) {
BatchQueueEntry* current = static_cast<BatchQueueEntry*>(fd[0]);
if (processing && processing->processing) { if (processing && processing->processing) {
// restore failed thumb // restore failed thumb
BatchQueueButtonSet* bqbs = new BatchQueueButtonSet (processing); BatchQueueButtonSet* bqbs = new BatchQueueButtonSet (processing);

View File

@@ -64,11 +64,7 @@ void CacheManager::init () {
safe_g_mkdir_with_parents (Glib::ustring(Glib::build_filename (baseDir, "data")), 511); safe_g_mkdir_with_parents (Glib::ustring(Glib::build_filename (baseDir, "data")), 511);
} }
/* Thumbnail* CacheManager::getEntry (const Glib::ustring& fname) {
* if pparams is NULL (default), get the ProcParams from the cache;
* if pparams is non NULL, compute the thumbnails with the provided pparams
*/
Thumbnail* CacheManager::getEntry (const Glib::ustring& fname, const rtengine::procparams::ProcParams *pparams) {
Thumbnail* res = NULL; Thumbnail* res = NULL;
@@ -98,7 +94,7 @@ Thumbnail* CacheManager::getEntry (const Glib::ustring& fname, const rtengine::p
CacheImageData* cfs = new CacheImageData (); CacheImageData* cfs = new CacheImageData ();
int e = cfs->load (cfname); int e = cfs->load (cfname);
if (!e && cfs->supported==true) if (!e && cfs->supported==true)
res = new Thumbnail (this, fname, cfs, pparams); res = new Thumbnail (this, fname, cfs);
if (res && !res->isSupported ()) { if (res && !res->isSupported ()) {
delete res; delete res;
res = NULL; res = NULL;
@@ -108,7 +104,7 @@ Thumbnail* CacheManager::getEntry (const Glib::ustring& fname, const rtengine::p
// if not, create a new one // if not, create a new one
if (!res) { if (!res) {
res = new Thumbnail (this, fname, md5, pparams); res = new Thumbnail (this, fname, md5);
if (!res->isSupported ()) { if (!res->isSupported ()) {
delete res; delete res;
res = NULL; res = NULL;

View File

@@ -47,7 +47,7 @@ class CacheManager {
static CacheManager* getInstance(void); static CacheManager* getInstance(void);
void init (); void init ();
Thumbnail* getEntry (const Glib::ustring& fname, const rtengine::procparams::ProcParams *pparams=NULL); Thumbnail* getEntry (const Glib::ustring& fname);
void deleteEntry (const Glib::ustring& fname); void deleteEntry (const Glib::ustring& fname);
void renameEntry (const std::string& oldfilename, const std::string& oldmd5, const std::string& newfilename); void renameEntry (const std::string& oldfilename, const std::string& oldmd5, const std::string& newfilename);

View File

@@ -33,18 +33,13 @@
using namespace rtengine::procparams; using namespace rtengine::procparams;
Thumbnail::Thumbnail (CacheManager* cm, const Glib::ustring& fname, CacheImageData* cf, const rtengine::procparams::ProcParams *pparams) Thumbnail::Thumbnail (CacheManager* cm, const Glib::ustring& fname, CacheImageData* cf)
: fname(fname), cfs(*cf), cachemgr(cm), ref(1), enqueueNumber(0), tpp(NULL), : fname(fname), cfs(*cf), cachemgr(cm), ref(1), enqueueNumber(0), tpp(NULL),
pparamsValid(false), needsReProcessing(true),imageLoading(false), lastImg(NULL), pparamsValid(false), needsReProcessing(true),imageLoading(false), lastImg(NULL),
lastW(0), lastH(0), lastScale(0), initial_(false) lastW(0), lastH(0), lastScale(0), initial_(false)
{ {
if (pparams) { loadProcParams ();
this->pparams = *pparams;
pparamsValid = true;
}
else
loadProcParams ();
// should be safe to use the unprotected version of loadThumbnail, since we are in the constructor // should be safe to use the unprotected version of loadThumbnail, since we are in the constructor
_loadThumbnail (); _loadThumbnail ();
@@ -66,7 +61,7 @@ Thumbnail::Thumbnail (CacheManager* cm, const Glib::ustring& fname, CacheImageDa
tpp = 0; tpp = 0;
} }
Thumbnail::Thumbnail (CacheManager* cm, const Glib::ustring& fname, const std::string& md5, const rtengine::procparams::ProcParams *pparams) Thumbnail::Thumbnail (CacheManager* cm, const Glib::ustring& fname, const std::string& md5)
: fname(fname), cachemgr(cm), ref(1), enqueueNumber(0), tpp(NULL), pparamsValid(false), : fname(fname), cachemgr(cm), ref(1), enqueueNumber(0), tpp(NULL), pparamsValid(false),
needsReProcessing(true),imageLoading(false), lastImg(NULL), needsReProcessing(true),imageLoading(false), lastImg(NULL),
initial_(true) initial_(true)
@@ -74,12 +69,7 @@ Thumbnail::Thumbnail (CacheManager* cm, const Glib::ustring& fname, const std::s
cfs.md5 = md5; cfs.md5 = md5;
if (pparams) { loadProcParams ();
this->pparams = *pparams;
pparamsValid = true;
}
else
loadProcParams ();
_generateThumbnailImage (); _generateThumbnailImage ();
cfs.recentlySaved = false; cfs.recentlySaved = false;
@@ -456,11 +446,32 @@ void Thumbnail::decreaseRef ()
cachemgr->closeThumbnail (this); cachemgr->closeThumbnail (this);
} }
void Thumbnail::getThumbnailSize (int &w, int &h) { void Thumbnail::getThumbnailSize (int &w, int &h, const rtengine::procparams::ProcParams *pparams) {
if (imgRatio > 0.) int tw_ = tw;
w = (int)(imgRatio * (float)h); int th_ = th;
float imgRatio_ = imgRatio;
if (pparams) {
int ppCoarse = pparams->coarse.rotate;
if (ppCoarse >= 180) ppCoarse -= 180;
int thisCoarse = this->pparams.coarse.rotate;
if (thisCoarse >= 180) thisCoarse -= 180;
if (thisCoarse != ppCoarse) {
// different orientation -> swapping width & height
int tmp = th_;
th_ = tw_;
tw_ = tmp;
if (imgRatio_ >= 0.0001f)
imgRatio_ = 1.f/imgRatio_;
}
}
if (imgRatio_ > 0.)
w = (int)(imgRatio_ * (float)h);
else else
w = tw * h / th; w = tw_ * h / th_;
} }
void Thumbnail::getFinalSize (const rtengine::procparams::ProcParams& pparams, int& w, int& h) { void Thumbnail::getFinalSize (const rtengine::procparams::ProcParams& pparams, int& w, int& h) {

View File

@@ -77,8 +77,8 @@ class Thumbnail {
Glib::ustring getCacheFileName (Glib::ustring subdir); Glib::ustring getCacheFileName (Glib::ustring subdir);
public: public:
Thumbnail (CacheManager* cm, const Glib::ustring& fname, CacheImageData* cf, const rtengine::procparams::ProcParams *pparams=NULL); Thumbnail (CacheManager* cm, const Glib::ustring& fname, CacheImageData* cf);
Thumbnail (CacheManager* cm, const Glib::ustring& fname, const std::string& md5, const rtengine::procparams::ProcParams *pparams=NULL); Thumbnail (CacheManager* cm, const Glib::ustring& fname, const std::string& md5);
~Thumbnail (); ~Thumbnail ();
bool hasProcParams (); bool hasProcParams ();
@@ -105,7 +105,7 @@ class Thumbnail {
// unsigned char* getThumbnailImage (int &w, int &h, int fixwh=1); // fixwh = 0: fix w and calculate h, =1: fix h and calculate w // unsigned char* getThumbnailImage (int &w, int &h, int fixwh=1); // fixwh = 0: fix w and calculate h, =1: fix h and calculate w
rtengine::IImage8* processThumbImage (const rtengine::procparams::ProcParams& pparams, int h, double& scale); rtengine::IImage8* processThumbImage (const rtengine::procparams::ProcParams& pparams, int h, double& scale);
rtengine::IImage8* upgradeThumbImage (const rtengine::procparams::ProcParams& pparams, int h, double& scale); rtengine::IImage8* upgradeThumbImage (const rtengine::procparams::ProcParams& pparams, int h, double& scale);
void getThumbnailSize (int &w, int &h); void getThumbnailSize (int &w, int &h, const rtengine::procparams::ProcParams *pparams=NULL);
void getFinalSize (const rtengine::procparams::ProcParams& pparams, int& w, int& h); void getFinalSize (const rtengine::procparams::ProcParams& pparams, int& w, int& h);
const Glib::ustring& getExifString (); const Glib::ustring& getExifString ();