Instead of destroying the BAboutWindow object on close, Hide() it, then on the destructor of the calling window call Quit() explicitly to destroy it.

This commit is contained in:
John Scipione
2012-11-12 23:57:30 -05:00
parent 04875296c4
commit 97a814061e
6 changed files with 21 additions and 56 deletions
+1 -2
View File
@@ -17,8 +17,7 @@ class BHandler;
class BAboutWindow : public BWindow {
public:
BAboutWindow(BHandler* handler,
const char* appName,
BAboutWindow(const char* appName,
const char* signature);
virtual ~BAboutWindow();
+4 -10
View File
@@ -1112,22 +1112,16 @@ ActivityView::MessageReceived(BMessage* message)
switch (message->what) {
case B_ABOUT_REQUESTED:
{
bool quit = false;
if (message->FindBool("quit", &quit) == B_OK && quit) {
fAboutWindow = NULL;
break;
}
if (fAboutWindow == NULL) {
fAboutWindow = new BAboutWindow(this, kAppName, kSignature);
fAboutWindow = new BAboutWindow(kAppName, kSignature);
fAboutWindow->AddCopyright(2008, "Haiku, Inc.");
fAboutWindow->Show();
} else
} else if (fAboutWindow->IsHidden())
fAboutWindow->Show();
else
fAboutWindow->Activate();
break;
}
case kMsgUpdateResolution:
{
+4 -10
View File
@@ -270,13 +270,6 @@ CalcView::MessageReceived(BMessage* message)
// (replicant) about box requested
case B_ABOUT_REQUESTED:
{
bool quit = false;
if (message->FindBool("quit", &quit) == B_OK && quit) {
fAboutWindow = NULL;
break;
}
if (fAboutWindow == NULL) {
// create the about window
const char* extraCopyrights[] = {
@@ -284,15 +277,16 @@ CalcView::MessageReceived(BMessage* message)
NULL
};
fAboutWindow = new BAboutWindow(this, kAppName, kSignature);
fAboutWindow = new BAboutWindow(kAppName, kSignature);
fAboutWindow->AddCopyright(2006, "Haiku, Inc.",
extraCopyrights);
fAboutWindow->Show();
} else
} else if (fAboutWindow->IsHidden())
fAboutWindow->Show();
else
fAboutWindow->Activate();
break;
}
case MSG_UNFLASH_KEY:
{
@@ -426,13 +426,6 @@ ProcessController::MessageReceived(BMessage *message)
}
case B_ABOUT_REQUESTED:
{
bool quit = false;
if (message->FindBool("quit", &quit) == B_OK && quit) {
fAboutWindow = NULL;
break;
}
if (fAboutWindow == NULL) {
const char* extraCopyrights[] = {
"1997-2001 Georges-Edouard Berenger",
@@ -444,16 +437,17 @@ ProcessController::MessageReceived(BMessage *message)
NULL
};
fAboutWindow = new BAboutWindow(this,
fAboutWindow = new BAboutWindow(
B_TRANSLATE_SYSTEM_NAME("ProcessController"), kSignature);
fAboutWindow->AddCopyright(2007, "Haiku, Inc.", extraCopyrights);
fAboutWindow->AddAuthors(authors);
fAboutWindow->Show();
} else
} else if (fAboutWindow->IsHidden())
fAboutWindow->Show();
else
fAboutWindow->Activate();
break;
}
default:
BView::MessageReceived(message);
+4 -14
View File
@@ -254,11 +254,10 @@ AboutView::AppIcon(const char* signature)
// #pragma mark -
BAboutWindow::BAboutWindow(BHandler* handler, const char* appName, const char* signature)
BAboutWindow::BAboutWindow(const char* appName, const char* signature)
: BWindow(BRect(0.0, 0.0, 200.0, 140.0), appName, B_TITLED_WINDOW,
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE
| B_AUTO_UPDATE_SIZE_LIMITS),
fCaller(handler)
| B_AUTO_UPDATE_SIZE_LIMITS)
{
_Init(appName, signature);
}
@@ -275,18 +274,9 @@ BAboutWindow::~BAboutWindow()
bool
BAboutWindow::QuitRequested()
{
if (fCaller != NULL) {
status_t status;
BMessenger messenger(fCaller, NULL, &status);
if (status == B_OK && messenger.IsValid()) {
BMessage* message = new BMessage(B_ABOUT_REQUESTED);
message->AddBool("quit", true);
messenger.SendMessage(message);
delete message;
}
}
Hide();
return true;
return false;
}
+4 -10
View File
@@ -73,13 +73,6 @@ LocalePreflet::MessageReceived(BMessage* message)
break;
case B_ABOUT_REQUESTED:
{
bool quit = false;
if (message->FindBool("quit", &quit) == B_OK && quit) {
fAboutWindow = NULL;
break;
}
if (fAboutWindow == NULL) {
const char* authors[] = {
"Axel Dörfler",
@@ -88,15 +81,16 @@ LocalePreflet::MessageReceived(BMessage* message)
NULL
};
fAboutWindow = new BAboutWindow(this, kAppName, kSignature);
fAboutWindow = new BAboutWindow(kAppName, kSignature);
fAboutWindow->AddCopyright(2005, "Haiku, Inc.");
fAboutWindow->AddAuthors(authors);
fAboutWindow->Show();
} else
} else if (fAboutWindow->IsHidden())
fAboutWindow->Show();
else
fAboutWindow->Activate();
break;
}
default:
BApplication::MessageReceived(message);