Static object -> pointer
Clean up renderer in module OnExit or we get a crash on exit (under wxX11 at least). To-do: we need to add priorities to wxModule so we can clean this up last. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@22697 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
15d93f1ebb
commit
0872a451dc
@ -33,9 +33,8 @@
|
||||
|
||||
#include "wx/settings.h"
|
||||
#include "wx/splitter.h"
|
||||
|
||||
#include "wx/dcmirror.h"
|
||||
|
||||
#include "wx/module.h"
|
||||
#include "wx/renderer.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -72,6 +71,11 @@ public:
|
||||
|
||||
virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win);
|
||||
|
||||
// Cleanup by deleting standard renderer
|
||||
static void Cleanup();
|
||||
|
||||
// Get the generic object
|
||||
static wxRendererGeneric* DoGetGeneric();
|
||||
|
||||
protected:
|
||||
// draw the rectange using the first pen for the left and top sides and
|
||||
@ -84,12 +88,22 @@ protected:
|
||||
m_penDarkGrey,
|
||||
m_penLightGrey,
|
||||
m_penHighlight;
|
||||
|
||||
static wxRendererGeneric* sm_rendererGeneric;
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
// wxRendererGeneric implementation
|
||||
// ============================================================================
|
||||
|
||||
// Get the generic object
|
||||
wxRendererGeneric* wxRendererGeneric::DoGetGeneric()
|
||||
{
|
||||
if (!sm_rendererGeneric)
|
||||
sm_rendererGeneric = new wxRendererGeneric;
|
||||
return sm_rendererGeneric;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxRendererGeneric creation
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -97,11 +111,19 @@ protected:
|
||||
/* static */
|
||||
wxRendererNative& wxRendererNative::GetGeneric()
|
||||
{
|
||||
static wxRendererGeneric s_rendererGeneric;
|
||||
|
||||
return s_rendererGeneric;
|
||||
return * wxRendererGeneric::DoGetGeneric();
|
||||
}
|
||||
|
||||
void wxRendererGeneric::Cleanup()
|
||||
{
|
||||
if (sm_rendererGeneric)
|
||||
delete sm_rendererGeneric;
|
||||
|
||||
sm_rendererGeneric = NULL;
|
||||
}
|
||||
|
||||
wxRendererGeneric* wxRendererGeneric::sm_rendererGeneric = NULL;
|
||||
|
||||
wxRendererGeneric::wxRendererGeneric()
|
||||
: m_penBlack(wxSystemSettings::GetColour(wxSYS_COLOUR_3DDKSHADOW)),
|
||||
m_penDarkGrey(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW)),
|
||||
@ -300,3 +322,15 @@ wxRendererGeneric::DrawSplitterSash(wxWindow *win,
|
||||
}
|
||||
}
|
||||
|
||||
// A module to allow cleanup of generic renderer.
|
||||
class wxGenericRendererModule: public wxModule
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxGenericRendererModule)
|
||||
public:
|
||||
wxGenericRendererModule() {}
|
||||
bool OnInit() { return true; };
|
||||
void OnExit() { wxRendererGeneric::Cleanup(); };
|
||||
};
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxGenericRendererModule, wxModule)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user