View Issue Details

IDProjectCategoryView StatusLast Update
0038714LazarusWidgetsetpublic2021-04-13 17:02
ReporterEric Hartner Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
Status newResolutionopen 
Product Version2.0.12 
Summary0038714: [Cocoa] WMTigq[_|^ Being Written In Other TDBGrid Fields When Field Size Is Large
DescriptionI'm experiencing strange behavior when putting data in my TDBGrid in my Cocoa application that uses a SQLite database. When I put data into the first field, it puts text "WMTigq[_|^" into the other fields when I tab out of the first field. I find this "WMTigq[_|^" text in lazarus/lcl/interfaces/cocoa/cocoagdiobjects.pas. Note that this happens with both the latest trunk version and the current stable release.

A few things to note:
- As stated above, this happens with the most recent trunk version of Lazarus as well as the current stable version.
- I have no issues at all when the same code is compiled for Windows under the current stable version.
Steps To ReproduceStrange things start to happen when the TStringField.Size exceeds 255, but you don't see the "WMTigq[_|^" text from TCocoaContext.GetTextMetrics showing up until the Size is much higher. And just to re-iterate, I do NOT see this problem when compiled and linked for Windows.

(1) Create the SQLite table:
    SQLQuery1.SQL.Text := 'create table test1 (field1 WideChar, field2 WideChar, field3 WideChar)';
    SQLQuery1.ExecSQL;

(2) Populate the table with some existing data:
  for i := 1 to 10 do
  begin
    SQLQuery1.SQL.Text := 'insert into test1 (field1,field2,field3) values ('+IntToStr(i)+','+IntToStr(i)+','+IntToStr(i+10)+')';
    SQLQuery1.ExecSQL;
  end;

(3) Create the string fields, set the size to 2000 and issue the select:
  SQLQuery2.SQL.Text := 'select field1, field2, field3 from test1';
  SQLQuery2.Fields.Clear;
  // create each of the three fields
  for i := 1 to 3 do
    with TStringField.Create(SQLQuery2) do
    begin
      FieldName := 'field'+IntToStr(i);
      DisplayLabel := 'Field '+IntToStr(i);
      DataSet := SQLQuery2;
      Visible := True;
      DisplayWidth := 20;
      Size := 2000;
    end;

  SQLQuery2.Open;

  // make sure SQLQuery2 is displying it's data into a TDBGrid

(4) Edit the first column in a row in the DB Grid and then tab to the next field. Upon doing this, the other columns in that row will either be blanked out or overwritten with "WMTigq[_|^".
TagsNo tags attached.
Fixed in Revision
LazTarget-
WidgetsetCocoa
Attached Files

Activities

Eric Hartner

2021-04-07 17:01

reporter  

SQLite Test.zip (725,776 bytes)

Bart Broersma

2021-04-07 22:15

developer   ~0130164

See forum discussion at https://forum.lazarus.freepascal.org/index.php/topic,53982.0.html

Eric Hartner

2021-04-08 05:16

reporter   ~0130169

Note that the problem seems to occur when I do not include a field length in the for the WideChar fields when creating the table. For example...

I have the issue when working with the table created by the following:
create table test1 (field1 WideChar, field2 WideChar, field3 WideChar)

However, I don't have the issue when working with the table created by the following:
create table test1 (field1 WideChar(8000), field2 WideChar(8000), field3 WideChar(8000))

Issue History

Date Modified Username Field Change
2021-04-07 17:01 Eric Hartner New Issue
2021-04-07 17:01 Eric Hartner File Added: SQLite Test.zip
2021-04-07 22:15 Bart Broersma Note Added: 0130164
2021-04-08 05:16 Eric Hartner Note Added: 0130169
2021-04-13 17:02 Maxim Ganetsky Summary WMTigq[_|^ Being Written In Other TDBGrid Fields When Field Size Is Large => [Cocoa] WMTigq[_|^ Being Written In Other TDBGrid Fields When Field Size Is Large
2021-04-13 17:02 Maxim Ganetsky LazTarget => -
2021-04-13 17:02 Maxim Ganetsky Widgetset Cocoa => Cocoa