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
This commit is contained in:
Volker Lanz 2010-03-03 18:58:14 +00:00
parent 532d84f6e5
commit 899d27fb34
5 changed files with 26 additions and 1 deletions

View File

@ -44,6 +44,11 @@ void DeviceScanner::clear()
} }
void DeviceScanner::run() void DeviceScanner::run()
{
scan();
}
void DeviceScanner::scan()
{ {
emit progress(QString(), 0); emit progress(QString(), 0);

View File

@ -39,13 +39,13 @@ class DeviceScanner : public QThread
public: public:
void clear(); /**< clear Devices and the OperationStack */ void clear(); /**< clear Devices and the OperationStack */
void scan(); /**< do the actual scanning; blocks if called directly */
signals: signals:
void progress(const QString& device_node, int progress); void progress(const QString& device_node, int progress);
protected: protected:
virtual void run(); virtual void run();
OperationStack& operationStack() { return m_OperationStack; } OperationStack& operationStack() { return m_OperationStack; }
const OperationStack& operationStack() const { return m_OperationStack; } const OperationStack& operationStack() const { return m_OperationStack; }

View File

@ -428,7 +428,9 @@ void OperationStack::clearOperations()
/** Clears the list of Devices. */ /** Clears the list of Devices. */
void OperationStack::clearDevices() void OperationStack::clearDevices()
{ {
#if defined(THREADED_DEVICE_SCANNER)
QWriteLocker lockDevices(&lock()); QWriteLocker lockDevices(&lock());
#endif
qDeleteAll(previewDevices()); qDeleteAll(previewDevices());
previewDevices().clear(); previewDevices().clear();
@ -441,7 +443,9 @@ void OperationStack::clearDevices()
*/ */
Device* OperationStack::findDeviceForPartition(const Partition* p) Device* OperationStack::findDeviceForPartition(const Partition* p)
{ {
#if defined(THREADED_DEVICE_SCANNER)
QReadLocker lockDevices(&lock()); QReadLocker lockDevices(&lock());
#endif
foreach (Device* d, previewDevices()) foreach (Device* d, previewDevices())
{ {
@ -469,7 +473,10 @@ void OperationStack::addDevice(Device* d)
{ {
Q_ASSERT(d); Q_ASSERT(d);
#if defined(THREADED_DEVICE_SCANNER)
QWriteLocker lockDevices(&lock()); QWriteLocker lockDevices(&lock());
#endif
previewDevices().append(d); previewDevices().append(d);
emit devicesChanged(); emit devicesChanged();
} }
@ -481,7 +488,9 @@ static bool deviceLessThan(const Device* d1, const Device* d2)
void OperationStack::sortDevices() void OperationStack::sortDevices()
{ {
#if defined(THREADED_DEVICE_SCANNER)
QWriteLocker lockDevices(&lock()); QWriteLocker lockDevices(&lock());
#endif
qSort(previewDevices().begin(), previewDevices().end(), deviceLessThan); qSort(previewDevices().begin(), previewDevices().end(), deviceLessThan);

View File

@ -434,7 +434,9 @@ void MainWindow::on_m_OperationStack_operationsChanged()
void MainWindow::on_m_OperationStack_devicesChanged() void MainWindow::on_m_OperationStack_devicesChanged()
{ {
#if defined(THREADED_DEVICE_SCANNER)
QReadLocker lockDevices(&operationStack().lock()); QReadLocker lockDevices(&operationStack().lock());
#endif
listDevices().updateDevices(operationStack().previewDevices()); listDevices().updateDevices(operationStack().previewDevices());
@ -543,10 +545,15 @@ void MainWindow::scanDevices()
KApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); KApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
#if defined(THREADED_DEVICE_SCANNER)
scanProgressDialog().setEnabled(true); scanProgressDialog().setEnabled(true);
scanProgressDialog().show(); scanProgressDialog().show();
deviceScanner().start(); deviceScanner().start();
#else
deviceScanner().scan();
on_m_DeviceScanner_finished();
#endif
} }
void MainWindow::on_m_DeviceScanner_progress(const QString& device_node, int percent) 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() void MainWindow::on_m_DeviceScanner_finished()
{ {
#if defined(THREADED_DEVICE_SCANNER)
QReadLocker lockDevices(&operationStack().lock()); QReadLocker lockDevices(&operationStack().lock());
#endif
if (!operationStack().previewDevices().isEmpty()) if (!operationStack().previewDevices().isEmpty())
pmWidget().setSelectedDevice(operationStack().previewDevices()[0]); pmWidget().setSelectedDevice(operationStack().previewDevices()[0]);

View File

@ -186,7 +186,9 @@ Partition* PartitionManagerWidget::selectedPartition()
void PartitionManagerWidget::setSelectedDevice(const QString& device_node) void PartitionManagerWidget::setSelectedDevice(const QString& device_node)
{ {
#if defined(THREADED_DEVICE_SCANNER)
QReadLocker lockDevices(&operationStack().lock()); QReadLocker lockDevices(&operationStack().lock());
#endif
foreach(Device* d, operationStack().previewDevices()) foreach(Device* d, operationStack().previewDevices())
if (d->deviceNode() == device_node) if (d->deviceNode() == device_node)