From 899d27fb3423604754620995cf3e0c689141baff Mon Sep 17 00:00:00 2001 From: Volker Lanz Date: Wed, 3 Mar 2010 18:58:14 +0000 Subject: [PATCH] introduce a define to disable threaded device scanning in case we don't find a workaround for the solid problem. svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=1098456 --- src/core/devicescanner.cpp | 5 +++++ src/core/devicescanner.h | 2 +- src/core/operationstack.cpp | 9 +++++++++ src/gui/mainwindow.cpp | 9 +++++++++ src/gui/partitionmanagerwidget.cpp | 2 ++ 5 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/core/devicescanner.cpp b/src/core/devicescanner.cpp index 809939d..146f5ca 100644 --- a/src/core/devicescanner.cpp +++ b/src/core/devicescanner.cpp @@ -44,6 +44,11 @@ void DeviceScanner::clear() } void DeviceScanner::run() +{ + scan(); +} + +void DeviceScanner::scan() { emit progress(QString(), 0); diff --git a/src/core/devicescanner.h b/src/core/devicescanner.h index f800e37..30b7342 100644 --- a/src/core/devicescanner.h +++ b/src/core/devicescanner.h @@ -39,13 +39,13 @@ class DeviceScanner : public QThread public: void clear(); /**< clear Devices and the OperationStack */ + void scan(); /**< do the actual scanning; blocks if called directly */ signals: void progress(const QString& device_node, int progress); protected: virtual void run(); - OperationStack& operationStack() { return m_OperationStack; } const OperationStack& operationStack() const { return m_OperationStack; } diff --git a/src/core/operationstack.cpp b/src/core/operationstack.cpp index 719c1b5..7f65607 100644 --- a/src/core/operationstack.cpp +++ b/src/core/operationstack.cpp @@ -428,7 +428,9 @@ void OperationStack::clearOperations() /** Clears the list of Devices. */ void OperationStack::clearDevices() { +#if defined(THREADED_DEVICE_SCANNER) QWriteLocker lockDevices(&lock()); +#endif qDeleteAll(previewDevices()); previewDevices().clear(); @@ -441,7 +443,9 @@ void OperationStack::clearDevices() */ Device* OperationStack::findDeviceForPartition(const Partition* p) { +#if defined(THREADED_DEVICE_SCANNER) QReadLocker lockDevices(&lock()); +#endif foreach (Device* d, previewDevices()) { @@ -469,7 +473,10 @@ void OperationStack::addDevice(Device* d) { Q_ASSERT(d); +#if defined(THREADED_DEVICE_SCANNER) QWriteLocker lockDevices(&lock()); +#endif + previewDevices().append(d); emit devicesChanged(); } @@ -481,7 +488,9 @@ static bool deviceLessThan(const Device* d1, const Device* d2) void OperationStack::sortDevices() { +#if defined(THREADED_DEVICE_SCANNER) QWriteLocker lockDevices(&lock()); +#endif qSort(previewDevices().begin(), previewDevices().end(), deviceLessThan); diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 3597b99..11a84c4 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -434,7 +434,9 @@ void MainWindow::on_m_OperationStack_operationsChanged() void MainWindow::on_m_OperationStack_devicesChanged() { +#if defined(THREADED_DEVICE_SCANNER) QReadLocker lockDevices(&operationStack().lock()); +#endif listDevices().updateDevices(operationStack().previewDevices()); @@ -543,10 +545,15 @@ void MainWindow::scanDevices() KApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); +#if defined(THREADED_DEVICE_SCANNER) scanProgressDialog().setEnabled(true); scanProgressDialog().show(); deviceScanner().start(); +#else + deviceScanner().scan(); + on_m_DeviceScanner_finished(); +#endif } void MainWindow::on_m_DeviceScanner_progress(const QString& device_node, int percent) @@ -557,7 +564,9 @@ void MainWindow::on_m_DeviceScanner_progress(const QString& device_node, int per void MainWindow::on_m_DeviceScanner_finished() { +#if defined(THREADED_DEVICE_SCANNER) QReadLocker lockDevices(&operationStack().lock()); +#endif if (!operationStack().previewDevices().isEmpty()) pmWidget().setSelectedDevice(operationStack().previewDevices()[0]); diff --git a/src/gui/partitionmanagerwidget.cpp b/src/gui/partitionmanagerwidget.cpp index 08296db..1774540 100644 --- a/src/gui/partitionmanagerwidget.cpp +++ b/src/gui/partitionmanagerwidget.cpp @@ -186,7 +186,9 @@ Partition* PartitionManagerWidget::selectedPartition() void PartitionManagerWidget::setSelectedDevice(const QString& device_node) { +#if defined(THREADED_DEVICE_SCANNER) QReadLocker lockDevices(&operationStack().lock()); +#endif foreach(Device* d, operationStack().previewDevices()) if (d->deviceNode() == device_node)