GetStyleMergedWithBase no longer hangs if there's a loop implied by based-on styles.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@64520 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -95,6 +95,7 @@ All (GUI):
|
|||||||
|
|
||||||
- wxRTC: fixed style selection resetting after editing a style.
|
- wxRTC: fixed style selection resetting after editing a style.
|
||||||
- wxRTC: can now edit line spacing in .1 increments from 1 to 2.
|
- wxRTC: can now edit line spacing in .1 increments from 1 to 2.
|
||||||
|
- wxRTC: GetStyleMergedWithBase now detects loops.
|
||||||
|
|
||||||
wxMSW:
|
wxMSW:
|
||||||
|
|
||||||
|
@@ -56,17 +56,35 @@ bool wxRichTextStyleDefinition::Eq(const wxRichTextStyleDefinition& def) const
|
|||||||
/// Gets the style combined with the base style
|
/// Gets the style combined with the base style
|
||||||
wxRichTextAttr wxRichTextStyleDefinition::GetStyleMergedWithBase(const wxRichTextStyleSheet* sheet) const
|
wxRichTextAttr wxRichTextStyleDefinition::GetStyleMergedWithBase(const wxRichTextStyleSheet* sheet) const
|
||||||
{
|
{
|
||||||
if (!m_baseStyle.IsEmpty())
|
if (m_baseStyle.IsEmpty())
|
||||||
|
return m_style;
|
||||||
|
|
||||||
|
// Collect the styles, detecting loops
|
||||||
|
wxArrayString styleNames;
|
||||||
|
wxList styles;
|
||||||
|
const wxRichTextStyleDefinition* def = this;
|
||||||
|
while (def)
|
||||||
{
|
{
|
||||||
wxRichTextStyleDefinition* baseStyle = sheet->FindStyle(m_baseStyle);
|
styles.Insert((wxObject*) def);
|
||||||
if (baseStyle)
|
styleNames.Add(def->GetName());
|
||||||
{
|
|
||||||
wxRichTextAttr baseAttr = baseStyle->GetStyleMergedWithBase(sheet);
|
wxString baseStyleName = def->GetBaseStyle();
|
||||||
baseAttr.Apply(m_style, NULL);
|
if (!baseStyleName.IsEmpty() && styleNames.Index(baseStyleName) == wxNOT_FOUND)
|
||||||
return baseAttr;
|
def = sheet->FindStyle(baseStyleName);
|
||||||
}
|
else
|
||||||
|
def = NULL;
|
||||||
}
|
}
|
||||||
return m_style;
|
|
||||||
|
wxRichTextAttr attr;
|
||||||
|
wxList::compatibility_iterator node = styles.GetFirst();
|
||||||
|
while (node)
|
||||||
|
{
|
||||||
|
wxRichTextStyleDefinition* def = (wxRichTextStyleDefinition*) node->GetData();
|
||||||
|
attr.Apply(def->GetStyle(), NULL);
|
||||||
|
node = node->GetNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
return attr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
Reference in New Issue
Block a user