Commit 4abf4766 authored by Andi Clemens's avatar Andi Clemens
Browse files

Do not start a tool immediately in the constructor. This will lead to race conditions.

Also we try to connect signals to tools AFTER they started doing their job. This will not work for tasks that close immediately, e.g. "Scan for new items" on a very small collection. In this case the signal becomes connected AFTER the tool is done, therefore never executing the assigned slot. There are still some race conditions left, I need to check them, but for now the main issue in this bug report should be solved.

CCBUG: 297614
parent 14f48a68
......@@ -206,7 +206,8 @@ void AlbumSelectionTreeView::slotRebuildThumbs()
return;
}
new ThumbsGenerator(true, album->id());
ThumbsGenerator* tool = new ThumbsGenerator(true, album->id());
tool->start();
}
bool AlbumSelectionTreeView::viewportEvent(QEvent* event)
......
......@@ -292,7 +292,8 @@ DigikamApp::DigikamApp()
setAutoSaveSettings("General Settings", true);
// Now, enable finished the collection scan as deferred process
new NewItemsFinder(NewItemsFinder::ScanDeferredFiles);
NewItemsFinder* tool = new NewItemsFinder(NewItemsFinder::ScanDeferredFiles);
tool->start();
LoadSaveThread::setInfoProvider(new DatabaseLoadSaveFileInfoProvider);
}
......@@ -2596,7 +2597,8 @@ void DigikamApp::slotMaintenanceDone()
void DigikamApp::slotRebuildAlbumThumbnails()
{
new ThumbsGenerator(true, AlbumManager::instance()->currentAlbum()->id());
ThumbsGenerator* tool = new ThumbsGenerator(true, AlbumManager::instance()->currentAlbum()->id());
tool->start();
}
void DigikamApp::slotRecurseAlbums(bool checked)
......
......@@ -1224,7 +1224,8 @@ void PeopleSideBarWidget::slotScanForFaces()
if (dialog.exec() == QDialog::Accepted)
{
new FaceDetector(dialog.settings());
FaceDetector* tool = new FaceDetector(dialog.settings());
tool->start();
}
}
......
......@@ -840,7 +840,8 @@ void CameraUI::finishDialog()
d->statusProgressBar->progressBarMode(StatusProgressBar::TextMode,
i18n("Scanning for new files, please wait..."));
new NewItemsFinder(NewItemsFinder::ScheduleCollectionScan, d->foldersToScan.toList());
NewItemsFinder* tool = new NewItemsFinder(NewItemsFinder::ScheduleCollectionScan, d->foldersToScan.toList());
tool->start();
d->foldersToScan.clear();
......
......@@ -440,6 +440,8 @@ void FindDuplicatesView::slotFindDuplicates()
connect(finder, SIGNAL(signalComplete()),
this, SLOT(slotComplete()));
finder->start();
}
void FindDuplicatesView::slotComplete()
......@@ -560,7 +562,8 @@ void FindDuplicatesView::resetAlbumsAndTags()
void FindDuplicatesView::slotUpdateFingerPrints()
{
new FingerPrintsGenerator(false);
FingerPrintsGenerator* tool = new FingerPrintsGenerator(false);
tool->start();
}
} // namespace Digikam
......@@ -615,7 +615,8 @@ void FuzzySearchView::setActive(bool val)
if (result == KMessageBox::Yes)
{
new FingerPrintsGenerator(true);
FingerPrintsGenerator* tool = new FingerPrintsGenerator(true);
tool->start();
}
}
......
......@@ -69,8 +69,6 @@ DuplicatesFinder::DuplicatesFinder(const QStringList& albumsIdList, const QStrin
d->similarity = similarity;
d->albumsIdList = albumsIdList;
d->tagsIdList = tagsIdList;
QTimer::singleShot(500, this, SLOT(slotStart()));
}
DuplicatesFinder::DuplicatesFinder(int similarity, ProgressItem* parent)
......@@ -82,8 +80,6 @@ DuplicatesFinder::DuplicatesFinder(int similarity, ProgressItem* parent)
QStringList albumsIdList;
foreach(Album* a, palbumList)
d->albumsIdList << QString::number(a->id());
QTimer::singleShot(500, this, SLOT(slotStart()));
}
DuplicatesFinder::~DuplicatesFinder()
......
......@@ -215,11 +215,6 @@ FaceDetector::FaceDetector(const FaceScanSettings& settings, ProgressItem* paren
{
d->albumTodoList = settings.albums;
}
if (ProgressManager::addProgressItem(this))
{
QTimer::singleShot(500, this, SLOT(slotStart()));
}
}
FaceDetector::~FaceDetector()
......
......@@ -84,8 +84,6 @@ FingerPrintsGenerator::FingerPrintsGenerator(bool rebuildAll, ProgressItem* pare
this, SLOT(slotGotImagePreview(LoadingDescription,DImg)));
setLabel(i18n("Finger-prints"));
QTimer::singleShot(500, this, SLOT(slotStart()));
}
FingerPrintsGenerator::~FingerPrintsGenerator()
......@@ -128,6 +126,13 @@ void FingerPrintsGenerator::processOne()
{
if (canceled())
{
slotCancel();
return;
}
if (d->allPicturesPath.isEmpty())
{
slotDone();
return;
}
......
......@@ -109,6 +109,8 @@ void MaintenanceMngr::slotStage1()
connect(tool, SIGNAL(progressItemCanceled(const QString&)),
this, SLOT(slotCancel()));
tool->start();
}
else
{
......@@ -129,6 +131,8 @@ void MaintenanceMngr::slotStage2()
connect(tool, SIGNAL(progressItemCanceled(const QString&)),
this, SLOT(slotCancel()));
tool->start();
}
else
{
......@@ -149,6 +153,8 @@ void MaintenanceMngr::slotStage3()
connect(tool, SIGNAL(progressItemCanceled(const QString&)),
this, SLOT(slotCancel()));
tool->start();
}
else
{
......@@ -168,6 +174,8 @@ void MaintenanceMngr::slotStage4()
connect(tool, SIGNAL(progressItemCanceled(const QString&)),
this, SLOT(slotCancel()));
tool->start();
}
else
{
......@@ -187,6 +195,8 @@ void MaintenanceMngr::slotStage5()
connect(tool, SIGNAL(progressItemCanceled(const QString&)),
this, SLOT(slotCancel()));
tool->start();
}
else
{
......@@ -206,6 +216,8 @@ void MaintenanceMngr::slotStage6()
connect(tool, SIGNAL(progressItemCanceled(const QString&)),
this, SLOT(slotCancel()));
tool->start();
}
else
{
......
......@@ -71,6 +71,11 @@ void MaintenanceTool::setNotificationEnabled(bool b)
d->notification = b;
}
void MaintenanceTool::start()
{
slotStart();
}
void MaintenanceTool::slotStart()
{
d->duration.start();
......
......@@ -49,6 +49,8 @@ public:
*/
void setNotificationEnabled(bool b);
void start();
Q_SIGNALS:
/** Emit when process is done (not canceled).
......
......@@ -77,8 +77,6 @@ MetadataSynchronizer::MetadataSynchronizer(SyncDirection direction, ProgressItem
{
d->palbumList = AlbumManager::instance()->allPAlbums();
d->direction = direction;
QTimer::singleShot(500, this, SLOT(slotStart()));
}
MetadataSynchronizer::MetadataSynchronizer(Album* album, SyncDirection direction, ProgressItem* parent)
......@@ -87,8 +85,6 @@ MetadataSynchronizer::MetadataSynchronizer(Album* album, SyncDirection direction
{
d->palbumList.append(album);
d->direction = direction;
QTimer::singleShot(500, this, SLOT(slotStart()));
}
MetadataSynchronizer::MetadataSynchronizer(const ImageInfoList& list, SyncDirection direction, ProgressItem* parent)
......@@ -97,8 +93,6 @@ MetadataSynchronizer::MetadataSynchronizer(const ImageInfoList& list, SyncDirect
{
d->imageInfoList = list;
d->direction = direction;
QTimer::singleShot(500, this, SLOT(slotStart()));
}
// Common methods ----------------------------------------------------------------------------
......
......@@ -70,8 +70,6 @@ NewItemsFinder::NewItemsFinder(FinderMode mode, const QStringList& foldersToScan
d->mode = mode;
d->foldersToScan = foldersToScan;
QTimer::singleShot(500, this, SLOT(slotStart()));
}
NewItemsFinder::~NewItemsFinder()
......
......@@ -88,8 +88,6 @@ ThumbsGenerator::ThumbsGenerator(bool rebuildAll, int albumId, ProgressItem* par
this, SLOT(slotGotThumbnail(LoadingDescription, QPixmap)));
setLabel(i18n("Thumbs"));
QTimer::singleShot(500, this, SLOT(slotStart()));
}
ThumbsGenerator::~ThumbsGenerator()
......@@ -195,21 +193,13 @@ void ThumbsGenerator::processOne()
void ThumbsGenerator::slotGotThumbnail(const LoadingDescription& desc, const QPixmap& pix)
{
if (canceled())
{
slotCancel();
return;
}
if (d->allPicturesPath.isEmpty())
{
slotDone();
return;
}
if (d->allPicturesPath.first() != desc.filePath)
{
slotCancel();
return;
}
......
......@@ -493,7 +493,8 @@ void SetupCollectionModel::apply()
// Trigger collection scan
if (!newItems.isEmpty() || !deletedItems.isEmpty())
{
new NewItemsFinder();
NewItemsFinder* tool = new NewItemsFinder();
tool->start();
}
}
......
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