fixed static members
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3131 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -116,8 +116,14 @@ class WXDLLEXPORT wxFileSystemHandler : public wxObject
|
|||||||
// Returns MIME type of the file - w/o need to open it
|
// Returns MIME type of the file - w/o need to open it
|
||||||
// (default behaviour is that it returns type based on extension)
|
// (default behaviour is that it returns type based on extension)
|
||||||
|
|
||||||
|
public:
|
||||||
|
static void CleanUpStatics();
|
||||||
|
// deletes static members (m_MimeMng). It can be called
|
||||||
|
// as many times as you wish because m_MimeMng is created
|
||||||
|
// on demand
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static wxMimeTypesManager m_MimeMng;
|
static wxMimeTypesManager *m_MimeMng;
|
||||||
// MIME manager
|
// MIME manager
|
||||||
// (it's static and thus shared by all instances and derived classes)
|
// (it's static and thus shared by all instances and derived classes)
|
||||||
};
|
};
|
||||||
|
@@ -109,7 +109,7 @@ class WXDLLEXPORT wxHtmlWindow : public wxScrolledWindow
|
|||||||
|
|
||||||
static wxList m_Filters;
|
static wxList m_Filters;
|
||||||
// list of HTML filters
|
// list of HTML filters
|
||||||
static wxHtmlFilterPlainText m_DefaultFilter;
|
static wxHtmlFilter *m_DefaultFilter;
|
||||||
// this filter is used when no filter is able to read some file
|
// this filter is used when no filter is able to read some file
|
||||||
|
|
||||||
HtmlHistoryArray m_History;
|
HtmlHistoryArray m_History;
|
||||||
@@ -190,6 +190,9 @@ class WXDLLEXPORT wxHtmlWindow : public wxScrolledWindow
|
|||||||
// called when users clicked on hypertext link. Default behavior is to
|
// called when users clicked on hypertext link. Default behavior is to
|
||||||
// call LoadPage(loc)
|
// call LoadPage(loc)
|
||||||
|
|
||||||
|
static void CleanUpStatics();
|
||||||
|
// cleans static variables
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool ScrollToAnchor(const wxString& anchor);
|
bool ScrollToAnchor(const wxString& anchor);
|
||||||
// Scrolls to anchor of this name. (Anchor is #news
|
// Scrolls to anchor of this name. (Anchor is #news
|
||||||
@@ -207,6 +210,9 @@ class WXDLLEXPORT wxHtmlWindow : public wxScrolledWindow
|
|||||||
void OnIdle(wxIdleEvent& event);
|
void OnIdle(wxIdleEvent& event);
|
||||||
void OnKeyDown(wxKeyEvent& event);
|
void OnKeyDown(wxKeyEvent& event);
|
||||||
|
|
||||||
|
virtual wxHtmlFilter *GetDefaultFilter() {return new wxHtmlFilterPlainText;}
|
||||||
|
// returns new filter (will be stored into m_DefaultFilter variable)
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -35,7 +35,13 @@
|
|||||||
|
|
||||||
IMPLEMENT_ABSTRACT_CLASS(wxFileSystemHandler, wxObject)
|
IMPLEMENT_ABSTRACT_CLASS(wxFileSystemHandler, wxObject)
|
||||||
|
|
||||||
wxMimeTypesManager wxFileSystemHandler::m_MimeMng;
|
wxMimeTypesManager *wxFileSystemHandler::m_MimeMng = NULL;
|
||||||
|
|
||||||
|
void wxFileSystemHandler::CleanUpStatics()
|
||||||
|
{
|
||||||
|
if (m_MimeMng) delete m_MimeMng;
|
||||||
|
m_MimeMng = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
wxString wxFileSystemHandler::GetMimeTypeFromExt(const wxString& location)
|
wxString wxFileSystemHandler::GetMimeTypeFromExt(const wxString& location)
|
||||||
@@ -53,7 +59,8 @@ wxString wxFileSystemHandler::GetMimeTypeFromExt(const wxString& location)
|
|||||||
if (c == _T('.')) {ext = loc.Right(l2-i-1); break;}
|
if (c == _T('.')) {ext = loc.Right(l2-i-1); break;}
|
||||||
if ((c == _T('/')) || (c == _T('\\')) || (c == _T(':'))) {return wxEmptyString;}
|
if ((c == _T('/')) || (c == _T('\\')) || (c == _T(':'))) {return wxEmptyString;}
|
||||||
}
|
}
|
||||||
ft = m_MimeMng.GetFileTypeFromExtension(ext);
|
if (m_MimeMng == NULL) m_MimeMng = new wxMimeTypesManager;
|
||||||
|
ft = m_MimeMng -> GetFileTypeFromExtension(ext);
|
||||||
if (ft && (ft -> GetMimeType(&mime))) return mime;
|
if (ft && (ft -> GetMimeType(&mime))) return mime;
|
||||||
else return wxEmptyString;
|
else return wxEmptyString;
|
||||||
}
|
}
|
||||||
@@ -279,7 +286,10 @@ class wxFileSystemModule : public wxModule
|
|||||||
wxFileSystem::AddHandler(new wxLocalFSHandler);
|
wxFileSystem::AddHandler(new wxLocalFSHandler);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
virtual void OnExit() {}
|
virtual void OnExit()
|
||||||
|
{
|
||||||
|
wxFileSystemHandler::CleanUpStatics();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxFileSystemModule, wxModule)
|
IMPLEMENT_DYNAMIC_CLASS(wxFileSystemModule, wxModule)
|
||||||
@@ -287,3 +297,5 @@ IMPLEMENT_DYNAMIC_CLASS(wxFileSystemModule, wxModule)
|
|||||||
#endif
|
#endif
|
||||||
// (wxUSE_FS_INET || wxUSE_FS_ZIP) && wxUSE_STREAMS
|
// (wxUSE_FS_INET || wxUSE_FS_ZIP) && wxUSE_STREAMS
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -195,7 +195,10 @@ bool wxHtmlWindow::LoadPage(const wxString& location)
|
|||||||
}
|
}
|
||||||
node = node -> GetNext();
|
node = node -> GetNext();
|
||||||
}
|
}
|
||||||
if (src == wxEmptyString) src = m_DefaultFilter.ReadFile(*f);
|
if (src == wxEmptyString) {
|
||||||
|
if (m_DefaultFilter == NULL) m_DefaultFilter = GetDefaultFilter();
|
||||||
|
src = m_DefaultFilter -> ReadFile(*f);
|
||||||
|
}
|
||||||
|
|
||||||
m_FS -> ChangePathTo(f -> GetLocation());
|
m_FS -> ChangePathTo(f -> GetLocation());
|
||||||
rt_val = SetPage(src);
|
rt_val = SetPage(src);
|
||||||
@@ -377,7 +380,15 @@ void wxHtmlWindow::HistoryClear()
|
|||||||
|
|
||||||
|
|
||||||
wxList wxHtmlWindow::m_Filters;
|
wxList wxHtmlWindow::m_Filters;
|
||||||
wxHtmlFilterPlainText wxHtmlWindow::m_DefaultFilter;
|
wxHtmlFilter *wxHtmlWindow::m_DefaultFilter = NULL;
|
||||||
|
|
||||||
|
void wxHtmlWindow::CleanUpStatics()
|
||||||
|
{
|
||||||
|
if (m_DefaultFilter) delete m_DefaultFilter;
|
||||||
|
m_DefaultFilter = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void wxHtmlWindow::AddFilter(wxHtmlFilter *filter)
|
void wxHtmlWindow::AddFilter(wxHtmlFilter *filter)
|
||||||
{
|
{
|
||||||
@@ -525,6 +536,21 @@ END_EVENT_TABLE()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// A module to allow initialization/cleanup
|
||||||
|
// without calling these functions from app.cpp or from
|
||||||
|
// the user's application.
|
||||||
|
|
||||||
|
class wxHtmlWinModule: public wxModule
|
||||||
|
{
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxHtmlWinModule)
|
||||||
|
public:
|
||||||
|
wxHtmlWinModule() : wxModule() {}
|
||||||
|
bool OnInit() { return TRUE; }
|
||||||
|
void OnExit() { wxHtmlWindow::CleanUpStatics(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxHtmlWinModule, wxModule)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user