Copy&Paste from VB6 add binary chars
Windows visual diff and merge for files and directories
Brought to you by:
christianlist,
grimmdp
example screenshot
Logged In: YES
user_id=631874
Originator: NO
Looks like unicode chars?
Logged In: YES
user_id=652377
Originator: YES
WinMerge.exe has the same problem. Normally I work with WinMergeU.exe.
Logged In: YES
user_id=954028
Originator: NO
It seems that we should not suppose that the size of text in clipboard does not equal the size of clipboard data if using an external application.
Here is the fix:
Index: .
--- . (revision 5104)
+++ . (working copy)
@@ -1215,6 +1215,8 @@
GlobalUnlock (hData);
UINT fmt = GetClipTcharTextFormat();
bOK = SetClipboardData (fmt, hData) != NULL;
+ if (bOK)
+ SetClipboardData (RegisterClipboardFormat (_T("WinMergeClipboard")), NULL);
}
CloseClipboard ();
}
@@ -1240,6 +1242,20 @@
memcpy(text.GetBufferSetLength(cchText), pszData, cbData);
GlobalUnlock (hData);
bSuccess = TRUE;
+ BOOL bWinMergeClipboardFormat = FALSE;
+ UINT nFormat = 0;
+ UINT nWinMergeClipboardFormat = RegisterClipboardFormat (_T("WinMergeClipboard"));
+ while (nFormat = EnumClipboardFormats (nFormat))
+ {
+ if (nFormat == nWinMergeClipboardFormat)
+ bWinMergeClipboardFormat = TRUE;
+ }
+ if (!bWinMergeClipboardFormat)
+ {
+ // truncate the data after the first null
+ CString tmp = (LPCTSTR)text;
+ text = tmp;
+ }
}
}
CloseClipboard ();
Logged In: YES
user_id=631874
Originator: NO
> Index: .
Doesn't tell the file patched...
I don't understand the reasoning? What change broke this clipboard paste? And why? What we do now differently than we've done in past years?
Tim, can you check what experimental is first broken one? And if that happens to be the first experimental that has this binary file viewing?
Logged In: YES
user_id=954028
Originator: NO
>Doesn't tell the file patched...
Sorry. The file patched is ccrystaltextview2.cpp.
>What change broke this clipboard paste?
r4983 [Patch #1880711]
>And why? What we do now differently than we've done in past years?
Now we can copy&paste nul characters.
>I don't understand the reasoning?
We currently expect that the size of text equals clipboard memory size.
But VB6 allocates memory larger than the size of actual text in clipboard.
Logged In: YES
user_id=954028
Originator: NO
So we should trancate the data after the first null in clipboard if copying from VB6 or external application.
I introduced new clipboard format "WinMergeClipboard" to know whether copied data is from WinMerge or external application.
Logged In: YES
user_id=652377
Originator: YES
With Takashi's patch copy&paste from VB6 works like expected: Without binary chars! :)
Logged In: YES
user_id=631874
Originator: NO
> > And why? What we do now differently than we've done in past years?
> Now we can copy&paste nul characters.
Inside WinMerge, from "binary files" that is? So you are using this new clipboard format for this "binary data" copy/paste between binaries in WinMerge views?
Yes, the patch makes a lot more sense now.
Logged In: YES
user_id=954028
Originator: NO
> Inside WinMerge, from "binary files" that is? So you are using this new
> clipboard format for this "binary data" copy/paste between binaries in
> WinMerge views?
Yes. Sorry for my poor explanation.
Committed to SVN trunk. Completed: At revision: 5105
Logged In: YES
user_id=631874
Originator: NO
I'll close this as fixed as Tim already verified the patch fixes the bug.