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:
@@ -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.
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -104,15 +104,16 @@ InitParamsPanel::InitParamsPanel(BWindow* window, const BString& diskSystem,
|
|||||||
// put the add-on
|
// put the add-on
|
||||||
manager->PutAddOn(addOn);
|
manager->PutAddOn(addOn);
|
||||||
|
|
||||||
status_t err = addOn->GetParameterEditor(B_INITIALIZE_PARAMETER_EDITOR, &fEditor);
|
status_t err = addOn->GetParameterEditor(B_INITIALIZE_PARAMETER_EDITOR,
|
||||||
if (err != B_OK) {
|
&fEditor);
|
||||||
|
if (err != B_OK)
|
||||||
fEditor = NULL;
|
fEditor = NULL;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
fEditor = NULL;
|
fEditor = NULL;
|
||||||
}
|
}
|
||||||
|
if (fEditor == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
// TODO: fEditor should be checked for NULL before adding.
|
|
||||||
SetLayout(new BGroupLayout(B_HORIZONTAL));
|
SetLayout(new BGroupLayout(B_HORIZONTAL));
|
||||||
const float spacing = be_control_look->DefaultItemSpacing();
|
const float spacing = be_control_look->DefaultItemSpacing();
|
||||||
AddChild(BGroupLayoutBuilder(B_VERTICAL, spacing)
|
AddChild(BGroupLayoutBuilder(B_VERTICAL, spacing)
|
||||||
@@ -188,6 +189,10 @@ InitParamsPanel::MessageReceived(BMessage* message)
|
|||||||
int32
|
int32
|
||||||
InitParamsPanel::Go(BString& name, BString& parameters)
|
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
|
// run the window thread, to get an initial layout of the controls
|
||||||
Hide();
|
Hide();
|
||||||
Show();
|
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.
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -7,8 +7,10 @@
|
|||||||
* Ithamar R. Adema <[email protected]>
|
* Ithamar R. Adema <[email protected]>
|
||||||
* Ingo Weinhold <[email protected]>
|
* Ingo Weinhold <[email protected]>
|
||||||
* Stephan Aßmus <[email protected]>
|
* Stephan Aßmus <[email protected]>
|
||||||
|
* Axel Dörfler, [email protected].
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
|
|
||||||
#include <stdio.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 {
|
enum {
|
||||||
MSG_MOUNT_ALL = 'mnta',
|
MSG_MOUNT_ALL = 'mnta',
|
||||||
MSG_MOUNT = 'mnts',
|
MSG_MOUNT = 'mnts',
|
||||||
@@ -747,38 +781,6 @@ MainWindow::_MountAll()
|
|||||||
// #pragma mark -
|
// #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
|
void
|
||||||
MainWindow::_Initialize(BDiskDevice* disk, partition_id selectedPartition,
|
MainWindow::_Initialize(BDiskDevice* disk, partition_id selectedPartition,
|
||||||
const BString& diskSystemName)
|
const BString& diskSystemName)
|
||||||
@@ -871,19 +873,10 @@ MainWindow::_Initialize(BDiskDevice* disk, partition_id selectedPartition,
|
|||||||
|
|
||||||
BString name;
|
BString name;
|
||||||
BString parameters;
|
BString parameters;
|
||||||
|
InitParamsPanel* panel = new InitParamsPanel(this, diskSystemName,
|
||||||
// TODO: diskSystem.IsFileSystem() seems like a better fit here?
|
partition);
|
||||||
if (diskSystemName == "Be File System"
|
if (panel->Go(name, parameters) == GO_CANCELED)
|
||||||
|| diskSystemName == "NT File System") {
|
return;
|
||||||
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?
|
|
||||||
}
|
|
||||||
|
|
||||||
bool supportsName = diskSystem.SupportsContentName();
|
bool supportsName = diskSystem.SupportsContentName();
|
||||||
BString validatedName(name);
|
BString validatedName(name);
|
||||||
|
|||||||
Reference in New Issue
Block a user