From: <car...@us...> - 2014-11-26 10:20:26
|
Revision: 967 http://sourceforge.net/p/instantobjects/code/967 Author: carlobar Date: 2014-11-26 10:20:23 +0000 (Wed, 26 Nov 2014) Log Message: ----------- Fixed problems when UseUnicode is active and streaming memo fields passing thorought Value of an InstantBlob attribute. Modified Paths: -------------- trunk/Source/Core/InstantPersistence.pas Modified: trunk/Source/Core/InstantPersistence.pas =================================================================== --- trunk/Source/Core/InstantPersistence.pas 2014-09-03 07:36:40 UTC (rev 966) +++ trunk/Source/Core/InstantPersistence.pas 2014-11-26 10:20:23 UTC (rev 967) @@ -485,6 +485,7 @@ TInstantMemo = class(TInstantBlob) protected class function AttributeType: TInstantAttributeType; override; + procedure SetValue(const AValue: string); override; procedure ReadObject(Reader: TInstantReader); override; procedure WriteObject(Writer: TInstantWriter); override; end; @@ -3724,23 +3725,13 @@ LAnsiValue: AnsiString; LValue: String; begin - if not UseUnicode then - begin - LAnsiValue := AnsiString(AValue); - L := Length(LAnsiValue) * SizeOf(AnsiChar); - end - else - begin - LValue := AValue; - L := Length(LValue) * SizeOf(Char); - end; + //Default Blob streaming is not based on UseUnicode setting. + LAnsiValue := AnsiString(AValue); + L := Length(LAnsiValue) * SizeOf(AnsiChar); if L > 0 then begin Stream.Clear; - if not UseUnicode then - WriteBuffer(LAnsiValue[1], 0, L) - else - WriteBuffer(LValue[1], 0, L); + WriteBuffer(LAnsiValue[1], 0, L); Stream.Size := L; end else @@ -3906,6 +3897,36 @@ Value := Reader.ReadString; end; +procedure TInstantMemo.SetValue(const AValue: string); +var + L: Integer; + LAnsiValue: AnsiString; + LValue: String; +begin + //Don't call inherited: Text streaming is different by UseUnicode + if not UseUnicode then + begin + LAnsiValue := AnsiString(AValue); + L := Length(LAnsiValue) * SizeOf(AnsiChar); + end + else + begin + LValue := AValue; + L := Length(LValue) * SizeOf(Char); + end; + if L > 0 then + begin + Stream.Clear; + if not UseUnicode then + WriteBuffer(LAnsiValue[1], 0, L) + else + WriteBuffer(LValue[1], 0, L); + Stream.Size := L; + end + else + Clear; +end; + procedure TInstantMemo.WriteObject(Writer: TInstantWriter); begin WriteName(Writer); @@ -6088,7 +6109,8 @@ AttributeChanged(Attribute); if Assigned(FOnAttributeChanged) then FOnAttributeChanged(Self, Attribute); - Changed; + if not ((Attribute is TInstantContainer) and TInstantContainer(Attribute).isVirtual) then + Changed; end; procedure TInstantObject.DoBeforeContentChange( |