Nikolay Sivov : comctl32/updown: Don't update buddy text if it's the same.
Alexandre Julliard
julliard at winehq.org
Wed Dec 23 10:04:11 CST 2009
Module: wine
Branch: master
Commit: 750ce6be35c44052f453d26aac44b4fe636472f2
URL: http://source.winehq.org/git/wine.git/?a=commit;h=750ce6be35c44052f453d26aac44b4fe636472f2
Author: Nikolay Sivov <bunglehead at gmail.com>
Date: Tue Dec 22 21:58:27 2009 +0300
comctl32/updown: Don't update buddy text if it's the same.
---
dlls/comctl32/tests/updown.c | 36 ++++++++++++++++++++++++++++++++++++
dlls/comctl32/updown.c | 6 +++++-
2 files changed, 41 insertions(+), 1 deletions(-)
diff --git a/dlls/comctl32/tests/updown.c b/dlls/comctl32/tests/updown.c
index dacc460..fef53bf 100644
--- a/dlls/comctl32/tests/updown.c
+++ b/dlls/comctl32/tests/updown.c
@@ -59,6 +59,9 @@
#define EDIT_SEQ_INDEX 1
#define UPDOWN_SEQ_INDEX 2
+#define UPDOWN_ID 0
+#define BUDDY_ID 1
+
static HWND parent_wnd, g_edit;
static BOOL (WINAPI *pSetWindowSubclass)(HWND, SUBCLASSPROC, UINT_PTR, DWORD_PTR);
@@ -156,6 +159,11 @@ static const struct message test_updown_unicode_seq[] = {
{ 0 }
};
+static const struct message test_updown_pos_nochange_seq[] = {
+ { WM_GETTEXT, sent|id, 0, 0, BUDDY_ID },
+ { 0 }
+};
+
static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static LONG defwndproc_counter = 0;
@@ -233,6 +241,7 @@ static LRESULT WINAPI edit_subclass_proc(HWND hwnd, UINT message, WPARAM wParam,
if (defwndproc_counter) msg.flags |= defwinproc;
msg.wParam = wParam;
msg.lParam = lParam;
+ msg.id = BUDDY_ID;
add_message(sequences, EDIT_SEQ_INDEX, &msg);
defwndproc_counter++;
@@ -274,6 +283,7 @@ static LRESULT WINAPI updown_subclass_proc(HWND hwnd, UINT message, WPARAM wPara
if (defwndproc_counter) msg.flags |= defwinproc;
msg.wParam = wParam;
msg.lParam = lParam;
+ msg.id = UPDOWN_ID;
add_message(sequences, UPDOWN_SEQ_INDEX, &msg);
defwndproc_counter++;
@@ -360,6 +370,19 @@ static void test_updown_pos(void)
ok_sequence(sequences, UPDOWN_SEQ_INDEX, test_updown_pos_seq , "test updown pos", FALSE);
DestroyWindow(updown);
+
+ /* there's no attempt to update buddy Edit if text didn't change */
+ SetWindowTextA(g_edit, "50");
+ updown = create_updown_control(UDS_ALIGNRIGHT | UDS_SETBUDDYINT, g_edit);
+
+ flush_sequences(sequences, NUM_MSG_SEQUENCES);
+
+ r = SendMessage(updown, UDM_SETPOS, 0, 50);
+ expect(50,r);
+ ok_sequence(sequences, EDIT_SEQ_INDEX, test_updown_pos_nochange_seq,
+ "test updown pos, no change", FALSE);
+
+ DestroyWindow(updown);
}
static void test_updown_pos32(void)
@@ -434,6 +457,19 @@ static void test_updown_pos32(void)
ok_sequence(sequences, UPDOWN_SEQ_INDEX, test_updown_pos32_seq, "test updown pos32", FALSE);
DestroyWindow(updown);
+
+ /* there's no attempt to update buddy Edit if text didn't change */
+ SetWindowTextA(g_edit, "50");
+ updown = create_updown_control(UDS_ALIGNRIGHT | UDS_SETBUDDYINT, g_edit);
+
+ flush_sequences(sequences, NUM_MSG_SEQUENCES);
+
+ r = SendMessage(updown, UDM_SETPOS32, 0, 50);
+ expect(50,r);
+ ok_sequence(sequences, EDIT_SEQ_INDEX, test_updown_pos_nochange_seq,
+ "test updown pos, no change", FALSE);
+
+ DestroyWindow(updown);
}
static void test_updown_buddy(void)
diff --git a/dlls/comctl32/updown.c b/dlls/comctl32/updown.c
index 127bb40..776d72e 100644
--- a/dlls/comctl32/updown.c
+++ b/dlls/comctl32/updown.c
@@ -310,7 +310,7 @@ static BOOL UPDOWN_GetBuddyInt (UPDOWN_INFO *infoPtr)
static BOOL UPDOWN_SetBuddyInt (const UPDOWN_INFO *infoPtr)
{
WCHAR fmt[3] = { '%', 'd', '\0' };
- WCHAR txt[20];
+ WCHAR txt[20], txt_old[20] = { 0 };
int len;
if (!((infoPtr->Flags & FLAG_BUDDYINT) && IsWindow(infoPtr->Buddy)))
@@ -345,6 +345,10 @@ static BOOL UPDOWN_SetBuddyInt (const UPDOWN_INFO *infoPtr)
*dst = 0;
}
+ /* if nothing changed exit earlier */
+ GetWindowTextW(infoPtr->Buddy, txt_old, sizeof(txt_old)/sizeof(WCHAR));
+ if (lstrcmpiW(txt_old, txt) == 0) return 0;
+
return SetWindowTextW(infoPtr->Buddy, txt);
}
More information about the wine-cvs
mailing list