* 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.
|
||||
*
|
||||
* 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 = new BMenu(B_TRANSLATE("Encoding"));
|
||||
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;
|
||||
|
||||
|
||||
@@ -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:
|
||||
@@ -25,33 +25,32 @@ class StyledEditWindow;
|
||||
|
||||
|
||||
class StyledEditApp : public BApplication {
|
||||
public:
|
||||
StyledEditApp();
|
||||
virtual ~StyledEditApp();
|
||||
public:
|
||||
StyledEditApp();
|
||||
virtual ~StyledEditApp();
|
||||
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
virtual void ArgvReceived(int32 argc, char** argv);
|
||||
virtual void RefsReceived(BMessage *message);
|
||||
virtual void ReadyToRun();
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
virtual void ArgvReceived(int32 argc, char** argv);
|
||||
virtual void RefsReceived(BMessage* message);
|
||||
virtual void ReadyToRun();
|
||||
|
||||
int32 NumberOfWindows();
|
||||
void OpenDocument();
|
||||
status_t OpenDocument(entry_ref *ref);
|
||||
void CloseDocument();
|
||||
int32 NumberOfWindows();
|
||||
void OpenDocument();
|
||||
status_t OpenDocument(entry_ref* ref);
|
||||
void CloseDocument();
|
||||
|
||||
private:
|
||||
void ArgvReceivedEx(int32 argc, const char *argv[], const char * cwd);
|
||||
private:
|
||||
void ArgvReceivedEx(int32 argc, const char* argv[],
|
||||
const char* cwd);
|
||||
|
||||
private:
|
||||
BFilePanel *fOpenPanel;
|
||||
BMenu *fOpenPanelEncodingMenu;
|
||||
uint32 fOpenAsEncoding;
|
||||
int32 fWindowCount;
|
||||
int32 fNextUntitledWindow;
|
||||
bool fBadArguments;
|
||||
private:
|
||||
BFilePanel* fOpenPanel;
|
||||
BMenu* fOpenPanelEncodingMenu;
|
||||
uint32 fOpenAsEncoding;
|
||||
int32 fWindowCount;
|
||||
int32 fNextUntitledWindow;
|
||||
bool fBadArguments;
|
||||
};
|
||||
|
||||
extern StyledEditApp* styled_edit_app;
|
||||
|
||||
#endif // STYLED_EDIT_APP
|
||||
|
||||
|
||||
@@ -861,7 +861,8 @@ void
|
||||
StyledEditWindow::Quit()
|
||||
{
|
||||
SaveAttrs();
|
||||
styled_edit_app->CloseDocument();
|
||||
if (StyledEditApp* app = dynamic_cast<StyledEditApp*>(be_app))
|
||||
app->CloseDocument();
|
||||
BWindow::Quit();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user