[PATCH] richedit: Only notify selection change when selection has actually changed from previous notification. Otherwise, redundant and early notifications are sent to apps that do not expect them. Fixes crash #1 with Perfect! TextEdit.
Alex Villacís Lasso
alex at karlalex.palosanto.com
Sun Apr 27 13:08:55 CDT 2008
---
dlls/riched20/caret.c | 10 +++++++++-
dlls/riched20/editor.c | 2 ++
dlls/riched20/editstr.h | 3 +++
3 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c
index 7e7b66a..68cac62 100644
--- a/dlls/riched20/caret.c
+++ b/dlls/riched20/caret.c
@@ -1330,7 +1330,15 @@ void ME_SendSelChange(ME_TextEditor *editor)
sc.seltyp |= SEL_TEXT;
if (sc.chrg.cpMin < sc.chrg.cpMax+1) /* wth were RICHEDIT authors thinking ? */
sc.seltyp |= SEL_MULTICHAR;
- SendMessageW(GetParent(editor->hWnd), WM_NOTIFY, sc.nmhdr.idFrom, (LPARAM)&sc);
+ TRACE("cpMin=%d cpMax=%d seltyp=%d (%s %s)\n",
+ sc.chrg.cpMin, sc.chrg.cpMax, sc.seltyp,
+ (sc.seltyp & SEL_TEXT) ? "SEL_TEXT" : "",
+ (sc.seltyp & SEL_MULTICHAR) ? "SEL_MULTICHAR" : "");
+ if (sc.chrg.cpMin != editor->notified_cr.cpMin || sc.chrg.cpMax != editor->notified_cr.cpMax)
+ {
+ editor->notified_cr = sc.chrg;
+ SendMessageW(GetParent(editor->hWnd), WM_NOTIFY, sc.nmhdr.idFrom, (LPARAM)&sc);
+ }
}
BOOL
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index d143619..9f357bb 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -1665,6 +1665,8 @@ ME_TextEditor *ME_MakeEditor(HWND hWnd) {
else
ed->cPasswordMask = 0;
+ ed->notified_cr.cpMin = ed->notified_cr.cpMax = 0;
+
return ed;
}
diff --git a/dlls/riched20/editstr.h b/dlls/riched20/editstr.h
index aedaefa..8f69673 100644
--- a/dlls/riched20/editstr.h
+++ b/dlls/riched20/editstr.h
@@ -331,6 +331,9 @@ typedef struct tagME_TextEditor
/*for IME */
int imeStartIndex;
DWORD selofs, linesel, sely;
+
+ /* Track previous notified selection */
+ CHARRANGE notified_cr;
} ME_TextEditor;
typedef struct tagME_Context
--
1.5.4.1
--------------020404080504060505090009--
More information about the wine-patches
mailing list