* Fixed potential NULL menuBar. This fixes CID 462.

* Got rid of the global styled_edit_app variable.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38463 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2010-08-30 21:04:06 +00:00
parent 4cdd7099dc
commit 6387dbc3f2
3 changed files with 39 additions and 34 deletions
+14 -9
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007, Haiku, Inc. All Rights Reserved.
* Copyright 2002-2010, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -32,7 +32,6 @@
using namespace BPrivate;
StyledEditApp * styled_edit_app;
BRect gWindowRect(7-15, 26-15, 507, 426);
@@ -80,22 +79,27 @@ namespace
// #pragma mark -
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "Open_and_SaveAsPanel"
StyledEditApp::StyledEditApp()
: BApplication(APP_SIGNATURE),
:
BApplication(APP_SIGNATURE),
fOpenPanel(NULL)
{
fOpenPanel = new BFilePanel();
BMenuBar* menuBar =
dynamic_cast<BMenuBar*>(fOpenPanel->Window()->FindView("MenuBar"));
fOpenAsEncoding = 0;
fOpenPanelEncodingMenu = new BMenu(B_TRANSLATE("Encoding"));
menuBar->AddItem(fOpenPanelEncodingMenu);
fOpenPanelEncodingMenu->SetRadioMode(true);
BMenuBar* menuBar
= dynamic_cast<BMenuBar*>(fOpenPanel->Window()->FindView("MenuBar"));
if (menuBar != NULL)
menuBar->AddItem(fOpenPanelEncodingMenu);
BCharacterSetRoster roster;
BCharacterSet charset;
while (roster.GetNextCharacterSet(&charset) == B_NO_ERROR) {
@@ -122,14 +126,14 @@ StyledEditApp::StyledEditApp()
fWindowCount = 0;
fNextUntitledWindow = 1;
fBadArguments = false;
styled_edit_app = this;
}
StyledEditApp::~StyledEditApp()
{
delete fOpenPanel;
if (fOpenPanelEncodingMenu->Supermenu() == NULL)
delete fOpenPanelEncodingMenu;
}
@@ -150,7 +154,8 @@ StyledEditApp::MessageReceived(BMessage* message)
void* ptr;
if (message->FindPointer("source", &ptr) == B_OK
&& fOpenPanelEncodingMenu != 0) {
fOpenAsEncoding = (uint32)fOpenPanelEncodingMenu->IndexOf((BMenuItem*)ptr);
fOpenAsEncoding = (uint32)fOpenPanelEncodingMenu->IndexOf(
(BMenuItem*)ptr);
}
break;
+3 -4
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2006, Haiku, Inc. All Rights Reserved.
* Copyright 2002-2010, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -40,7 +40,8 @@ class StyledEditApp : public BApplication {
void CloseDocument();
private:
void ArgvReceivedEx(int32 argc, const char *argv[], const char * cwd);
void ArgvReceivedEx(int32 argc, const char* argv[],
const char* cwd);
private:
BFilePanel* fOpenPanel;
@@ -51,7 +52,5 @@ class StyledEditApp : public BApplication {
bool fBadArguments;
};
extern StyledEditApp* styled_edit_app;
#endif // STYLED_EDIT_APP
+2 -1
View File
@@ -861,7 +861,8 @@ void
StyledEditWindow::Quit()
{
SaveAttrs();
styled_edit_app->CloseDocument();
if (StyledEditApp* app = dynamic_cast<StyledEditApp*>(be_app))
app->CloseDocument();
BWindow::Quit();
}