Modify

#3555 closed Bug (Works For Me)

_GUICtrlRichEdit_StreamToVar with > 2048 characters

Reported by: anthonyjr2 Owned by:
Milestone: Component: Standard UDFs
Version: 3.3.14.2 Severity: None
Keywords: Cc:

Description (last modified by mLipok)

This bug was discussed and solved here: https://www.autoitscript.com/forum/topic/188643-is-_guictrlrichedit_streamtovar-limited-to-2048-chars/

The problem happens when trying to stream a RichEdit with length > 2048 to a variable with _GUICtrlRichEdit_StreamToVar. The stream to file works correctly in this matter. The problem lies within this code which is called by the function:

Func __GCR_StreamToVarCallback($iCookie, $pBuf, $iBuflen, $pQbytes)
	#forceref $iCookie
	Local $tQbytes = DllStructCreate("long", $pQbytes)
	DllStructSetData($tQbytes, 1, 0)
	Local $tBuf = DllStructCreate("char[" & $iBuflen & "]", $pBuf)
	Local $s = DllStructGetData($tBuf, 1)
	$__g_pGRC_sStreamVar &= $s
	Return 0
EndFunc   ;==>__GCR_StreamToVarCallback

The buffer is not updated correctly at the end of the function. The solution is to add a line before the return statement and modify the earlier struct set:

Func __GCR_StreamToVarCallback($iCookie, $pBuf, $iBuflen, $pQbytes)
	#forceref $iCookie
	Local $tQbytes = DllStructCreate("long", $pQbytes)
	DllStructSetData($tQbytes, 1, $iBuflen) ;Modified this line
	Local $tBuf = DllStructCreate("char[" & $iBuflen & "]", $pBuf)
	Local $s = DllStructGetData($tBuf, 1)
	$__g_pGRC_sStreamVar &= $s
	DllStructSetData($tQbytes, 1, StringLen($s)) ;Added this line
	Return 0
EndFunc   ;==>__GCR_StreamToVarCallback

This correctly updates the struct and solves the character limit.

Attachments (0)

Change History (6)

comment:1 by anonymous, on Jun 1, 2017 at 2:56:07 PM

Func GCR_StreamToVarCallback($iCookie, $pBuf, $iBuflen, $pQbytes)

#forceref $iCookie
	Local $tQbytes = DllStructCreate("long", $pQbytes)
	DllStructSetData($tQbytes, 1, 0)
	Local $tBuf = DllStructCreate("char[" & $iBuflen & "]", $pBuf)
	Local $s = DllStructGetData($tBuf, 1)
	$__g_pGRC_sStreamVar &= $s
	DllStructSetData($tQbytes, 1, StringLen($s))
	Return 0

EndFunc ;==>GCR_StreamToVarCallback

I didn't realize the editor messed up my code a bit. This should be better.

comment:2 by mLipok, on Jun 1, 2017 at 8:28:13 PM

Description: modified (diff)

comment:3 by J-Paul Mesnage, on Jun 21, 2017 at 3:34:43 PM

I don't undertstand how updating an in parameter can solve any issue.
If I run the Help example and I paste more the 2048 char it works fine.
So can I have a repro script?
Thanks

comment:4 by J-Paul Mesnage, on Jan 29, 2018 at 3:16:40 PM

Resolution: Works For Me
Status: newclosed

closed as no info supplied

comment:5 by anthonyjr2, on Jun 12, 2018 at 10:00:52 PM

Haven't checked autoIt in a while, but did you look at the issues and tests in the thread posted? It's been a long time so I can't exactly recall what caused the issue but it seemed to be related to the stream buffer. The fix I posted is just what we ended up with after some debugging.

comment:6 by anthonyjr2, on Oct 1, 2018 at 8:24:59 PM

Can confirm this is fixed in AutoIt 3.3.15.1

Modify Ticket

Action
as closed The ticket will remain with no owner.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.