DriveSetup: Removed (some) knowledge about initialization.
* Instead of guessing whether or not to show the InitParamsPanel, the panel will now no longer show itself if the disk system does not have an editor, and silently succeed. * This also fixed a potential crash if the editor could not be created for some reason. * Minor cleanup.
This commit is contained in:
parent
856f538b79
commit
8317edb350
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2008-2010 Haiku Inc. All rights reserved.
|
||||
* Copyright 2008-2013 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Authors:
|
||||
|
@ -104,15 +104,16 @@ InitParamsPanel::InitParamsPanel(BWindow* window, const BString& diskSystem,
|
|||
// put the add-on
|
||||
manager->PutAddOn(addOn);
|
||||
|
||||
status_t err = addOn->GetParameterEditor(B_INITIALIZE_PARAMETER_EDITOR, &fEditor);
|
||||
if (err != B_OK) {
|
||||
status_t err = addOn->GetParameterEditor(B_INITIALIZE_PARAMETER_EDITOR,
|
||||
&fEditor);
|
||||
if (err != B_OK)
|
||||
fEditor = NULL;
|
||||
}
|
||||
} else {
|
||||
fEditor = NULL;
|
||||
}
|
||||
if (fEditor == NULL)
|
||||
return;
|
||||
|
||||
// TODO: fEditor should be checked for NULL before adding.
|
||||
SetLayout(new BGroupLayout(B_HORIZONTAL));
|
||||
const float spacing = be_control_look->DefaultItemSpacing();
|
||||
AddChild(BGroupLayoutBuilder(B_VERTICAL, spacing)
|
||||
|
@ -188,6 +189,10 @@ InitParamsPanel::MessageReceived(BMessage* message)
|
|||
int32
|
||||
InitParamsPanel::Go(BString& name, BString& parameters)
|
||||
{
|
||||
// Without an editor, we cannot change anything, anyway
|
||||
if (fEditor == NULL)
|
||||
return GO_SUCCESS;
|
||||
|
||||
// run the window thread, to get an initial layout of the controls
|
||||
Hide();
|
||||
Show();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2013 Haiku Inc. All rights reserved.
|
||||
* Copyright 2002-2013 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Authors:
|
||||
|
@ -7,8 +7,10 @@
|
|||
* Ithamar R. Adema <ithamar@unet.nl>
|
||||
* Ingo Weinhold <ingo_weinhold@gmx.de>
|
||||
* Stephan Aßmus <superstippi@gmx.de>
|
||||
* Axel Dörfler, axeld@pinc-software.de.
|
||||
*/
|
||||
|
||||
|
||||
#include "MainWindow.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -140,6 +142,38 @@ private:
|
|||
};
|
||||
|
||||
|
||||
class ModificationPreparer {
|
||||
public:
|
||||
ModificationPreparer(BDiskDevice* disk)
|
||||
:
|
||||
fDisk(disk),
|
||||
fModificationStatus(fDisk->PrepareModifications())
|
||||
{
|
||||
}
|
||||
~ModificationPreparer()
|
||||
{
|
||||
if (fModificationStatus == B_OK)
|
||||
fDisk->CancelModifications();
|
||||
}
|
||||
status_t ModificationStatus() const
|
||||
{
|
||||
return fModificationStatus;
|
||||
}
|
||||
status_t CommitModifications()
|
||||
{
|
||||
status_t ret = fDisk->CommitModifications();
|
||||
if (ret == B_OK)
|
||||
fModificationStatus = B_ERROR;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private:
|
||||
BDiskDevice* fDisk;
|
||||
status_t fModificationStatus;
|
||||
};
|
||||
|
||||
|
||||
enum {
|
||||
MSG_MOUNT_ALL = 'mnta',
|
||||
MSG_MOUNT = 'mnts',
|
||||
|
@ -747,38 +781,6 @@ MainWindow::_MountAll()
|
|||
// #pragma mark -
|
||||
|
||||
|
||||
class ModificationPreparer {
|
||||
public:
|
||||
ModificationPreparer(BDiskDevice* disk)
|
||||
:
|
||||
fDisk(disk),
|
||||
fModificationStatus(fDisk->PrepareModifications())
|
||||
{
|
||||
}
|
||||
~ModificationPreparer()
|
||||
{
|
||||
if (fModificationStatus == B_OK)
|
||||
fDisk->CancelModifications();
|
||||
}
|
||||
status_t ModificationStatus() const
|
||||
{
|
||||
return fModificationStatus;
|
||||
}
|
||||
status_t CommitModifications()
|
||||
{
|
||||
status_t ret = fDisk->CommitModifications();
|
||||
if (ret == B_OK)
|
||||
fModificationStatus = B_ERROR;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private:
|
||||
BDiskDevice* fDisk;
|
||||
status_t fModificationStatus;
|
||||
};
|
||||
|
||||
|
||||
void
|
||||
MainWindow::_Initialize(BDiskDevice* disk, partition_id selectedPartition,
|
||||
const BString& diskSystemName)
|
||||
|
@ -871,19 +873,10 @@ MainWindow::_Initialize(BDiskDevice* disk, partition_id selectedPartition,
|
|||
|
||||
BString name;
|
||||
BString parameters;
|
||||
|
||||
// TODO: diskSystem.IsFileSystem() seems like a better fit here?
|
||||
if (diskSystemName == "Be File System"
|
||||
|| diskSystemName == "NT File System") {
|
||||
InitParamsPanel* panel = new InitParamsPanel(this, diskSystemName,
|
||||
partition);
|
||||
if (panel->Go(name, parameters) == GO_CANCELED)
|
||||
return;
|
||||
} else if (diskSystemName == "Intel Partition Map") {
|
||||
// TODO: parameters?
|
||||
} else if (diskSystemName == "Intel Extended Partition") {
|
||||
// TODO: parameters?
|
||||
}
|
||||
InitParamsPanel* panel = new InitParamsPanel(this, diskSystemName,
|
||||
partition);
|
||||
if (panel->Go(name, parameters) == GO_CANCELED)
|
||||
return;
|
||||
|
||||
bool supportsName = diskSystem.SupportsContentName();
|
||||
BString validatedName(name);
|
||||
|
|
Loading…
Reference in New Issue