From 78e755687677d3c82d435dc4ba3079765caf360f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Mussche?= Date: Fri, 14 Feb 2014 15:46:42 +0100 Subject: [PATCH 1/2] geen host dan geen reconnect --- IdHTTPWebsocketClient.pas | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/IdHTTPWebsocketClient.pas b/IdHTTPWebsocketClient.pas index 725a8fb..28910aa 100644 --- a/IdHTTPWebsocketClient.pas +++ b/IdHTTPWebsocketClient.pas @@ -1175,7 +1175,8 @@ begin if ws <> nil then ws.LastActivityTime := Now; chn.ConnectTimeout := 250; //250ms otherwise too much delay? todo: seperate ping/connnect thread - chn.TryUpgradeToWebsocket; + if (chn.Host <> '') and (chn.Port > 0) then + chn.TryUpgradeToWebsocket; except //just try end; From 3903dac00e817cc5cf2f362d1d37843951aee85f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Mussche?= Date: Fri, 14 Feb 2014 15:48:26 +0100 Subject: [PATCH 2/2] superobject: get current value/object (so objects are not created every time and overwritten -> mem leak) --- superobject/superobject.pas | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/superobject/superobject.pas b/superobject/superobject.pas index 2a61d87..8c42a77 100644 --- a/superobject/superobject.pas +++ b/superobject/superobject.pas @@ -6062,10 +6062,16 @@ function TSuperRttiContext.FromJson(TypeInfo: PTypeInfo; const obj: ISuperObject begin Result := True; if Value.Kind <> tkClass then - Value := GetTypeData(TypeInfo).ClassType.Create; + begin + //only create if emtpy + if Value.IsEmpty then + Value := GetTypeData(TypeInfo).ClassType.Create; + end; for f in Context.GetType(Value.AsObject.ClassType).GetFields do if f.FieldType <> nil then begin + //get current value/object (so objects are not created every time and overwritten -> mem leak + v := f.GetValue(Value.AsObject); Result := FromJson(f.FieldType.Handle, GetFieldDefault(f, obj.AsObject[GetFieldName(f)]), v); if Result then f.SetValue(Value.AsObject, v) else @@ -6133,6 +6139,7 @@ function TSuperRttiContext.FromJson(TypeInfo: PTypeInfo; const obj: ISuperObject Result := True; for i := 0 to i - 1 do begin + //val.Make(pb, el, val); copy old value Result := FromJson(el, obj.AsArray[i], val); if not Result then Break;