diff --git a/include/wx/html/helpfrm.h b/include/wx/html/helpfrm.h
index 9916dcb4a7..13816fa3c1 100644
--- a/include/wx/html/helpfrm.h
+++ b/include/wx/html/helpfrm.h
@@ -88,7 +88,7 @@ public:
wxHtmlHelpController* GetController() const { return m_helpController; }
/// Sets the help controller associated with the window.
- void SetController(wxHtmlHelpController* controller) { m_helpController = controller; }
+ void SetController(wxHtmlHelpController* controller);
/// Returns the help window.
wxHtmlHelpWindow* GetHelpWindow() const { return m_HtmlHelpWin; }
diff --git a/src/html/helpctrl.cpp b/src/html/helpctrl.cpp
index a0c120aa75..206e868051 100644
--- a/src/html/helpctrl.cpp
+++ b/src/html/helpctrl.cpp
@@ -87,12 +87,13 @@ void wxHtmlHelpController::OnCloseFrame(wxCloseEvent& evt)
{
if (m_Config)
WriteCustomization(m_Config, m_ConfigRoot);
-
+
evt.Skip();
OnQuit();
- m_helpWindow->SetController(NULL);
+ if ( m_helpWindow )
+ m_helpWindow->SetController(NULL);
m_helpWindow = NULL;
m_helpDialog = NULL;
m_helpFrame = NULL;
diff --git a/src/html/helpfrm.cpp b/src/html/helpfrm.cpp
index a9983916f7..ea22fa9b6e 100644
--- a/src/html/helpfrm.cpp
+++ b/src/html/helpfrm.cpp
@@ -85,12 +85,20 @@ void wxHtmlHelpFrame::Init(wxHtmlHelpData* data)
m_helpController = (wxHtmlHelpController*) NULL;
}
+void wxHtmlHelpFrame::SetController(wxHtmlHelpController* controller)
+{
+ m_helpController = controller;
+ if ( m_HtmlHelpWin )
+ m_HtmlHelpWin->SetController(controller);
+}
+
// Create: builds the GUI components.
bool wxHtmlHelpFrame::Create(wxWindow* parent, wxWindowID id,
const wxString& WXUNUSED(title), int style,
wxConfigBase *config, const wxString& rootpath)
{
m_HtmlHelpWin = new wxHtmlHelpWindow(m_Data);
+ m_HtmlHelpWin->SetController(m_helpController);
if ( config)
m_HtmlHelpWin->UseConfig(config, rootpath);
diff --git a/src/html/helpwnd.cpp b/src/html/helpwnd.cpp
index 7dc36c785e..778594052f 100644
--- a/src/html/helpwnd.cpp
+++ b/src/html/helpwnd.cpp
@@ -592,6 +592,9 @@ bool wxHtmlHelpWindow::Create(wxWindow* parent, wxWindowID id,
wxHtmlHelpWindow::~wxHtmlHelpWindow()
{
+ if ( m_helpController )
+ m_helpController->SetHelpWindow(NULL);
+
delete m_mergedIndex;
// PopEventHandler(); // wxhtmlhelpcontroller (not any more!)