use AllocExclusive() instead of duplicating its code in wxFont-specific Unshare(); this fixes recreating the font whenever it is modified (even if it's not shared) bug
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44507 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -120,11 +120,6 @@ public:
|
|||||||
// for consistency with other wxMSW classes
|
// for consistency with other wxMSW classes
|
||||||
WXHFONT GetHFONT() const;
|
WXHFONT GetHFONT() const;
|
||||||
|
|
||||||
/*
|
|
||||||
virtual bool UseResource();
|
|
||||||
virtual bool ReleaseResource();
|
|
||||||
*/
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// real font creation function, used in all cases
|
// real font creation function, used in all cases
|
||||||
bool DoCreate(int size,
|
bool DoCreate(int size,
|
||||||
@@ -139,7 +134,9 @@ protected:
|
|||||||
|
|
||||||
virtual void DoSetNativeFontInfo(const wxNativeFontInfo& info);
|
virtual void DoSetNativeFontInfo(const wxNativeFontInfo& info);
|
||||||
|
|
||||||
void Unshare();
|
// implement wxObject virtuals which are used by AllocExclusive()
|
||||||
|
virtual wxObjectRefData *CreateRefData() const;
|
||||||
|
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_DYNAMIC_CLASS(wxFont)
|
DECLARE_DYNAMIC_CLASS(wxFont)
|
||||||
|
@@ -857,6 +857,16 @@ wxFont::~wxFont()
|
|||||||
// real implementation
|
// real implementation
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wxObjectRefData *wxFont::CreateRefData() const
|
||||||
|
{
|
||||||
|
return new wxFontRefData();
|
||||||
|
}
|
||||||
|
|
||||||
|
wxObjectRefData *wxFont::CloneRefData(const wxObjectRefData *data) const
|
||||||
|
{
|
||||||
|
return new wxFontRefData(*wx_static_cast(const wxFontRefData *, data));
|
||||||
|
}
|
||||||
|
|
||||||
bool wxFont::RealizeResource()
|
bool wxFont::RealizeResource()
|
||||||
{
|
{
|
||||||
if ( GetResourceHandle() )
|
if ( GetResourceHandle() )
|
||||||
@@ -896,28 +906,13 @@ bool wxFont::IsFree() const
|
|||||||
return M_FONTDATA && (M_FONTDATA->GetHFONT() == 0);
|
return M_FONTDATA && (M_FONTDATA->GetHFONT() == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxFont::Unshare()
|
|
||||||
{
|
|
||||||
// Don't change shared data
|
|
||||||
if ( !m_refData )
|
|
||||||
{
|
|
||||||
m_refData = new wxFontRefData();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
wxFontRefData* ref = new wxFontRefData(*M_FONTDATA);
|
|
||||||
UnRef();
|
|
||||||
m_refData = ref;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// change font attribute: we recreate font when doing it
|
// change font attribute: we recreate font when doing it
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void wxFont::SetPointSize(int pointSize)
|
void wxFont::SetPointSize(int pointSize)
|
||||||
{
|
{
|
||||||
Unshare();
|
AllocExclusive();
|
||||||
|
|
||||||
M_FONTDATA->SetPointSize(pointSize);
|
M_FONTDATA->SetPointSize(pointSize);
|
||||||
|
|
||||||
@@ -926,7 +921,7 @@ void wxFont::SetPointSize(int pointSize)
|
|||||||
|
|
||||||
void wxFont::SetPixelSize(const wxSize& pixelSize)
|
void wxFont::SetPixelSize(const wxSize& pixelSize)
|
||||||
{
|
{
|
||||||
Unshare();
|
AllocExclusive();
|
||||||
|
|
||||||
M_FONTDATA->SetPixelSize(pixelSize);
|
M_FONTDATA->SetPixelSize(pixelSize);
|
||||||
|
|
||||||
@@ -935,7 +930,7 @@ void wxFont::SetPixelSize(const wxSize& pixelSize)
|
|||||||
|
|
||||||
void wxFont::SetFamily(int family)
|
void wxFont::SetFamily(int family)
|
||||||
{
|
{
|
||||||
Unshare();
|
AllocExclusive();
|
||||||
|
|
||||||
M_FONTDATA->SetFamily(family);
|
M_FONTDATA->SetFamily(family);
|
||||||
|
|
||||||
@@ -944,7 +939,7 @@ void wxFont::SetFamily(int family)
|
|||||||
|
|
||||||
void wxFont::SetStyle(int style)
|
void wxFont::SetStyle(int style)
|
||||||
{
|
{
|
||||||
Unshare();
|
AllocExclusive();
|
||||||
|
|
||||||
M_FONTDATA->SetStyle(style);
|
M_FONTDATA->SetStyle(style);
|
||||||
|
|
||||||
@@ -953,7 +948,7 @@ void wxFont::SetStyle(int style)
|
|||||||
|
|
||||||
void wxFont::SetWeight(int weight)
|
void wxFont::SetWeight(int weight)
|
||||||
{
|
{
|
||||||
Unshare();
|
AllocExclusive();
|
||||||
|
|
||||||
M_FONTDATA->SetWeight(weight);
|
M_FONTDATA->SetWeight(weight);
|
||||||
|
|
||||||
@@ -962,7 +957,7 @@ void wxFont::SetWeight(int weight)
|
|||||||
|
|
||||||
bool wxFont::SetFaceName(const wxString& faceName)
|
bool wxFont::SetFaceName(const wxString& faceName)
|
||||||
{
|
{
|
||||||
Unshare();
|
AllocExclusive();
|
||||||
|
|
||||||
bool refdataok = M_FONTDATA->SetFaceName(faceName);
|
bool refdataok = M_FONTDATA->SetFaceName(faceName);
|
||||||
|
|
||||||
@@ -980,7 +975,7 @@ bool wxFont::SetFaceName(const wxString& faceName)
|
|||||||
|
|
||||||
void wxFont::SetUnderlined(bool underlined)
|
void wxFont::SetUnderlined(bool underlined)
|
||||||
{
|
{
|
||||||
Unshare();
|
AllocExclusive();
|
||||||
|
|
||||||
M_FONTDATA->SetUnderlined(underlined);
|
M_FONTDATA->SetUnderlined(underlined);
|
||||||
|
|
||||||
@@ -989,7 +984,7 @@ void wxFont::SetUnderlined(bool underlined)
|
|||||||
|
|
||||||
void wxFont::SetEncoding(wxFontEncoding encoding)
|
void wxFont::SetEncoding(wxFontEncoding encoding)
|
||||||
{
|
{
|
||||||
Unshare();
|
AllocExclusive();
|
||||||
|
|
||||||
M_FONTDATA->SetEncoding(encoding);
|
M_FONTDATA->SetEncoding(encoding);
|
||||||
|
|
||||||
@@ -998,9 +993,7 @@ void wxFont::SetEncoding(wxFontEncoding encoding)
|
|||||||
|
|
||||||
void wxFont::DoSetNativeFontInfo(const wxNativeFontInfo& info)
|
void wxFont::DoSetNativeFontInfo(const wxNativeFontInfo& info)
|
||||||
{
|
{
|
||||||
Unshare();
|
AllocExclusive();
|
||||||
|
|
||||||
FreeResource();
|
|
||||||
|
|
||||||
*M_FONTDATA = wxFontRefData(info);
|
*M_FONTDATA = wxFontRefData(info);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user