add assert and check if there is a selected partition

svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=1127769
This commit is contained in:
Volker Lanz 2010-05-17 15:49:46 +00:00
parent 438a325f29
commit 3eb9dc8b4a
1 changed files with 11 additions and 2 deletions

View File

@ -379,14 +379,23 @@ void PartitionManagerWidget::onPropertiesPartition()
void PartitionManagerWidget::onMountPartition()
{
Partition* p = selectedPartition();
Q_ASSERT(p);
if (p == NULL)
{
kWarning() << "no partition selected";
return;
}
Report report(NULL);
if (p && p->canMount())
if (p->canMount())
{
if (!p->mount(report))
KMessageBox::detailedSorry(this, i18nc("@info", "The file system on partition <filename>%1</filename> could not be mounted.", p->deviceNode()), QString("<pre>%1</pre>").arg(report.toText()), i18nc("@title:window", "Could Not Mount File System."));
}
else if (p && p->canUnmount())
else if (p->canUnmount())
{
if (!p->unmount(report))
KMessageBox::detailedSorry(this, i18nc("@info", "The file system on partition <filename>%1</filename> could not be unmounted.", p->deviceNode()), QString("<pre>%1</pre>").arg(report.toText()), i18nc("@title:window", "Could Not Unmount File System."));