Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue parsing data in 10.4 creates RTTI issues? Works great PRE 10.4 .. #133

Open
jdredd87 opened this issue Aug 20, 2020 · 3 comments
Open

Comments

@jdredd87
Copy link

jdredd87 commented Aug 20, 2020

< solutions 2 post down, problem is with TObjectList<> usage in your classes >

Updating to 10.4 Delphi, will no longer parse properly when using the "fromJSON" usage to turn JSON back into object code.

Go back to 10.3 and older and it works fine.


Debugger Exception Notification

Project Photomate.exe raised exception class EInvocationError with message 'Parameter count mismatch'.

Break Continue Help

:76639962 KERNELBASE.RaiseException + 0x62
System.Rtti.TRttiInstanceMethodEx.DispatchInvoke(($401330, Pointer($1044DD4) as IValueData, 4, 61700, 12251396, $BAF104, TClass($BAF104), 4, -3836, 12251396, 1.71678624006352e-38, 6.05299387719686e-317, 0.00000000004466e-4933, 12251396, 1225.1396, 12251396, 12251396, ($BAF104, nil), $BAF104),(...))
System.Rtti.TRttiMethod.Invoke(TClass($BAF104),(...))
XSuperObject.TSerializeParse.ObjectConstructor(TClass($BAF104))
XSuperObject.TSerializeParse.CheckObject<System.string>($4985110,$EABEE68,'parts',nil)
XSuperObject.TSerializeParse.WriteMember<XSuperJSON.IJSONObject,System.string>($4985110,'parts',$BAF2B4,$EABEE68,TSuperObject($AA0E370) as {XSuperObject}IBaseJSON<XSuperJSON.IJSONObject,System.string>)
XSuperObject.TSerializeParse.WriteMembers($4985110,$AA0E310,TSuperObject($AA0E370) as ISuperObject)
XSuperObject.TSerializeParse.WriteObject($4985110,TSuperObject($AA0E370) as ISuperObject)
XSuperObject.TSuperObjectHelper.FromJSON(TSuperObject($AA0E370) as ISuperObject,(...),'Create')
XSuperObject.TSuperObjectHelper.FromJSON('{"result":"1","parts":[{"PartCode":"AAA","PartNumbers":"","PartName":"CUSTOMER DECLINES WARRANTY","Sided":"N","UndamagedPricing":"N","PartType":""},{"PartCode":"AAC","PartNumbers":"","PartName":"AUX. AIR CONDITIONER","Sided":"N","UndamagedPricing":"N","PartType":"Mechanical"},{"PartCode":"ABK","PartNumbers":"545","PartName":"ANTI-LOCK BRAKE PARTS","Sided":"N","UndamagedPricing":"N","PartType":"Mechanical"},{"PartCode":"ABS","PartNumbers":"526","PartName":"SHOCK ABSORBERS","Sided":"N","UndamagedPricing":"N","PartType":"Mechanical"},{"PartCode":"ABX","PartNumbers":"","PartName":"DISCONTINUED USE ACL","Sided":"N","UndamagedPricing":"N","PartType":"Mechanical"},{"PartCode":"ACA","PartNumbers":"","PartName":"AIR COND. ASSY.","Sided":"N","UndamagedPricing":"N","PartType":"Mechanical"},{"PartCode":"ACB","PartNumbers":"","PartName":"AIR COND. BRACKET","Sided":"N","UndamagedPricing":"N","PartType":"Mechanical"},{"PartCode":"ACC","PartNumbers":"","PartName":"ACCELERATOR CABLE","Sided":"N","UndamagedPricing":"N","PartType":"Mechanical"},{"PartCode":"ACD","PartNumbers":"686","PartName":"AIR COND. DRYER","Sided":"N","UndamagedPricing":"N","PartType":"Mechanical"},{"PartCode":"ACH","PartNumbers":"683","PartName":"AIR CONDITIONER HOSE","Sided":"N","UndamagedPricing":"N","PartType":"Mechanical"},{"PartCode":"ACL","PartNumbers":"319","PartName":"AIR CLEANER","Sided":"N","UndamagedPricing":"N","PartType":"Mechanical"},{"PartCode":"ACM","PartNumbers":"","PartName":"DISCONTINUED USE CBX","Sided":"N","UndamagedPricing":"N","PartType":"Mechanical"},{"PartCode":"ACN","PartNumbers":"","PartName":"AIR ASSIST CANISTER","Sided":"N","UndamagedPricing":"N","PartType":""},{"PartCode":"ACO","PartNumbers":"","PartName":"A/C CHANGE-OVER","Sided":"N","UndamagedPricing":"N","PartType":"Mechanical"},{"PartCode":"ACP","PartNumbers":"234","PartName":"ACCELERATOR PARTS","Sided":"N","UndamagedPricing":"N","PartType":"Mechanical"},{"PartCode":"ACR","PartNumbers":"","PartName":"AIR COMPRESSOR RELAY","Sided"...
XSuperObject.TSuperObjectHelper.FromJSON('{"result":"1","parts":[{"PartCode":"AAA","PartNumbers":"","PartName":"CUSTOMER DECLINES WARRANTY","Sided":"N","UndamagedPricing":"N","PartType":""},{"PartCode":"AAC","PartNumbers":"","PartName":"AUX. AIR CONDITIONER","Sided":"N","UndamagedPricing":"N","PartType":"Mechanical"},{"PartCode":"ABK","PartNumbers":"545","PartName":"ANTI-LOCK BRAKE PARTS","Sided":"N","UndamagedPricing":"N","PartType":"Mechanical"},{"PartCode":"ABS","PartNumbers":"526","PartName":"SHOCK ABSORBERS","Sided":"N","UndamagedPricing":"N","PartType":"Mechanical"},{"PartCode":"ABX","PartNumbers":"","PartName":"DISCONTINUED USE ACL","Sided":"N","UndamagedPricing":"N","PartType":"Mechanical"},{"PartCode":"ACA","PartNumbers":"","PartName":"AIR COND. ASSY.","Sided":"N","UndamagedPricing":"N","PartType":"Mechanical"},{"PartCode":"ACB","PartNumbers":"","PartName":"AIR COND. BRACKET","Sided":"N","UndamagedPricing":"N","PartType":"Mechanical"},{"PartCode":"ACC","PartNumbers":"","PartName":"ACCELERATOR CABLE","Sided":"N","UndamagedPricing":"N","PartType":"Mechanical"},{"PartCode":"ACD","PartNumbers":"686","PartName":"AIR COND. DRYER","Sided":"N","UndamagedPricing":"N","PartType":"Mechanical"},{"PartCode":"ACH","PartNumbers":"683","PartName":"AIR CONDITIONER HOSE","Sided":"N","UndamagedPricing":"N","PartType":"Mechanical"},{"PartCode":"ACL","PartNumbers":"319","PartName":"AIR CLEANER","Sided":"N","UndamagedPricing":"N","PartType":"Mechanical"},{"PartCode":"ACM","PartNumbers":"","PartName":"DISCONTINUED USE CBX","Sided":"N","UndamagedPricing":"N","PartType":"Mechanical"},{"PartCode":"ACN","PartNumbers":"","PartName":"AIR ASSIST CANISTER","Sided":"N","UndamagedPricing":"N","PartType":""},{"PartCode":"ACO","PartNumbers":"","PartName":"A/C CHANGE-OVER","Sided":"N","UndamagedPricing":"N","PartType":"Mechanical"},{"PartCode":"ACP","PartNumbers":"234","PartName":"ACCELERATOR PARTS","Sided":"N","UndamagedPricing":"N","PartType":"Mechanical"},{"PartCode":"ACR","PartNumbers":"","PartName":"AIR COMPRESSOR RELAY","Sided"...
CM_Inventory.TGetPartsRequest.Execute
helpercalls.GetPartList
frm_Login.TfrmLogin.btnLoginClick$ActRec.$0$Body$ActRec.$0$2$Body
System.Classes.CheckSynchronize(???)
Vcl.Forms.TApplication.WndProc((0, 0, 0, 0, 0, 0, (), 0, 0, (), 0, 0, ()))
System.Classes.StdWndProc(2361792,0,0,0)
:76e5d9cb USER32.AddClipboardFormatListener + 0x4b
:76e546ea ; C:\Windows\SysWOW64\USER32.dll
:76e52a1a ; C:\Windows\SysWOW64\USER32.dll
:76e527e0 USER32.DispatchMessageW + 0x10
FMX.Platform.Win.TPlatformWin.HandleMessage
:00907af4 TPlatformWin.HandleMessage + $34
FMX.Platform.Win.TPlatformWin.Run
FMX.Forms.TApplication.Run
Photomate.Photomate
:76d4f989 KERNEL32.BaseThreadInitThunk + 0x19
:779874a4 ntdll.RtlGetAppContainerNamedObjectPath + 0xe4
:77987474 ntdll.RtlGetAppContainerNamedObjectPath + 0xb4

Name Value
Self ($BAF138, 8, $49D3E38, $AA09F08, nil, nil, $EAC3640)
Instance ($401330, Pointer($1044DD4) as IValueData, 4, 61700, 12251396, $BAF104, TClass($BAF104), 4, -3836, 12251396, 1.71678624006352e-38, 6.05299387719686e-317, 0.00000000004466e-4933, 12251396, 1225.1396, 12251396, 12251396, ($BAF104, nil), $BAF104)
Args (($401004, Pointer($1044DD4) as IValueData, 1, 1, 1, $1, TClass($1), 1, 1, 1, 1.40129846432482e-45, 4.94065645841247e-324, 1e-4932, 1, 0.0001, 1, 1, ($1, nil), $1))
Result ($19F714, nil, 255, 65535, 4294967295, $FFFFFFFF, TClass($FFFFFFFF), -1, -1, -1, -NAN, 2.12199579047121e-314, 3.72036854775808e-3210, 4294967295, 429496.7295, 4294967295, 4294967295, ($FFFFFFFF, nil), $FFFFFFFF)
code nil
argCount E2171 Variable 'argCount' inaccessible here due to optimization
argList ()
parList ()
i E2171 Variable 'i' inaccessible here due to optimization
currArg 0
cls nil
obj nil
alloc False
isCons True
isDest False
isStat False
isClas False
callConv ccReg

@jdredd87
Copy link
Author

Problem is with TObjectList in 10.4

They added a new Constructor Create; with no parameters.
And code is trying to use that flavor.

@jdredd87
Copy link
Author

jdredd87 commented Aug 20, 2020

Fix for this.. works with 10.4 and pre 10.4

`
class function TSerializeParse.IsGenerics(Cls: TRttiType): Boolean;
var
C: TClass;
Mtd: TRttiMethod;
Info: TGenericsInfo;
Gt: TGenericsType;
begin
Result := False;
C := Cls.AsInstance.MetaclassType;
if FGenericsCache.TryGetValue(C, Info) then
Exit(Info.IsGeneric);

if C.UnitName = GenericsUnit then begin
Gt := GetGenericType(C);
if Gt in [gtList, gtObjectList] then begin
Mtd := Cls.GetMethod('First');
if (Mtd <> Nil) and (Mtd.MethodKind = mkFunction) then begin // TList<> or TObjectList<>
Info := TGenericsInfo.Create(C, True, Mtd.ReturnType);
if Gt = gtObjectList then begin
{$IF CompilerVersion > 33} // 10.4.x +
SetLength(Info.CreateArgs, 0);
{$else} // 10.3.x and below
SetLength(Info.CreateArgs, 1);
Info.CreateArgs[0] := True;
{$endif}
end;
FGenericsCache.Add(C, Info);
Exit(True);
end
end;
end;
end;
`

@fleabie
Copy link

fleabie commented Sep 15, 2024

Thanks so much @jdredd87, this worked for me as well.
Just in case someone else is wondering where this goes, you need to find and replace this method in XSuperObject.pas :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants