* Some menu items were enabled for the completely wrong partitions, because
the BPartition pointer in _UpdateMenus() was toast after calling CancelModifications() on the disk. Most importantly, the Mount/Unmount items are now correctly enabled/disabled. And you can no longer initialize mounted partitions... * Added some debug output to help track down why BDiskDeviceRoster notifications don't work anymore. I am pretty sure those did work at one time. +alphabranch. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32872 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -229,7 +229,11 @@ MainWindow::MainWindow(BRect frame)
|
|||||||
fListView->SetSelectionMessage(new BMessage(MSG_PARTITION_ROW_SELECTED));
|
fListView->SetSelectionMessage(new BMessage(MSG_PARTITION_ROW_SELECTED));
|
||||||
fListView->SetTarget(this);
|
fListView->SetTarget(this);
|
||||||
|
|
||||||
BDiskDeviceRoster().StartWatching(this);
|
status_t ret = fDDRoster.StartWatching(BMessenger(this));
|
||||||
|
if (ret != B_OK) {
|
||||||
|
fprintf(stderr, "Failed to start watching for device changes: %s\n",
|
||||||
|
strerror(ret));
|
||||||
|
}
|
||||||
|
|
||||||
// visit all disks in the system and show their contents
|
// visit all disks in the system and show their contents
|
||||||
_ScanDrives();
|
_ScanDrives();
|
||||||
@@ -296,6 +300,7 @@ MainWindow::MessageReceived(BMessage* message)
|
|||||||
|
|
||||||
// TODO: this could probably be done better!
|
// TODO: this could probably be done better!
|
||||||
case B_DEVICE_UPDATE:
|
case B_DEVICE_UPDATE:
|
||||||
|
printf("B_DEVICE_UPDATE\n");
|
||||||
case MSG_RESCAN:
|
case MSG_RESCAN:
|
||||||
_ScanDrives();
|
_ScanDrives();
|
||||||
break;
|
break;
|
||||||
@@ -521,14 +526,14 @@ MainWindow::_UpdateMenus(BDiskDevice* disk,
|
|||||||
if (parentPartition && parentPartition->ContainsPartitioningSystem())
|
if (parentPartition && parentPartition->ContainsPartitioningSystem())
|
||||||
fCreateMI->SetEnabled(true);
|
fCreateMI->SetEnabled(true);
|
||||||
|
|
||||||
BPartition* partition = disk->FindDescendant(selectedPartition);
|
|
||||||
if (partition == NULL)
|
|
||||||
partition = disk;
|
|
||||||
|
|
||||||
bool prepared = disk->PrepareModifications() == B_OK;
|
bool prepared = disk->PrepareModifications() == B_OK;
|
||||||
fInitMenu->SetEnabled(prepared);
|
fInitMenu->SetEnabled(prepared);
|
||||||
fDeleteMI->SetEnabled(prepared);
|
fDeleteMI->SetEnabled(prepared);
|
||||||
|
|
||||||
|
BPartition* partition = disk->FindDescendant(selectedPartition);
|
||||||
|
if (partition == NULL)
|
||||||
|
partition = disk;
|
||||||
|
|
||||||
BDiskSystem diskSystem;
|
BDiskSystem diskSystem;
|
||||||
fDDRoster.RewindDiskSystems();
|
fDDRoster.RewindDiskSystems();
|
||||||
while (fDDRoster.GetNextDiskSystem(&diskSystem) == B_OK) {
|
while (fDDRoster.GetNextDiskSystem(&diskSystem) == B_OK) {
|
||||||
@@ -555,9 +560,6 @@ MainWindow::_UpdateMenus(BDiskDevice* disk,
|
|||||||
fInitMenu->AddItem(item);
|
fInitMenu->AddItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prepared)
|
|
||||||
disk->CancelModifications();
|
|
||||||
|
|
||||||
// Mount items
|
// Mount items
|
||||||
if (partition) {
|
if (partition) {
|
||||||
fInitMenu->SetEnabled(!partition->IsMounted()
|
fInitMenu->SetEnabled(!partition->IsMounted()
|
||||||
@@ -587,6 +589,10 @@ MainWindow::_UpdateMenus(BDiskDevice* disk,
|
|||||||
fMountMI->SetEnabled(false);
|
fMountMI->SetEnabled(false);
|
||||||
fUnmountMI->SetEnabled(false);
|
fUnmountMI->SetEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (prepared)
|
||||||
|
disk->CancelModifications();
|
||||||
|
|
||||||
fMountAllMI->SetEnabled(true);
|
fMountAllMI->SetEnabled(true);
|
||||||
}
|
}
|
||||||
if (selectedPartition < 0) {
|
if (selectedPartition < 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user