From 6436e4676f2f43a9773fba8e521f0719d8a60f8a Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Mon, 13 Jun 2011 00:00:20 +0000 Subject: [PATCH] MainWindow::_UpdateMenus(): * Don't fall back to the disk device, if no partition was selected. No idea why that was done. It led to operations (like initialize) being enabled that would fail, if invoked. * Don't check CanInitialize() on the selected partition with its current disk system to determine whether to enable the initialization menu. No idea why that was done either. It led to the menu being disabled, when there was no reason for it. * Also disable the initialization menu when no partition is selected. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42135 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/drivesetup/MainWindow.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/apps/drivesetup/MainWindow.cpp b/src/apps/drivesetup/MainWindow.cpp index 5325fe60c5..e9694d3d52 100644 --- a/src/apps/drivesetup/MainWindow.cpp +++ b/src/apps/drivesetup/MainWindow.cpp @@ -534,8 +534,10 @@ MainWindow::_UpdateMenus(BDiskDevice* disk, // Create menu and items BPartition* parentPartition = NULL; - if (selectedPartition <= -2) + if (selectedPartition <= -2) { + // a partitionable space item is selected parentPartition = disk->FindDescendant(parentID); + } if (parentPartition && parentPartition->ContainsPartitioningSystem()) fCreateMI->SetEnabled(true); @@ -545,8 +547,6 @@ MainWindow::_UpdateMenus(BDiskDevice* disk, fDeleteMI->SetEnabled(prepared); BPartition* partition = disk->FindDescendant(selectedPartition); - if (partition == NULL) - partition = disk; BDiskSystem diskSystem; fDDRoster.RewindDiskSystems(); @@ -569,20 +569,17 @@ MainWindow::_UpdateMenus(BDiskDevice* disk, BMenuItem* item = new BMenuItem(label.String(), message); // TODO: Very unintuitive that we have to use the pretty name here! -// item->SetEnabled(partition->CanInitialize(diskSystem.Name())); - item->SetEnabled(partition->CanInitialize(diskSystem.PrettyName())); + item->SetEnabled(partition != NULL +// && partition->CanInitialize(diskSystem.Name())); + && partition->CanInitialize(diskSystem.PrettyName())); fInitMenu->AddItem(item); } // Mount items if (partition) { - BDiskSystem partitionDiskSystem; - partition->GetDiskSystem(&partitionDiskSystem); fInitMenu->SetEnabled(!partition->IsMounted() && !partition->IsReadOnly() - && partition->Device()->HasMedia() - // Check if the current disk system allows initialzation. - && partition->CanInitialize(partitionDiskSystem.PrettyName())); + && partition->Device()->HasMedia()); fDeleteMI->SetEnabled(!partition->IsMounted() && !partition->IsDevice()); @@ -604,6 +601,7 @@ MainWindow::_UpdateMenus(BDiskDevice* disk, } else { fDeleteMI->SetEnabled(false); fMountMI->SetEnabled(false); + fInitMenu->SetEnabled(false); } if (prepared)