GUID handling issue
issueid=334 13-11-2011 21:55
Super Moderator
Number of reported issues by Petr Schreiber: 127
GUID handling issue
GUID variable handling is not consitent with the rest of the variable types

There is an issue with GUID handling, the following code demonstrates the problem:
Uses "Console"      
 
' -- Classic Long variable
Dim lVar As Long

 
PrintL SizeOf(lVar), SizeOf(Long), "<-- should match, it does, GOOD"
 
' -- Long in UDT
Type tWithLong
  longItem As Long
End Type
Dim lVarFromType As tWithLong
 
PrintL SizeOf(lVarFromType), SizeOf(tWithLong), "<-- should match, it does, GOOD"
          
' -- Classic GUID variable
Dim gVar As Guid
 
PrintL SizeOf(gVar), SizeOf(Guid), "<-- should both equal to 16, it doesn't :("
 
' -- GUID in UDT
Type tWithGUID
  guidItem As Guid
End Type                                                                             
Dim gVarFromType As tWithGUID
                                                                  

PrintL SizeOf(gVarFromType), SizeOf(tWithGUID), "<-- should both equal to 16, it doesn't :("
 
WaitKey
The most troubling part is the UDT integration, but the good news is that there is possible workaround. Instead of dimensioning UDT property AS GUID, you might use AS STRING * 16.
It will have the expected effect and the problem with incorrect UDT size will go away.


Petr
Issue Details
Issue Number 334
Project thinBasic
Category Core engine (thinCore.dll)
Status Fixed
Priority 3
Affected Version 1.8.9
Fixed Version 1.9.1
Milestone thinBasic 1.9.0.0
Users able to reproduce bug 0
Users unable to reproduce bug 0
Assigned Users (none)
Tags (none)




16-11-2011 16:20
thinBasic author
Ok, this is fixed.
GUID inside UDT was not even a considered option. Now it is.

But problem is still open because I'm now checking if reading and writing GUID variables is ok.

If you have an example of GUID usage to test I will check it.

16-11-2011 17:23
thinBasic author
Petr,

I've updated thinBasic 1.9.0.0 at the usual web link so you can test what I've already done:
http://www.thinbasic.biz/projects/th...ic_1.9.0.0.zip

Ciao
Eros

16-11-2011 18:41
thinBasic author
Petr,

I've updated again thinBasic 1.9.0.0 at the usual web link so you can test what I've already done:
http://www.thinbasic.biz/projects/th...ic_1.9.0.0.zip

I should have implemented GUID assignment and data retrieving for standard GUID variables also when included inside UDT.
Example:

USES "CONSOLE"

' -- GUID in UDT
Type tWithGUID
  guidItem    As Guid
  oID1        As Guid
  oID2        As Guid
  stringitem  As String * 16
End Type                                                                             
Dim gVarFromType As tWithGUID


gVarFromType.oID1 = Guid$("{01234567-89AB-CDEF-FEDC-BA9876543210}")
gVarFromType.oID2 = Guid$("The GUID we need is shown as {0123456789ABCDEFFEDCBA9876543210}")


'---Full UDT                                                                  
PrintL SizeOf(gVarFromType), SizeOf(tWithGUID), "<-- should both equal to 32"


'---Single elements
PrintL SizeOf(gVarFromType.guidItem), SizeOf(gVarFromType.stringitem), "<-- should both equal to 16"


PrintL "GUID1", GuidTxt$(gVarFromType.oID1)
PrintL "GUID2", GuidTxt$(gVarFromType.oID2)


WaitKey

17-11-2011 10:11
Super Moderator
Thanks,

according to my tests the GUIDs work as expected.
I tried your example, where I get correct sizes 64 & 16, and also the Josť's GDI+ samples seem to behave as they should :)


Petr

+ Reply