Menu

#1680 Copy&Paste from VB6 add binary chars

Trunk
closed-fixed
None
5
2008-03-03
2008-02-28
Tim Gerundt
No

I copy&paste today some text from Visual Basic 6 to WinMerge (2.7.7.6). Unfortunately WinMerge paste now binary chars at the end of the text.

Look at the screenshot to see the chars. They look like paths ("C:\Entwicklung\Microsoft SDK"). If I copy&paste text from Word 2000, IE6 or VC6 I have *no* problems.

WinMerge 2.7.7.3 has the same problem, WinMerge 2.6 not.

Greetings,
Tim

Discussion

  • Tim Gerundt

    Tim Gerundt - 2008-02-28

    example screenshot

     
  • Kimmo Varis

    Kimmo Varis - 2008-02-28

    Logged In: YES
    user_id=631874
    Originator: NO

    Looks like unicode chars?

     
  • Tim Gerundt

    Tim Gerundt - 2008-02-28

    Logged In: YES
    user_id=652377
    Originator: YES

    WinMerge.exe has the same problem. Normally I work with WinMergeU.exe.

     
  • Takashi Sawanaka

    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 ();

     
  • Kimmo Varis

    Kimmo Varis - 2008-03-02

    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?

     
  • Takashi Sawanaka

    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.

     
  • Takashi Sawanaka

    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.

     
  • Tim Gerundt

    Tim Gerundt - 2008-03-02

    Logged In: YES
    user_id=652377
    Originator: YES

    With Takashi's patch copy&paste from VB6 works like expected: Without binary chars! :)

     
  • Kimmo Varis

    Kimmo Varis - 2008-03-02

    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.

     
  • Takashi Sawanaka

    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

     
  • Kimmo Varis

    Kimmo Varis - 2008-03-03
    • assigned_to: nobody --> sdottaka
    • status: open --> closed-fixed
     
  • Kimmo Varis

    Kimmo Varis - 2008-03-03

    Logged In: YES
    user_id=631874
    Originator: NO

    I'll close this as fixed as Tim already verified the patch fixes the bug.

     

Log in to post a comment.

Auth0 Logo