[PATCH 2/3] riched20: Release the font cache when changing the default style.

Huw Davies huw at codeweavers.com
Mon Nov 9 10:11:42 CST 2015


Signed-off-by: Huw Davies <huw at codeweavers.com>
---
 dlls/riched20/run.c   | 19 -------------------
 dlls/riched20/style.c | 28 ++++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 19 deletions(-)

diff --git a/dlls/riched20/run.c b/dlls/riched20/run.c
index d76737a..d261213 100644
--- a/dlls/riched20/run.c
+++ b/dlls/riched20/run.c
@@ -763,25 +763,6 @@ void ME_SetCharFormat(ME_TextEditor *editor, ME_Cursor *start, ME_Cursor *end, C
   }
 }
 
-/******************************************************************************
- * ME_SetDefaultCharFormat
- * 
- * Applies a style change to the default character style.
- */     
-void ME_SetDefaultCharFormat(ME_TextEditor *editor, CHARFORMAT2W *mod)
-{
-  ME_Style *style;
-
-  assert(mod->cbSize == sizeof(CHARFORMAT2W));
-  style = ME_ApplyStyle(editor->pBuffer->pDefaultStyle, mod);
-  editor->pBuffer->pDefaultStyle->fmt = style->fmt;
-  editor->pBuffer->pDefaultStyle->tm = style->tm;
-  ScriptFreeCache( &editor->pBuffer->pDefaultStyle->script_cache );
-  ME_ReleaseStyle(style);
-  ME_MarkAllForWrapping(editor);
-  /*  pcf = editor->pBuffer->pDefaultStyle->fmt; */
-}
-
 static void ME_GetRunCharFormat(ME_TextEditor *editor, ME_DisplayItem *run, CHARFORMAT2W *pFmt)
 {
   ME_CopyCharFormat(pFmt, &run->member.run.style->fmt);
diff --git a/dlls/riched20/style.c b/dlls/riched20/style.c
index 0e990e2..37f56d9 100644
--- a/dlls/riched20/style.c
+++ b/dlls/riched20/style.c
@@ -508,3 +508,31 @@ void ME_ClearTempStyle(ME_TextEditor *editor)
   ME_ReleaseStyle(editor->pBuffer->pCharStyle);
   editor->pBuffer->pCharStyle = NULL;
 }
+
+/******************************************************************************
+ * ME_SetDefaultCharFormat
+ *
+ * Applies a style change to the default character style.
+ *
+ * The default style is special in that it is mutable - runs
+ * in the document that have this style should change if the
+ * default style changes.  That means we need to fix up this
+ * style manually.
+ */
+void ME_SetDefaultCharFormat(ME_TextEditor *editor, CHARFORMAT2W *mod)
+{
+    ME_Style *style, *def = editor->pBuffer->pDefaultStyle;
+
+    assert(mod->cbSize == sizeof(CHARFORMAT2W));
+    style = ME_ApplyStyle(def, mod);
+    def->fmt = style->fmt;
+    def->tm = style->tm;
+    if (def->font_cache)
+    {
+        release_font_cache( def->font_cache );
+        def->font_cache = NULL;
+    }
+    ScriptFreeCache( &def->script_cache );
+    ME_ReleaseStyle( style );
+    ME_MarkAllForWrapping( editor );
+}
-- 
1.8.0




More information about the wine-patches mailing list