BPrintJob: fixed crash.

Since hrev49481, BAlert sets its default button in Go(), and not in the
constructor. So DefaultButton() will return NULL if Go() hasn't been called
yet.
Moreover, BAlert now centers itself on screen in Go() and not in the costructor,
so move it away from screen after the Go() call.
Fixes #12271, although there should be a nicer way to implement this.
This commit is contained in:
Stefano Ceccherini 2015-08-29 15:16:17 +02:00
parent e2eb9b7baf
commit 1805bbf29b

View File

@ -747,12 +747,22 @@ PrintServerMessenger::~PrintServerMessenger()
void
PrintServerMessenger::RejectUserInput()
{
// TODO: This code is sort of a hack:
// It creates a BAlert then moves it out of the screen to
// block user input.
fHiddenApplicationModalWindow = new BAlert("bogus", "app_modal", "OK");
fHiddenApplicationModalWindow->DefaultButton()->SetEnabled(false);
fHiddenApplicationModalWindow->SetDefaultButton(NULL);
BButton* defaultButton = fHiddenApplicationModalWindow->DefaultButton();
if (defaultButton != NULL) {
// TODO: Doing this is useless, since BAlert now sets its
// default button on Go().
defaultButton->SetEnabled(false);
fHiddenApplicationModalWindow->SetDefaultButton(NULL);
}
fHiddenApplicationModalWindow->SetFlags(fHiddenApplicationModalWindow->Flags() | B_CLOSE_ON_ESCAPE);
fHiddenApplicationModalWindow->MoveTo(-65000, -65000);
fHiddenApplicationModalWindow->Go(NULL);
// Moved here because now BAlert centers itself on screen in Go().
fHiddenApplicationModalWindow->MoveTo(-65000, -65000);
}
@ -867,7 +877,6 @@ PrintServerMessenger::MessengerThread(void* data)
return B_ERROR;
}
BMessage reply;
if (printServer.SendMessage(request, &reply) != B_OK
|| reply.what != 'okok' ) {