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: can now edit line spacing in .1 increments from 1 to 2.
|
||||
- wxRTC: GetStyleMergedWithBase now detects loops.
|
||||
|
||||
wxMSW:
|
||||
|
||||
|
@@ -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())
|
||||
{
|
||||
wxRichTextStyleDefinition* baseStyle = sheet->FindStyle(m_baseStyle);
|
||||
if (baseStyle)
|
||||
{
|
||||
wxRichTextAttr baseAttr = baseStyle->GetStyleMergedWithBase(sheet);
|
||||
baseAttr.Apply(m_style, NULL);
|
||||
return baseAttr;
|
||||
}
|
||||
}
|
||||
if (m_baseStyle.IsEmpty())
|
||||
return m_style;
|
||||
|
||||
// Collect the styles, detecting loops
|
||||
wxArrayString styleNames;
|
||||
wxList styles;
|
||||
const wxRichTextStyleDefinition* def = this;
|
||||
while (def)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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