fixed mem leak when using non default theme; change the art provider automatically when the theme is changed (patch 646463)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18070 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -121,9 +121,6 @@ bool wxAppBase::OnInitGui()
|
|||||||
#ifdef __WXUNIVERSAL__
|
#ifdef __WXUNIVERSAL__
|
||||||
if ( !wxTheme::Get() && !wxTheme::CreateDefault() )
|
if ( !wxTheme::Get() && !wxTheme::CreateDefault() )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
wxArtProvider *art = wxTheme::Get()->GetArtProvider();
|
|
||||||
if ( art )
|
|
||||||
wxArtProvider::PushProvider(art);
|
|
||||||
#endif // __WXUNIVERSAL__
|
#endif // __WXUNIVERSAL__
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -385,6 +382,8 @@ bool wxAppBase::OnCmdLineParsed(wxCmdLineParser& parser)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete the defaultly created theme and set the new theme.
|
||||||
|
delete wxTheme::Get();
|
||||||
wxTheme::Set(theme);
|
wxTheme::Set(theme);
|
||||||
}
|
}
|
||||||
#endif // __WXUNIVERSAL__
|
#endif // __WXUNIVERSAL__
|
||||||
|
@@ -33,6 +33,8 @@
|
|||||||
#include "wx/log.h"
|
#include "wx/log.h"
|
||||||
#endif // WX_PRECOMP
|
#endif // WX_PRECOMP
|
||||||
|
|
||||||
|
#include "wx/artprov.h"
|
||||||
|
|
||||||
#include "wx/univ/renderer.h"
|
#include "wx/univ/renderer.h"
|
||||||
#include "wx/univ/inphand.h"
|
#include "wx/univ/inphand.h"
|
||||||
#include "wx/univ/theme.h"
|
#include "wx/univ/theme.h"
|
||||||
@@ -106,22 +108,25 @@ wxThemeInfo::wxThemeInfo(Constructor c,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
ms_theme = Create(nameDefTheme);
|
wxTheme *theme = Create(nameDefTheme);
|
||||||
|
|
||||||
// fallback to the first one in the list
|
// fallback to the first one in the list
|
||||||
if ( !ms_theme && ms_allThemes )
|
if ( !theme && ms_allThemes )
|
||||||
{
|
{
|
||||||
ms_theme = ms_allThemes->ctor();
|
theme = ms_allThemes->ctor();
|
||||||
}
|
}
|
||||||
|
|
||||||
// abort if still nothing
|
// abort if still nothing
|
||||||
if ( !ms_theme )
|
if ( !theme )
|
||||||
{
|
{
|
||||||
wxLogError(_("Failed to initialize GUI: no built-in themes found."));
|
wxLogError(_("Failed to initialize GUI: no built-in themes found."));
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set the theme as current.
|
||||||
|
wxTheme::Set(theme);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,6 +134,16 @@ wxThemeInfo::wxThemeInfo(Constructor c,
|
|||||||
{
|
{
|
||||||
wxTheme *themeOld = ms_theme;
|
wxTheme *themeOld = ms_theme;
|
||||||
ms_theme = theme;
|
ms_theme = theme;
|
||||||
|
|
||||||
|
if ( ms_theme )
|
||||||
|
{
|
||||||
|
// automatically start using the art provider of the new theme if it
|
||||||
|
// has one
|
||||||
|
wxArtProvider *art = ms_theme->GetArtProvider();
|
||||||
|
if ( art )
|
||||||
|
wxArtProvider::PushProvider(art);
|
||||||
|
}
|
||||||
|
|
||||||
return themeOld;
|
return themeOld;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user