Skip to content

Commit

Permalink
Merge pull request #75 from calband/help_crash
Browse files Browse the repository at this point in the history
Fix for #20: MAC: Crash when quitting from the help menu
  • Loading branch information
kmdurand committed Mar 15, 2014
2 parents 191b509 + bc27b19 commit f34dc61
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 16 deletions.
16 changes: 9 additions & 7 deletions src/calchartapp.cpp
Expand Up @@ -37,13 +37,6 @@

wxPrintDialogData *gPrintDialogData;

wxHtmlHelpController&
GetGlobalHelpController()
{
static wxHtmlHelpController sHelpController;
return sHelpController;
}

void CC_continuity_UnitTests();
void CC_point_UnitTests();
void CC_coord_UnitTests();
Expand All @@ -63,6 +56,7 @@ bool CalChartApp::OnInit()
CLASSINFO(CalChartDoc), CLASSINFO(FieldView));

gPrintDialogData = new wxPrintDialogData();
mHelpController = std::unique_ptr<wxHtmlHelpController>(new wxHtmlHelpController());

// setup the configuration.
ReadConfig();
Expand Down Expand Up @@ -107,6 +101,12 @@ bool CalChartApp::OnInit()
return true;
}

wxHtmlHelpController&
CalChartApp::GetGlobalHelpController()
{
return *mHelpController;
}

void CalChartApp::MacOpenFile(const wxString &fileName)
{
mDocManager->CreateDocument(fileName, wxDOC_SILENT);
Expand All @@ -125,6 +125,8 @@ int CalChartApp::OnExit()
// delete the doc manager
delete wxDocManager::GetDocumentManager();

mHelpController.reset();

return wxApp::OnExit();
}

9 changes: 6 additions & 3 deletions src/calchartapp.h
Expand Up @@ -27,14 +27,12 @@

#include <wx/wx.h>
#include <wx/docview.h>
#include <memory>

class CalChartApp;
class ShowMode;
class wxHtmlHelpController;

// the global help system:
wxHtmlHelpController& GetGlobalHelpController();

DECLARE_APP(CalChartApp)

// Define a new application
Expand All @@ -46,10 +44,15 @@ class CalChartApp : public wxApp
int OnExit();

ShowModeList& GetModeList() { return mModeList; }

// the global help system:
wxHtmlHelpController& GetGlobalHelpController();

private:
ShowModeList mModeList;

wxDocManager* mDocManager;
std::unique_ptr<wxHtmlHelpController> mHelpController;
};

#endif // _CALCHARTAPP_H_
4 changes: 2 additions & 2 deletions src/cont_ui.cpp
Expand Up @@ -224,8 +224,8 @@ void ContinuityEditor::OnCloseWindow(wxCommandEvent& event)

void ContinuityEditor::OnCmdHelp(wxCommandEvent& event)
{
GetGlobalHelpController().LoadFile();
GetGlobalHelpController().KeywordSearch(wxT("Animation Commands"));
wxGetApp().GetGlobalHelpController().LoadFile();
wxGetApp().GetGlobalHelpController().KeywordSearch(wxT("Animation Commands"));
}


Expand Down
4 changes: 2 additions & 2 deletions src/print_cont_ui.cpp
Expand Up @@ -253,8 +253,8 @@ void PrintContinuityEditor::OnCloseWindow(wxCommandEvent& event)

void PrintContinuityEditor::OnCmdHelp(wxCommandEvent& event)
{
GetGlobalHelpController().LoadFile();
GetGlobalHelpController().KeywordSearch(wxT("Animation Commands"));
wxGetApp().GetGlobalHelpController().LoadFile();
wxGetApp().GetGlobalHelpController().KeywordSearch(wxT("Animation Commands"));
}


Expand Down
4 changes: 2 additions & 2 deletions src/top_frame.cpp
Expand Up @@ -139,8 +139,8 @@ TopFrame::About()
void
TopFrame::Help()
{
GetGlobalHelpController().LoadFile();
GetGlobalHelpController().DisplayContents();
wxGetApp().GetGlobalHelpController().LoadFile();
wxGetApp().GetGlobalHelpController().DisplayContents();
}


Expand Down

0 comments on commit f34dc61

Please sign in to comment.