X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/02aa812cb0e5a1ae7fcf827f53f9d41cb0e53c6b..17d98558b35b75e3cad68d96841b4fa5a0c7e6ee:/src/richtext/richtextstyles.cpp?ds=sidebyside diff --git a/src/richtext/richtextstyles.cpp b/src/richtext/richtextstyles.cpp index 00b24a319a..6e47ba618e 100644 --- a/src/richtext/richtextstyles.cpp +++ b/src/richtext/richtextstyles.cpp @@ -56,17 +56,35 @@ bool wxRichTextStyleDefinition::Eq(const wxRichTextStyleDefinition& def) const /// Gets the style combined with the base style wxTextAttr 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) - { - wxTextAttr 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; + } + + wxRichTextAttr attr; + wxList::compatibility_iterator node = styles.GetFirst(); + while (node) + { + wxRichTextStyleDefinition* def = (wxRichTextStyleDefinition*) node->GetData(); + attr.Apply(def->GetStyle(), NULL); + node = node->GetNext(); } - return m_style; + + return attr; } /*!