Author: bonefish Date: 2011-06-13 02:00:20 +0200 (Mon, 13 Jun 2011) New Revision: 42135 Changeset: https://dev.haiku-os.org/changeset/42135 Modified: haiku/trunk/src/apps/drivesetup/MainWindow.cpp Log: 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. Modified: haiku/trunk/src/apps/drivesetup/MainWindow.cpp =================================================================== --- haiku/trunk/src/apps/drivesetup/MainWindow.cpp 2011-06-12 23:31:57 UTC (rev 42134) +++ haiku/trunk/src/apps/drivesetup/MainWindow.cpp 2011-06-13 00:00:20 UTC (rev 42135) @@ -534,8 +534,10 @@ // 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 @@ fDeleteMI->SetEnabled(prepared); BPartition* partition = disk->FindDescendant(selectedPartition); - if (partition == NULL) - partition = disk; BDiskSystem diskSystem; fDDRoster.RewindDiskSystems(); @@ -569,20 +569,17 @@ 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 @@ } else { fDeleteMI->SetEnabled(false); fMountMI->SetEnabled(false); + fInitMenu->SetEnabled(false); } if (prepared)