We are getting a very weird error when using a dictionary. Sometimes, the values become corrupted.
Here is an except from debugging the problem.
dim overalls(2) as string
dim d as new dictionary
dim pd as new mydictionary
dim d2 as new dictionary
dim d3 as new xojo.core.dictionary
me.gradedata = new mydictionary
dim overall as string = overalls(0)
dim cmyk as string = overalls(1)
dim spot as string = overalls(2)
me.gradedata.value("overall") = overall
d.value("overall") = overall
pd.value("overall") = overall
d2.Value("overall")="3"
d3.Value("overall")="3"
me.gradedata is a mydictionary class and is a subclass of dictionary. The others are just local variables for testing to compare.
overalls(2) is a string array containing (ā3ā,āā,ā3ā) and can be confirmed by looking in the IDE.
But, when I look at the dictionary, the values for the keys show as empty and the typeinfo of the value contains gibberish āUHļæ½ļæ½AVSIļæ½ļæ½Hļæ½ļæ½ļæ½!fHļæ½ļæ½Lļæ½ļæ½ļæ½fHļæ½Tļæ½Hļæ½8ā
We normally write the dictionary as a string to save it and have a loop to generate a string data for many of the types
dim attributestrings() as string
dim thiskey as variant
dim thisvalue as variant
for each thisentry as DictionaryEntry in d
thiskey=thisentry.Key
thisvalue=thisentry.Value
Var ti As Introspection.Typeinfo = Introspection.GetType(thisvalue)
if ti<>nil then
select case ti.name
case "string"
....
....
case "Folderitem"
valuestring = encodehex(folderitem(thisvalue).SaveInfo(nil))
else
if ti.IsPrimitive then
//basic type
attributestrings.Append(thiskey+chr(9)+EncodingToURLMBS(thisvalue))
else
break
app.debugmessage("dictionary_string error mydictionary string for a type "+ti.fullname)
valuestring="BADDATA"
end if
end select
We get a breakpoint with it.fullname containing the above gibberish type when it goes wrong. Processing the same data again does not cause each time.
Back to the code aboveā¦
d, pd, d2 and d3 are all local variables.
Inspecting them in the IDE shows that dictionary d and d2 are both corrupt. The value of āoverallā is empty and has the gibberish ti.fullname. How this can happen to a local variable, I really canāt understand. d2 has ā3ā directly allocated to it. d3, of type Xojo.Core.Dictionary is ok and contains a single entry with a key of āoverallā and a value of ā3ā. Unfortunately, I canāt make mydictionary a subclass of Xojo.Core.Dictionary because there are many internal functions and plugins which require a āDictionary classā, not āXojo.Core.Dictionaryā
Has anyone seen anything like this before?
Iām using Xojo2024r1.1 and Xojo2024r1. MBS 2023r4 and now 2024pr2 beta as a test
Regards,
Lee