Commit 6478053c authored by Maik Qualmann's avatar Maik Qualmann

further changes to the preview loader

CCBUGS: 427333
parent 045b5b84
......@@ -180,8 +180,6 @@ void SharedLoadingTask::execute()
}
}
bool loadingImage = false;
if (continueQuery() && m_img.isNull())
{
// find possible running loading process
......@@ -225,12 +223,13 @@ void SharedLoadingTask::execute()
// m_img is now set to the result
}
else
}
if (continueQuery() && m_img.isNull())
{
{
LoadingCache::CacheLock lock(cache);
loadingImage = true;
// Neither in cache, nor currently loading in different thread.
// Load it here and now, add this LoadingProcess to cache list.
......@@ -241,61 +240,55 @@ void SharedLoadingTask::execute()
cache->notifyNewLoadingProcess(this, m_loadingDescription);
}
}
if (loadingImage || (continueQuery() && m_img.isNull()))
{
// load image
m_img = DImg(m_loadingDescription.filePath, this, m_loadingDescription.rawDecodingSettings);
if (loadingImage || continueQuery())
{
LoadingCache::CacheLock lock(cache);
// remove this from the list of loading processes in cache
cache->removeLoadingProcess(this);
if (!m_img.isNull())
{
LoadingCache::CacheLock lock(cache);
// put valid image into cache of loaded images
// remove this from the list of loading processes in cache
cache->putImage(m_loadingDescription.cacheKey(), m_img,
m_loadingDescription.filePath);
cache->removeLoadingProcess(this);
// dispatch image to all listeners
if (!m_img.isNull())
for (int i = 0 ; i < m_listeners.count() ; ++i)
{
// put valid image into cache of loaded images
cache->putImage(m_loadingDescription.cacheKey(), m_img,
m_loadingDescription.filePath);
LoadingProcessListener* const l = m_listeners.at(i);
// dispatch image to all listeners
if (l->accessMode() == LoadSaveThread::AccessModeReadWrite)
{
// If a listener requested ReadWrite access, it gets a deep copy.
// DImg is explicitly shared.
for (int i = 0 ; i < m_listeners.count() ; ++i)
l->setResult(m_loadingDescription, m_img.copy());
}
else
{
LoadingProcessListener* const l = m_listeners.at(i);
if (l->accessMode() == LoadSaveThread::AccessModeReadWrite)
{
// If a listener requested ReadWrite access, it gets a deep copy.
// DImg is explicitly shared.
l->setResult(m_loadingDescription, m_img.copy());
}
else
{
l->setResult(m_loadingDescription, m_img);
}
l->setResult(m_loadingDescription, m_img);
}
}
}
// indicate that loading has finished so that listeners can stop waiting
// indicate that loading has finished so that listeners can stop waiting
m_completed = true;
}
m_completed = true;
}
// wait until all listeners have removed themselves
// wait until all listeners have removed themselves
while (m_listeners.count() != 0)
{
QThread::msleep(10);
}
while (m_listeners.count() != 0)
{
QThread::msleep(10);
}
}
......
......@@ -108,8 +108,6 @@ void PreviewLoadingTask::execute()
}
}
bool loadingImage = false;
if (continueQuery() && m_img.isNull())
{
// find possible running loading process
......@@ -153,12 +151,13 @@ void PreviewLoadingTask::execute()
// m_img is now set to the result
}
else
}
if (continueQuery() && m_img.isNull())
{
{
LoadingCache::CacheLock lock(cache);
loadingImage = true;
// Neither in cache, nor currently loading in different thread.
// Load it here and now, add this LoadingProcess to cache list.
......@@ -169,10 +168,7 @@ void PreviewLoadingTask::execute()
cache->notifyNewLoadingProcess(this, m_loadingDescription);
}
}
if (loadingImage || (continueQuery() && m_img.isNull()))
{
// Preview is not in cache, we will load image from file.
DImg::FORMAT format = DImg::fileFormat(m_loadingDescription.filePath);
......@@ -184,7 +180,7 @@ void PreviewLoadingTask::execute()
// Check original image size using Exiv2.
QSize originalSize = previews.originalSize();
QSize originalSize = previews.originalSize();
// If not valid, get original size from LibRaw
......@@ -321,58 +317,55 @@ void PreviewLoadingTask::execute()
}
}
if (loadingImage || continueQuery())
if (!m_img.isNull() && MetaEngineSettings::instance()->settings().exifRotate)
{
if (!m_img.isNull() && MetaEngineSettings::instance()->settings().exifRotate)
{
m_img.exifRotate(m_loadingDescription.filePath);
}
m_img.exifRotate(m_loadingDescription.filePath);
}
{
LoadingCache::CacheLock lock(cache);
{
LoadingCache::CacheLock lock(cache);
// remove this from the list of loading processes in cache
// remove this from the list of loading processes in cache
cache->removeLoadingProcess(this);
cache->removeLoadingProcess(this);
if (!m_img.isNull())
{
// put valid image into cache of loaded images
if (!m_img.isNull())
{
// put valid image into cache of loaded images
cache->putImage(m_loadingDescription.cacheKey(), m_img,
m_loadingDescription.filePath);
cache->putImage(m_loadingDescription.cacheKey(), m_img,
m_loadingDescription.filePath);
// dispatch image to all listeners
// dispatch image to all listeners
for (int i = 0 ; i < m_listeners.count() ; ++i)
{
LoadingProcessListener* const l = m_listeners.at(i);
for (int i = 0 ; i < m_listeners.count() ; ++i)
{
LoadingProcessListener* const l = m_listeners.at(i);
if (l->accessMode() == LoadSaveThread::AccessModeReadWrite)
{
// If a listener requested ReadWrite access, it gets a deep copy.
// DImg is explicitly shared.
if (l->accessMode() == LoadSaveThread::AccessModeReadWrite)
{
// If a listener requested ReadWrite access, it gets a deep copy.
// DImg is explicitly shared.
l->setResult(m_loadingDescription, m_img.copy());
}
else
{
l->setResult(m_loadingDescription, m_img);
}
l->setResult(m_loadingDescription, m_img.copy());
}
else
{
l->setResult(m_loadingDescription, m_img);
}
}
}
// indicate that loading has finished so that listeners can stop waiting
// indicate that loading has finished so that listeners can stop waiting
m_completed = true;
}
m_completed = true;
}
// wait until all listeners have removed themselves
// wait until all listeners have removed themselves
while (m_listeners.count() != 0)
{
QThread::msleep(10);
}
while (m_listeners.count() != 0)
{
QThread::msleep(10);
}
}
......
......@@ -115,8 +115,6 @@ void ThumbnailLoadingTask::execute()
}
}
bool loadingImage = false;
if (continueQuery() && m_qimage.isNull())
{
// find possible running loading process
......@@ -155,12 +153,13 @@ void ThumbnailLoadingTask::execute()
// m_qimage is now set to the result
}
else
}
if (continueQuery() && m_qimage.isNull())
{
{
LoadingCache::CacheLock lock(cache);
loadingImage = true;
// Neither in cache, nor currently loading in different thread.
// Load it here and now, add this LoadingProcess to cache list.
......@@ -171,10 +170,7 @@ void ThumbnailLoadingTask::execute()
cache->notifyNewLoadingProcess(this, m_loadingDescription);
}
}
if (loadingImage || (continueQuery() && m_qimage.isNull()))
{
// Load or create thumbnail
setupCreator();
......@@ -200,46 +196,43 @@ void ThumbnailLoadingTask::execute()
}
}
if (loadingImage || continueQuery())
{
{
LoadingCache::CacheLock lock(cache);
LoadingCache::CacheLock lock(cache);
// remove this from the list of loading processes in cache
// remove this from the list of loading processes in cache
cache->removeLoadingProcess(this);
cache->removeLoadingProcess(this);
if (!m_qimage.isNull())
{
// put valid image into cache of loaded images
if (!m_qimage.isNull())
{
// put valid image into cache of loaded images
cache->putThumbnail(m_loadingDescription.cacheKey(), m_qimage,
m_loadingDescription.filePath);
cache->putThumbnail(m_loadingDescription.cacheKey(), m_qimage,
m_loadingDescription.filePath);
// dispatch image to all listeners
// dispatch image to all listeners
for (int i = 0 ; i < m_listeners.count() ; ++i)
{
ThumbnailLoadingTask* const task = dynamic_cast<ThumbnailLoadingTask*>(m_listeners.at(i));
for (int i = 0 ; i < m_listeners.count() ; ++i)
{
ThumbnailLoadingTask* const task = dynamic_cast<ThumbnailLoadingTask*>(m_listeners.at(i));
if (task)
{
task->setThumbResult(m_loadingDescription, m_qimage);
}
if (task)
{
task->setThumbResult(m_loadingDescription, m_qimage);
}
}
}
// indicate that loading has finished so that listeners can stop waiting
// indicate that loading has finished so that listeners can stop waiting
m_completed = true;
}
m_completed = true;
}
// wait until all listeners have removed themselves
// wait until all listeners have removed themselves
while (m_listeners.count() != 0)
{
QThread::msleep(10);
}
while (m_listeners.count() != 0)
{
QThread::msleep(10);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment