From e24bd9f61bc4d64d89e66c200645e8caaf6c1427 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 30 May 2010 14:34:43 +0400 Subject: [PATCH] Fix catching LibParted exeptions --- src/libparted.cpp | 1 - src/pagepartitioning.cpp | 29 ++++++++++++++++++++++------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/libparted.cpp b/src/libparted.cpp index 0a4a980..4bf8096 100644 --- a/src/libparted.cpp +++ b/src/libparted.cpp @@ -58,7 +58,6 @@ QList LibParted::getPartitionList(const QString& path) throw(LibP { QList PartInfo; - if ( m_DeviceList.find(path) == m_DeviceList.end() ) throw LibPartedError(); diff --git a/src/pagepartitioning.cpp b/src/pagepartitioning.cpp index 7354b5c..c5e886d 100644 --- a/src/pagepartitioning.cpp +++ b/src/pagepartitioning.cpp @@ -97,11 +97,9 @@ void PagePartitioning::show() qDebug() << "parted version: " << libParted->getVersion(); - QStringList disks; - try { - disks = libParted->getDevices(); - } - catch(LibPartedError e) + QStringList disks = libParted->getDevices(); + + if ( disks.isEmpty() ) { qDebug() << "disk not found"; QMessageBox::critical(m_Widget, tr("Error"), tr("Disks not found")); @@ -117,14 +115,24 @@ void PagePartitioning::show() } catch(LibPartedError e) { - qDebug() << QString("partitions not found on disk %1").arg(dev); + qDebug() << QString("Cannot read disk info from %1").arg(dev); continue; } QString disk_info = QString("%1 %2 %3").arg(dev, 10).arg(dev_info.size, 10).arg(dev_info.model, 25); m_Disks->addItem(disk_info, QVariant(dev)); - QList part_list = libParted->getPartitionList(dev); + QList part_list; + + try { + part_list = libParted->getPartitionList(dev); + } + catch(LibPartedError e) + { + qDebug() << QString("Cannot read partition table from %1").arg(dev); + continue; + } + QList partitions; PartitionDesc part_desc; @@ -142,6 +150,13 @@ void PagePartitioning::show() m_Disks->setCurrentIndex(0); updatePartitions(0); } + + if ( m_Disks->count() == 0 ) + { + qDebug() << "disk not found"; + QMessageBox::critical(m_Widget, tr("Error"), tr("Disks not found")); + emit changeNext(false); + } } void PagePartitioning::updatePartitions(int num)