Applied 1215477, fixing a crash by properly removing
a file system handler in a module. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41033 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -188,6 +188,10 @@ public:
|
|||||||
// In fact, this class is only front-end to the FS handlers :-)
|
// In fact, this class is only front-end to the FS handlers :-)
|
||||||
static void AddHandler(wxFileSystemHandler *handler);
|
static void AddHandler(wxFileSystemHandler *handler);
|
||||||
|
|
||||||
|
// Removes FS handler
|
||||||
|
static wxFileSystemHandler* RemoveHandler(wxFileSystemHandler *handler);
|
||||||
|
|
||||||
|
|
||||||
// Returns true if there is a handler which can open the given location.
|
// Returns true if there is a handler which can open the given location.
|
||||||
static bool HasHandlerForPath(const wxString& location);
|
static bool HasHandlerForPath(const wxString& location);
|
||||||
|
|
||||||
|
@@ -487,6 +487,20 @@ void wxFileSystem::AddHandler(wxFileSystemHandler *handler)
|
|||||||
m_Handlers.Insert((size_t)0, handler);
|
m_Handlers.Insert((size_t)0, handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxFileSystemHandler* wxFileSystem::RemoveHandler(wxFileSystemHandler *handler)
|
||||||
|
{
|
||||||
|
// if handler has already been removed (or deleted)
|
||||||
|
// we return NULL. This is by design in case
|
||||||
|
// CleanUpHandlers() is called before RemoveHandler
|
||||||
|
// is called, as we cannot control the order
|
||||||
|
// which modules are unloaded
|
||||||
|
if (!m_Handlers.DeleteObject(handler))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool wxFileSystem::HasHandlerForPath(const wxString &location)
|
bool wxFileSystem::HasHandlerForPath(const wxString &location)
|
||||||
{
|
{
|
||||||
for ( wxList::compatibility_iterator node = m_Handlers.GetFirst();
|
for ( wxList::compatibility_iterator node = m_Handlers.GetFirst();
|
||||||
@@ -589,15 +603,28 @@ class wxFileSystemModule : public wxModule
|
|||||||
DECLARE_DYNAMIC_CLASS(wxFileSystemModule)
|
DECLARE_DYNAMIC_CLASS(wxFileSystemModule)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
wxFileSystemModule() :
|
||||||
|
wxModule(),
|
||||||
|
m_handler(NULL)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
virtual bool OnInit()
|
virtual bool OnInit()
|
||||||
{
|
{
|
||||||
wxFileSystem::AddHandler(new wxLocalFSHandler);
|
m_handler = new wxLocalFSHandler;
|
||||||
|
wxFileSystem::AddHandler(m_handler);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
virtual void OnExit()
|
virtual void OnExit()
|
||||||
{
|
{
|
||||||
|
delete wxFileSystem::RemoveHandler(m_handler);
|
||||||
|
|
||||||
wxFileSystem::CleanUpHandlers();
|
wxFileSystem::CleanUpHandlers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxFileSystemHandler* m_handler;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxFileSystemModule, wxModule)
|
IMPLEMENT_DYNAMIC_CLASS(wxFileSystemModule, wxModule)
|
||||||
|
@@ -140,12 +140,26 @@ class wxFileSystemInternetModule : public wxModule
|
|||||||
DECLARE_DYNAMIC_CLASS(wxFileSystemInternetModule)
|
DECLARE_DYNAMIC_CLASS(wxFileSystemInternetModule)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
wxFileSystemInternetModule() :
|
||||||
|
wxModule(),
|
||||||
|
m_handler(NULL)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
virtual bool OnInit()
|
virtual bool OnInit()
|
||||||
{
|
{
|
||||||
wxFileSystem::AddHandler(new wxInternetFSHandler);
|
m_handler = new wxInternetFSHandler;
|
||||||
|
wxFileSystem::AddHandler(m_handler);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
virtual void OnExit() {}
|
|
||||||
|
virtual void OnExit()
|
||||||
|
{
|
||||||
|
delete wxFileSystem::RemoveHandler(m_handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxFileSystemHandler* m_handler;
|
||||||
};
|
};
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxFileSystemInternetModule, wxModule)
|
IMPLEMENT_DYNAMIC_CLASS(wxFileSystemInternetModule, wxModule)
|
||||||
|
Reference in New Issue
Block a user