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 { class BAboutWindow : public BWindow {
public: public:
BAboutWindow(BHandler* handler, BAboutWindow(const char* appName,
const char* appName,
const char* signature); const char* signature);
virtual ~BAboutWindow(); virtual ~BAboutWindow();
+4 -10
View File
@@ -1112,22 +1112,16 @@ ActivityView::MessageReceived(BMessage* message)
switch (message->what) { switch (message->what) {
case B_ABOUT_REQUESTED: case B_ABOUT_REQUESTED:
{
bool quit = false;
if (message->FindBool("quit", &quit) == B_OK && quit) {
fAboutWindow = NULL;
break;
}
if (fAboutWindow == NULL) { if (fAboutWindow == NULL) {
fAboutWindow = new BAboutWindow(this, kAppName, kSignature); fAboutWindow = new BAboutWindow(kAppName, kSignature);
fAboutWindow->AddCopyright(2008, "Haiku, Inc."); fAboutWindow->AddCopyright(2008, "Haiku, Inc.");
fAboutWindow->Show(); fAboutWindow->Show();
} else } else if (fAboutWindow->IsHidden())
fAboutWindow->Show();
else
fAboutWindow->Activate(); fAboutWindow->Activate();
break; break;
}
case kMsgUpdateResolution: case kMsgUpdateResolution:
{ {
+4 -10
View File
@@ -270,13 +270,6 @@ CalcView::MessageReceived(BMessage* message)
// (replicant) about box requested // (replicant) about box requested
case B_ABOUT_REQUESTED: case B_ABOUT_REQUESTED:
{
bool quit = false;
if (message->FindBool("quit", &quit) == B_OK && quit) {
fAboutWindow = NULL;
break;
}
if (fAboutWindow == NULL) { if (fAboutWindow == NULL) {
// create the about window // create the about window
const char* extraCopyrights[] = { const char* extraCopyrights[] = {
@@ -284,15 +277,16 @@ CalcView::MessageReceived(BMessage* message)
NULL NULL
}; };
fAboutWindow = new BAboutWindow(this, kAppName, kSignature); fAboutWindow = new BAboutWindow(kAppName, kSignature);
fAboutWindow->AddCopyright(2006, "Haiku, Inc.", fAboutWindow->AddCopyright(2006, "Haiku, Inc.",
extraCopyrights); extraCopyrights);
fAboutWindow->Show(); fAboutWindow->Show();
} else } else if (fAboutWindow->IsHidden())
fAboutWindow->Show();
else
fAboutWindow->Activate(); fAboutWindow->Activate();
break; break;
}
case MSG_UNFLASH_KEY: case MSG_UNFLASH_KEY:
{ {
@@ -426,13 +426,6 @@ ProcessController::MessageReceived(BMessage *message)
} }
case B_ABOUT_REQUESTED: case B_ABOUT_REQUESTED:
{
bool quit = false;
if (message->FindBool("quit", &quit) == B_OK && quit) {
fAboutWindow = NULL;
break;
}
if (fAboutWindow == NULL) { if (fAboutWindow == NULL) {
const char* extraCopyrights[] = { const char* extraCopyrights[] = {
"1997-2001 Georges-Edouard Berenger", "1997-2001 Georges-Edouard Berenger",
@@ -444,16 +437,17 @@ ProcessController::MessageReceived(BMessage *message)
NULL NULL
}; };
fAboutWindow = new BAboutWindow(this, fAboutWindow = new BAboutWindow(
B_TRANSLATE_SYSTEM_NAME("ProcessController"), kSignature); B_TRANSLATE_SYSTEM_NAME("ProcessController"), kSignature);
fAboutWindow->AddCopyright(2007, "Haiku, Inc.", extraCopyrights); fAboutWindow->AddCopyright(2007, "Haiku, Inc.", extraCopyrights);
fAboutWindow->AddAuthors(authors); fAboutWindow->AddAuthors(authors);
fAboutWindow->Show(); fAboutWindow->Show();
} else } else if (fAboutWindow->IsHidden())
fAboutWindow->Show();
else
fAboutWindow->Activate(); fAboutWindow->Activate();
break; break;
}
default: default:
BView::MessageReceived(message); BView::MessageReceived(message);
+4 -14
View File
@@ -254,11 +254,10 @@ AboutView::AppIcon(const char* signature)
// #pragma mark - // #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, : BWindow(BRect(0.0, 0.0, 200.0, 140.0), appName, B_TITLED_WINDOW,
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE
| B_AUTO_UPDATE_SIZE_LIMITS), | B_AUTO_UPDATE_SIZE_LIMITS)
fCaller(handler)
{ {
_Init(appName, signature); _Init(appName, signature);
} }
@@ -275,18 +274,9 @@ BAboutWindow::~BAboutWindow()
bool bool
BAboutWindow::QuitRequested() BAboutWindow::QuitRequested()
{ {
if (fCaller != NULL) { Hide();
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;
}
}
return true; return false;
} }
+4 -10
View File
@@ -73,13 +73,6 @@ LocalePreflet::MessageReceived(BMessage* message)
break; break;
case B_ABOUT_REQUESTED: case B_ABOUT_REQUESTED:
{
bool quit = false;
if (message->FindBool("quit", &quit) == B_OK && quit) {
fAboutWindow = NULL;
break;
}
if (fAboutWindow == NULL) { if (fAboutWindow == NULL) {
const char* authors[] = { const char* authors[] = {
"Axel Dörfler", "Axel Dörfler",
@@ -88,15 +81,16 @@ LocalePreflet::MessageReceived(BMessage* message)
NULL NULL
}; };
fAboutWindow = new BAboutWindow(this, kAppName, kSignature); fAboutWindow = new BAboutWindow(kAppName, kSignature);
fAboutWindow->AddCopyright(2005, "Haiku, Inc."); fAboutWindow->AddCopyright(2005, "Haiku, Inc.");
fAboutWindow->AddAuthors(authors); fAboutWindow->AddAuthors(authors);
fAboutWindow->Show(); fAboutWindow->Show();
} else } else if (fAboutWindow->IsHidden())
fAboutWindow->Show();
else
fAboutWindow->Activate(); fAboutWindow->Activate();
break; break;
}
default: default:
BApplication::MessageReceived(message); BApplication::MessageReceived(message);