diff options
author | Arno <arno@disconnect.de> | 2016-03-05 06:54:56 +0100 |
---|---|---|
committer | Arno <arno@disconnect.de> | 2016-03-05 06:54:56 +0100 |
commit | 59433fdbc15862c167490597546956894fec0a37 (patch) | |
tree | 2b1d33101b14c2b5314d2014fc20b11e404b86b9 /archivebrowser.cpp | |
parent | ded3712fb4f7e8d58ea7bc1fad084f5ec43a6f09 (diff) | |
download | SheMov-59433fdbc15862c167490597546956894fec0a37.tar.gz SheMov-59433fdbc15862c167490597546956894fec0a37.tar.bz2 SheMov-59433fdbc15862c167490597546956894fec0a37.zip |
Do not connect CopyWorker on every invokation
I connected the CopyWorker SIGNALS to the ArchiveBrowser SLOTS on every
copy. Of course that made the success dialogs pop up as many times as
there were copy operations.
Fix it by moving the connect call into the constructor.
Diffstat (limited to 'archivebrowser.cpp')
-rw-r--r-- | archivebrowser.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/archivebrowser.cpp b/archivebrowser.cpp index fbeb50d..1459dac 100644 --- a/archivebrowser.cpp +++ b/archivebrowser.cpp @@ -80,7 +80,9 @@ ArchiveBrowser::ArchiveBrowser(QWidget *parent) : QWidget(parent), mSelectedSize //copyworker mUSBProgress = 0; mCopyWorker = new CopyWorker(this); - + connect(mCopyWorker, SIGNAL(error(QString)), this, SLOT(copyError(QString))); + connect(mCopyWorker, SIGNAL(success(QString)), this, SLOT(copySuccess(QString))); + connect(mCopyWorker, SIGNAL(file(QString)), this, SLOT(setCopyFile(QString))); } void ArchiveBrowser::browserSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected) { @@ -213,9 +215,6 @@ void ArchiveBrowser::moveToUSB(){ } mUSBProgress = new QProgressDialog(this); connect(mCopyWorker, SIGNAL(bytesRead(int)), mUSBProgress, SLOT(setValue(int))); - connect(mCopyWorker, SIGNAL(error(QString)), this, SLOT(copyError(QString))); - connect(mCopyWorker, SIGNAL(success(QString)), this, SLOT(copySuccess(QString))); - connect(mCopyWorker, SIGNAL(file(QString)), this, SLOT(setCopyFile(QString))); mUSBProgress->setLabelText(tr("Copying files...")); mUSBProgress->setMinimum(0); mUSBProgress->setMaximum(mCopyWorker->max()); @@ -289,15 +288,19 @@ void ArchiveBrowser::resetAll() { void ArchiveBrowser::copyError(QString error){ mUSBProgress->hide(); QMessageBox::critical(this, tr("Copy Error"), error); - mUSBProgress->disconnect(); - mUSBProgress->deleteLater(); + mCopyWorker->disconnect(mUSBProgress); + QProgressDialog *old = mUSBProgress; + old->deleteLater(); + mUSBProgress = 0; } void ArchiveBrowser::copySuccess(QString success){ mUSBProgress->hide(); QMessageBox::information(this, tr("Copy Success"), success); - mUSBProgress->disconnect(); - mUSBProgress->deleteLater(); + mCopyWorker->disconnect(mUSBProgress); + QProgressDialog *old = mUSBProgress; + old->deleteLater(); + mUSBProgress = 0; QString msg = QString(tr("Delete source files and update database?")); int q = QMessageBox::question(this, tr("Question"), msg); if(q == QMessageBox::Yes){ |