PackageInstaller: Unbreak selecting custom install folders.
BFilePanel always sends B_CANCEL when it hides (as documented in the BeBook), not just when the user cancels the file panel. Track what message we expect and only react to B_CANCEL when it means the user really canceled selecting the target folder.
This commit is contained in:
parent
91e3737dd8
commit
792a46db79
@ -73,6 +73,7 @@ PackageView::PackageView(const entry_ref* ref)
|
||||
BView("package_view", 0),
|
||||
fOpenPanel(new BFilePanel(B_OPEN_PANEL, NULL, NULL, B_DIRECTORY_NODE,
|
||||
false)),
|
||||
fExpectingOpenPanelResult(false),
|
||||
fInfo(ref),
|
||||
fInstallProcess(this)
|
||||
{
|
||||
@ -180,6 +181,7 @@ PackageView::MessageReceived(BMessage* message)
|
||||
}
|
||||
|
||||
case P_MSG_OPEN_PANEL:
|
||||
fExpectingOpenPanelResult = true;
|
||||
fOpenPanel->Show();
|
||||
break;
|
||||
|
||||
@ -266,6 +268,9 @@ PackageView::MessageReceived(BMessage* message)
|
||||
|
||||
case B_REFS_RECEIVED:
|
||||
{
|
||||
if (!_ValidateFilePanelMessage(message))
|
||||
break;
|
||||
|
||||
entry_ref ref;
|
||||
if (message->FindRef("refs", &ref) == B_OK) {
|
||||
BPath path(&ref);
|
||||
@ -290,6 +295,9 @@ PackageView::MessageReceived(BMessage* message)
|
||||
|
||||
case B_CANCEL:
|
||||
{
|
||||
if (!_ValidateFilePanelMessage(message))
|
||||
break;
|
||||
|
||||
// file panel aborted, select first suitable item
|
||||
for (int32 i = 0; i < fDestination->CountItems(); i++) {
|
||||
BMenuItem* item = fDestination->ItemAt(i);
|
||||
@ -723,3 +731,14 @@ PackageView::_AddMenuItem(const char* name, BMessage* message,
|
||||
menu->AddItem(item);
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
PackageView::_ValidateFilePanelMessage(BMessage* message)
|
||||
{
|
||||
if (!fExpectingOpenPanelResult)
|
||||
return false;
|
||||
|
||||
fExpectingOpenPanelResult = false;
|
||||
return true;
|
||||
}
|
||||
|
@ -66,6 +66,8 @@ private:
|
||||
BMenuItem* _AddMenuItem(const char* name,
|
||||
BMessage* message, BMenu* menu) const;
|
||||
|
||||
bool _ValidateFilePanelMessage(BMessage* message);
|
||||
|
||||
private:
|
||||
BPopUpMenu* fInstallTypes;
|
||||
BTextView* fInstallTypeDescriptionView;
|
||||
@ -74,6 +76,8 @@ private:
|
||||
BButton* fBeginButton;
|
||||
|
||||
BFilePanel* fOpenPanel;
|
||||
bool fExpectingOpenPanelResult;
|
||||
|
||||
BPath fCurrentPath;
|
||||
uint32 fCurrentType;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user