bugfix: hard crash when using _ClipBoard_GetData

Recommended Posts

TripleEntendre 0

TripleEntendre 0

This one's been around a while, and I think maybe I've fixed it. Or something. I'm sure this will help someone, since I've seen this problem go unanswered in the archived bug report forum!

I found this proposed change by looking at examples given for the Clipboard API in other programming languages, and the one *difference* that they all had in common was to lock and copy the memory when reading from the clipboard.

CODE

Func _ClipBoard_GetData_Carefully($iFormat = 1)

Local $hMemory, $tData

Local $hMemoryDest, $hLock

If Not _ClipBoard_IsFormatAvailable($iFormat) Then Return SetError(-1, 0, 0)

If Not _ClipBoard_Open(0) Then Return SetError(-2, 0, 0)

$hMemory = _ClipBoard_GetDataEx($iFormat)

_ClipBoard_Close()

If $hMemory = 0 Then Return SetError(-3, 0, 0)

Switch $iFormat

Case $CF_TEXT, $CF_OEMTEXT

;THIS WAS BAD: $tData = DllStructCreate("char Text[8192]", $hMemory)

$tData = DllStructCreate("char Text[8192]") ; do it this way so it is allocated...?

$hMemoryDest = DllStructGetPtr($tData)

; so let's lock that clipboard memory down and make our own for-sure copy.

Share this post

Link to post

Share on other sites

TripleEntendre 0

TripleEntendre 0

The old Bug Report forum only exists as an historical archive. Did you look for this issue in the Bug Trac that is now actively used?

Thanks, I have submitted this as a bug/bugfix.

I wish I could figure out just *why* I find Trac so impenetrable. I really *want* to like it, but there's something about it that just sits there, not looking like one could actually *do* anything with it. Maybe it's something that some shiny chrome could fix. *shrug*