TWideStringField GetValue Method Not Calling GetData Properly
Original Reporter info from Mantis: TimYoung
-
Reporter name: Tim Young
Original Reporter info from Mantis: TimYoung
- Reporter name: Tim Young
Description:
The TWideStringField GetValue method is not calling GetData properly. It is calling GetData with the second parameter (NativeFormat) set to False, which is incorrect and causes the DataConvert method to be called for the field buffer. DataConvert does not do anything with ftWideString fields, including the required copying of the source buffer to the destination buffer "as-is". The result is that TWideStringField simply returns garbage for the GetValue method, i.e. it simply doesn't work for Unicode apps such as Windows CE apps. Our product ElevateDB, for example, requires this fix in order for the Unicode versions of ElevateDB to work at all with Free Pascal.
This was reported previously by Hannes Danzl last year in report # 0009143.
Additional information:
Here is the fixed code for fields.inc:
function TWideStringField.GetValue(var aValue: WideString): Boolean;
var
FixBuffer : array[0..dsMaxStringSize div 2] of WideChar;
DynBuffer : array of WideChar;
Buffer : PWideChar;
begin
if DataSize <= dsMaxStringSize then begin
Result := GetData(@FixBuffer, True); <<< Fixed with True parameter
aValue := FixBuffer;
end else begin
SetLength(DynBuffer, Succ(Size));
Buffer := PWideChar(DynBuffer);
Result := GetData(Buffer, True); <<< Fixed with True parameter
if Result then
aValue := Buffer;
end;
end;
Mantis conversion info:
- Mantis ID: 11706
- Version: 2.2.0
- Fixed in version: 2.2.4
- Fixed in revision: 12294 (#c4ac93e6)
- Monitored by: » CC (Leslie)
- Target version: 2.3.1