* 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:
@@ -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.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -32,7 +32,6 @@
|
|||||||
using namespace BPrivate;
|
using namespace BPrivate;
|
||||||
|
|
||||||
|
|
||||||
StyledEditApp * styled_edit_app;
|
|
||||||
BRect gWindowRect(7-15, 26-15, 507, 426);
|
BRect gWindowRect(7-15, 26-15, 507, 426);
|
||||||
|
|
||||||
|
|
||||||
@@ -80,22 +79,27 @@ namespace
|
|||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
#undef B_TRANSLATE_CONTEXT
|
#undef B_TRANSLATE_CONTEXT
|
||||||
#define B_TRANSLATE_CONTEXT "Open_and_SaveAsPanel"
|
#define B_TRANSLATE_CONTEXT "Open_and_SaveAsPanel"
|
||||||
|
|
||||||
|
|
||||||
StyledEditApp::StyledEditApp()
|
StyledEditApp::StyledEditApp()
|
||||||
: BApplication(APP_SIGNATURE),
|
:
|
||||||
|
BApplication(APP_SIGNATURE),
|
||||||
fOpenPanel(NULL)
|
fOpenPanel(NULL)
|
||||||
{
|
{
|
||||||
fOpenPanel = new BFilePanel();
|
fOpenPanel = new BFilePanel();
|
||||||
BMenuBar* menuBar =
|
|
||||||
dynamic_cast<BMenuBar*>(fOpenPanel->Window()->FindView("MenuBar"));
|
|
||||||
|
|
||||||
fOpenAsEncoding = 0;
|
fOpenAsEncoding = 0;
|
||||||
fOpenPanelEncodingMenu = new BMenu(B_TRANSLATE("Encoding"));
|
fOpenPanelEncodingMenu = new BMenu(B_TRANSLATE("Encoding"));
|
||||||
menuBar->AddItem(fOpenPanelEncodingMenu);
|
|
||||||
fOpenPanelEncodingMenu->SetRadioMode(true);
|
fOpenPanelEncodingMenu->SetRadioMode(true);
|
||||||
|
|
||||||
|
BMenuBar* menuBar
|
||||||
|
= dynamic_cast<BMenuBar*>(fOpenPanel->Window()->FindView("MenuBar"));
|
||||||
|
if (menuBar != NULL)
|
||||||
|
menuBar->AddItem(fOpenPanelEncodingMenu);
|
||||||
|
|
||||||
BCharacterSetRoster roster;
|
BCharacterSetRoster roster;
|
||||||
BCharacterSet charset;
|
BCharacterSet charset;
|
||||||
while (roster.GetNextCharacterSet(&charset) == B_NO_ERROR) {
|
while (roster.GetNextCharacterSet(&charset) == B_NO_ERROR) {
|
||||||
@@ -122,14 +126,14 @@ StyledEditApp::StyledEditApp()
|
|||||||
fWindowCount = 0;
|
fWindowCount = 0;
|
||||||
fNextUntitledWindow = 1;
|
fNextUntitledWindow = 1;
|
||||||
fBadArguments = false;
|
fBadArguments = false;
|
||||||
|
|
||||||
styled_edit_app = this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
StyledEditApp::~StyledEditApp()
|
StyledEditApp::~StyledEditApp()
|
||||||
{
|
{
|
||||||
delete fOpenPanel;
|
delete fOpenPanel;
|
||||||
|
if (fOpenPanelEncodingMenu->Supermenu() == NULL)
|
||||||
|
delete fOpenPanelEncodingMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -150,7 +154,8 @@ StyledEditApp::MessageReceived(BMessage* message)
|
|||||||
void* ptr;
|
void* ptr;
|
||||||
if (message->FindPointer("source", &ptr) == B_OK
|
if (message->FindPointer("source", &ptr) == B_OK
|
||||||
&& fOpenPanelEncodingMenu != 0) {
|
&& fOpenPanelEncodingMenu != 0) {
|
||||||
fOpenAsEncoding = (uint32)fOpenPanelEncodingMenu->IndexOf((BMenuItem*)ptr);
|
fOpenAsEncoding = (uint32)fOpenPanelEncodingMenu->IndexOf(
|
||||||
|
(BMenuItem*)ptr);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -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.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -40,7 +40,8 @@ class StyledEditApp : public BApplication {
|
|||||||
void CloseDocument();
|
void CloseDocument();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ArgvReceivedEx(int32 argc, const char *argv[], const char * cwd);
|
void ArgvReceivedEx(int32 argc, const char* argv[],
|
||||||
|
const char* cwd);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BFilePanel* fOpenPanel;
|
BFilePanel* fOpenPanel;
|
||||||
@@ -51,7 +52,5 @@ class StyledEditApp : public BApplication {
|
|||||||
bool fBadArguments;
|
bool fBadArguments;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern StyledEditApp* styled_edit_app;
|
|
||||||
|
|
||||||
#endif // STYLED_EDIT_APP
|
#endif // STYLED_EDIT_APP
|
||||||
|
|
||||||
|
|||||||
@@ -861,7 +861,8 @@ void
|
|||||||
StyledEditWindow::Quit()
|
StyledEditWindow::Quit()
|
||||||
{
|
{
|
||||||
SaveAttrs();
|
SaveAttrs();
|
||||||
styled_edit_app->CloseDocument();
|
if (StyledEditApp* app = dynamic_cast<StyledEditApp*>(be_app))
|
||||||
|
app->CloseDocument();
|
||||||
BWindow::Quit();
|
BWindow::Quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user