Commit 29ae7797 authored by Alexander Stippich's avatar Alexander Stippich
Browse files

cleanup shut down

parent 8e88c2b8
......@@ -262,10 +262,7 @@ KSaneWidget::KSaneWidget(QWidget *parent)
KSaneWidget::~KSaneWidget()
{
while (!closeDevice()) {
usleep(100);
}
// wait for any thread to exit
closeDevice();
s_objectMutex->lock();
s_objectCount--;
......@@ -585,15 +582,21 @@ bool KSaneWidget::closeDevice()
if (d->m_scanThread->isRunning()) {
d->m_scanThread->cancelScan();
d->m_closeDevicePending = true;
return false;
}
disconnect(d->m_scanThread);
if (d->m_scanThread->isRunning()) {
connect(d->m_scanThread, &QThread::finished, d->m_scanThread, &QThread::deleteLater);
}
if (d->m_scanThread->isFinished()) {
d->m_scanThread->deleteLater();
}
d->m_scanThread = nullptr;
d->m_auth->clearDeviceAuth(d->m_devName);
// else
d->clearDeviceOptions();
sane_close(d->m_saneHandle);
d->m_saneHandle = nullptr;
d->clearDeviceOptions();
// disable the interface until a new device is opened.
d->m_optsTabWidget->setDisabled(true);
......
......@@ -124,7 +124,6 @@ void KSaneWidgetPrivate::clearDeviceOptions()
m_optPreview = nullptr;
m_optWaitForBtn = nullptr;
m_scanOngoing = false;
m_closeDevicePending = false;
// delete all the options in the list.
while (!m_optionsList.isEmpty()) {
......@@ -144,9 +143,6 @@ void KSaneWidgetPrivate::clearDeviceOptions()
delete m_otherOptsTab;
m_otherOptsTab = nullptr;
delete m_scanThread;
m_scanThread = nullptr;
m_devName.clear();
m_model.clear();
m_vendor.clear();
......@@ -1019,15 +1015,6 @@ void KSaneWidgetPrivate::previewScanDone()
{
// even if the scan is finished successfully we need to call sane_cancel()
sane_cancel(m_saneHandle);
if (m_closeDevicePending) {
setBusy(false);
sane_close(m_saneHandle);
m_saneHandle = nullptr;
clearDeviceOptions();
Q_EMIT q->scanDone(KSaneWidget::NoError, QString());
return;
}
// restore the original settings of the changed parameters
if (m_optDepth != nullptr) {
......@@ -1125,13 +1112,6 @@ void KSaneWidgetPrivate::scanDone()
void KSaneWidgetPrivate::oneFinalScanDone()
{
if (m_closeDevicePending) {
setBusy(false);
sane_close(m_saneHandle);
m_saneHandle = nullptr;
clearDeviceOptions();
return;
}
if (m_scanThread->frameStatus() == KSaneScanThread::ReadReady) {
// scan finished OK
......
......@@ -183,7 +183,6 @@ public:
int m_selIndex;
bool m_scanOngoing;
bool m_closeDevicePending;
bool m_cancelMultiScan = false;
// option handling
......
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