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:
Julian Smart
2010-06-07 07:39:45 +00:00
parent 74589ae82f
commit dbf712b607
2 changed files with 28 additions and 9 deletions

View File

@@ -95,6 +95,7 @@ All (GUI):
- wxRTC: fixed style selection resetting after editing a style.
- wxRTC: can now edit line spacing in .1 increments from 1 to 2.
- wxRTC: GetStyleMergedWithBase now detects loops.
wxMSW:

View File

@@ -56,17 +56,35 @@ bool wxRichTextStyleDefinition::Eq(const wxRichTextStyleDefinition& def) const
/// Gets the style combined with the base style
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);
if (baseStyle)
{
wxRichTextAttr baseAttr = baseStyle->GetStyleMergedWithBase(sheet);
baseAttr.Apply(m_style, NULL);
return baseAttr;
}
styles.Insert((wxObject*) def);
styleNames.Add(def->GetName());
wxString baseStyleName = def->GetBaseStyle();
if (!baseStyleName.IsEmpty() && styleNames.Index(baseStyleName) == wxNOT_FOUND)
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;
}
/*!