DriveSetup: fixed crash in CreateParametersPanel.
* Changed order of calling Init() vs. _CreateViewControls(). This fixes bug #9422. * The panel now hides (instead of disabling) the name or type control if those aren't supported, anyway.
This commit is contained in:
@@ -43,13 +43,13 @@ CreateParametersPanel::CreateParametersPanel(BWindow* window,
|
|||||||
:
|
:
|
||||||
AbstractParametersPanel(window)
|
AbstractParametersPanel(window)
|
||||||
{
|
{
|
||||||
Init(B_CREATE_PARAMETER_EDITOR, "", partition);
|
|
||||||
|
|
||||||
// Scale offset, and size from bytes to megabytes (2^20)
|
// Scale offset, and size from bytes to megabytes (2^20)
|
||||||
// so that we do not run over a signed int32.
|
// so that we do not run over a signed int32.
|
||||||
offset /= kMegaByte;
|
offset /= kMegaByte;
|
||||||
size /= kMegaByte;
|
size /= kMegaByte;
|
||||||
_CreateViewControls(partition, offset, size);
|
_CreateViewControls(partition, offset, size);
|
||||||
|
|
||||||
|
Init(B_CREATE_PARAMETER_EDITOR, "", partition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -122,14 +122,23 @@ CreateParametersPanel::AddControls(BLayoutBuilder::Group<>& builder,
|
|||||||
{
|
{
|
||||||
builder
|
builder
|
||||||
.Add(fSizeSlider)
|
.Add(fSizeSlider)
|
||||||
.Add(fSizeTextControl)
|
.Add(fSizeTextControl);
|
||||||
.AddGrid(0.0, 5.0)
|
|
||||||
.Add(fNameTextControl->CreateLabelLayoutItem(), 0, 0)
|
if (fSupportsName || fSupportsType) {
|
||||||
.Add(fNameTextControl->CreateTextViewLayoutItem(), 1, 0)
|
BLayoutBuilder::Group<>::GridBuilder gridBuilder
|
||||||
.Add(fTypeMenuField->CreateLabelLayoutItem(), 0, 1)
|
= builder.AddGrid(0.0, B_USE_DEFAULT_SPACING);
|
||||||
.Add(fTypeMenuField->CreateMenuBarLayoutItem(), 1, 1)
|
|
||||||
.End()
|
if (fSupportsName) {
|
||||||
.Add(editorView);
|
gridBuilder.Add(fNameTextControl->CreateLabelLayoutItem(), 0, 0)
|
||||||
|
.Add(fNameTextControl->CreateTextViewLayoutItem(), 1, 0);
|
||||||
|
}
|
||||||
|
if (fSupportsType) {
|
||||||
|
gridBuilder.Add(fTypeMenuField->CreateLabelLayoutItem(), 0, 1)
|
||||||
|
.Add(fTypeMenuField->CreateMenuBarLayoutItem(), 1, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.Add(editorView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -154,8 +163,7 @@ CreateParametersPanel::_CreateViewControls(BPartition* parent, off_t offset,
|
|||||||
|
|
||||||
fNameTextControl = new BTextControl("Name Control",
|
fNameTextControl = new BTextControl("Name Control",
|
||||||
B_TRANSLATE("Partition name:"), "", NULL);
|
B_TRANSLATE("Partition name:"), "", NULL);
|
||||||
if (!parent->SupportsChildName())
|
fSupportsName = parent->SupportsChildName();
|
||||||
fNameTextControl->SetEnabled(false);
|
|
||||||
|
|
||||||
fTypePopUpMenu = new BPopUpMenu("Partition Type");
|
fTypePopUpMenu = new BPopUpMenu("Partition Type");
|
||||||
|
|
||||||
@@ -173,6 +181,7 @@ CreateParametersPanel::_CreateViewControls(BPartition* parent, off_t offset,
|
|||||||
|
|
||||||
fTypeMenuField = new BMenuField(B_TRANSLATE("Partition type:"),
|
fTypeMenuField = new BMenuField(B_TRANSLATE("Partition type:"),
|
||||||
fTypePopUpMenu);
|
fTypePopUpMenu);
|
||||||
|
fSupportsType = fTypePopUpMenu->CountItems() != 0;
|
||||||
|
|
||||||
fOkButton->SetLabel(B_TRANSLATE("Create"));
|
fOkButton->SetLabel(B_TRANSLATE("Create"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ private:
|
|||||||
BTextControl* fNameTextControl;
|
BTextControl* fNameTextControl;
|
||||||
SizeSlider* fSizeSlider;
|
SizeSlider* fSizeSlider;
|
||||||
BTextControl* fSizeTextControl;
|
BTextControl* fSizeTextControl;
|
||||||
|
bool fSupportsName;
|
||||||
|
bool fSupportsType;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user