View Issue Details

IDProjectCategoryView StatusLast Update
0031486LazarusDatabase Componentspublic2017-03-22 22:07
ReporterArtem Proskurnev Assigned ToOndrej Pokorny  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
OSlinux 
Target Version1.8 
Summary0031486: SIGSEGV TDBLookupComboBox on modal form
DescriptionFPC 3.0.0 and lazarus 1.6.2 all ok

FPC>=3.0.2
Lazarus>=1.6.4
SIGSEGV on post or cancel if use two TDBLookupComboBox on modalform.

SQLQuery1 have 2 lookup fields.

procedure TForm1.Button1Click(Sender: TObject);
var
  a: TForm2;
begin
  try
    a := TForm2.Create(Form1);
    a.SQLQuery2.Open;
    a.SQLQuery3.Open;
    a.SQLQuery1.Open;
    a.SQLQuery1.Edit;
    if a.ShowModal = idOk then
      a.SQLQuery1.Post <-----SIGSEGV
    else
      a.SQLQuery1.Cancel; <------SIGSEGV
  finally
    a.Free;
  end;
end;

in another programm:
/usr/lib64/lazarus/lcl/include/dblookup.inc line 88
if FRecordUpdated or ((FLookup.ControlItems <> nil) and (FLookup.ControlItems.Count <> DataSet.RecordCount)) then <----SIGSEGV
Error:
The object FLookup.ControlItems does not exist Count properties
Steps To ReproduceGenerate MariaDB(MySQL) database table.sql
unpack and compile program published.tar.gz
TagsNo tags attached.
Fixed in Revision54441
LazTarget1.8
Widgetset
Attached Files

Relationships

related to 0031447 closedJuha Manninen AutoComlete error TDBLookupComboBox 

Activities

Artem Proskurnev

2017-03-06 01:35

reporter  

s35.png (19,535 bytes)   
s35.png (19,535 bytes)   

Artem Proskurnev

2017-03-06 01:35

reporter  

table.sql (1,516 bytes)

Artem Proskurnev

2017-03-06 01:36

reporter  

published.tar.gz (4,572 bytes)

Artem Proskurnev

2017-03-06 02:10

reporter   ~0098672

fpc 3.0.2 + lazarus 1.6.2 all ok

Artem Proskurnev

2017-03-06 02:53

reporter   ~0098674

If I copy lcl/include/customform.inc from 1.6.2 to 1.6.4 and rebuild lazarus 1.6.4 all work fpc3.0.2+lazarus1.6.4

Artem Proskurnev

2017-03-06 02:55

reporter  

cf.diff (1,026 bytes)   
diff 162/lazarus/lcl/include/customform.inc 164/lazarus/lcl/include/customform.inc
1716c1716,1720
<   if FMenu <> nil then FMenu.Parent := nil;
---
>   if (FMenu <> nil) and not (csDestroying in FMenu.ComponentState) then
>   begin
>     FMenu.DestroyHandle;
>     FMenu.Parent := nil;
>   end;
2572,2573c2576
<     Result.Width := ClientWidth;
<     Result.Height := ClientHeight;
---
>     Result.SetSize(ClientWidth, ClientHeight);
2880,2884c2883,2884
<     if PopupMode = pmNone then
<     begin
<       RecreateWnd(Self);
<       HandleNeeded;
<     end;
---
>     if (PopupMode = pmNone) and HandleAllocated then
>       RecreateWnd(Self); // need to refresh handle for pmNone because ParentWindow changes if (fsModal in FFormState) - see GetRealPopupParent
2952a2953,2954
>       if ((PopupMode = pmNone) and HandleAllocated) and not (csDestroying in ComponentState) then
>         RecreateWnd(Self); // need to refresh handle for pmNone because ParentWindow changes if (fsModal in FFormState) - see GetRealPopupParent
cf.diff (1,026 bytes)   

Artem Proskurnev

2017-03-06 03:14

reporter   ~0098675

patch for lazarus1.6.4 lcl/include/customform.inc

Artem Proskurnev

2017-03-06 03:14

reporter  

customform.patch (591 bytes)   
2883,2884c2880,2884
<     if (PopupMode = pmNone) and HandleAllocated then
<       RecreateWnd(Self); // need to refresh handle for pmNone because ParentWindow changes if (fsModal in FFormState) - see GetRealPopupParent
---
>     if PopupMode = pmNone then
>     begin
>       RecreateWnd(Self);
>       HandleNeeded;
>     end;
2953,2954d2952
<       if ((PopupMode = pmNone) and HandleAllocated) and not (csDestroying in ComponentState) then
<         RecreateWnd(Self); // need to refresh handle for pmNone because ParentWindow changes if (fsModal in FFormState) - see GetRealPopupParent
customform.patch (591 bytes)   

Thaddy de Koning

2017-03-06 06:54

reporter   ~0098677

This is a Lazarus issue, so should be moved.

serbod

2017-03-14 15:32

reporter   ~0098899

Mandatory properties ListSource and ListField was empty in TDBLookupComboBox controls. And unnecessary DataField and DataSource properties was set.

IMHO, some sanity checks on TDBLookupComboBox with informative exceptions can prevent such troubles in future.

Artem Proskurnev

2017-03-14 16:46

reporter   ~0098904

@serbod, if you fill properties ListSource and ListField the error still remains.

Artem Proskurnev

2017-03-14 16:53

reporter   ~0098905

And KeyField

Artem Proskurnev

2017-03-14 18:54

reporter   ~0098908

Collision: http://bugs.freepascal.org/view.php?id=0031028

Artem Proskurnev

2017-03-14 19:03

reporter   ~0098909

If change
lcl/include/dblookup.inc line 88
if FRecordUpdated or ((FLookup.ControlItems <> nil) and (FLookup.ControlItems.Count <> DataSet.RecordCount)) then
to
    if FRecordUpdated and ((FLookup.ControlItems <> nil) and (FLookup.ControlItems.Count <> DataSet.RecordCount)) then

all ok

Artem Proskurnev

2017-03-14 19:04

reporter   ~0098910

or->and
all ok without patch

Artem Proskurnev

2017-03-14 19:24

reporter   ~0098911

If patch only:
2953,2954d2952
< if ((PopupMode = pmNone) and HandleAllocated) and not (csDestroying in ComponentState) then
< RecreateWnd(Self); // need to refresh handle for pmNone because ParentWindow changes if (fsModal in FFormState) - see GetRealPopupParent
all ok

Artem Proskurnev

2017-03-14 19:26

reporter  

cf.patch (262 bytes)   
2953,2954d2952
<       if ((PopupMode = pmNone) and HandleAllocated) and not (csDestroying in ComponentState) then
<         RecreateWnd(Self); // need to refresh handle for pmNone because ParentWindow changes if (fsModal in FFormState) - see GetRealPopupParent
cf.patch (262 bytes)   

Ondrej Pokorny

2017-03-18 09:44

developer   ~0099001

The patch cannot be applied because form handle can be recreated also from other sources/methods and so the issue wouldn't be solved.

Ondrej Pokorny

2017-03-18 10:20

developer   ~0099003

Fixed, please test. Will be merged to 1.6

Artem Proskurnev

2017-03-20 20:56

reporter   ~0099090

Thank you!
Which version to download to test? This http://svn.freepascal.org/svn/lazarus/trunk ?
Tell me where was the bug? Which files fixed? Very interesting! :-)

Ondrej Pokorny

2017-03-20 21:03

developer   ~0099091

Look into the "Fixed in Revision" field above: 54441. http://svn.freepascal.org/cgi-bin/viewvc.cgi?view=revision&root=lazarus&revision=54441

Yes, trunk.

It will appear in 1_6_fixes branch as soon as it is merged. The merge list is here: http://wiki.freepascal.org/Lazarus_1.6_fixes_branch

Artem Proskurnev

2017-03-20 21:23

reporter   ~0099092

Great!
This erros fixed! :-)
But autocomplete isn't working :-( http://bugs.freepascal.org/view.php?id=31447

Artem Proskurnev

2017-03-20 21:25

reporter   ~0099093

Thank you!!! :-)

Artem Proskurnev

2017-03-22 22:07

reporter   ~0099157

Ok!

Issue History

Date Modified Username Field Change
2017-03-06 01:35 Artem Proskurnev New Issue
2017-03-06 01:35 Artem Proskurnev File Added: s35.png
2017-03-06 01:35 Artem Proskurnev File Added: table.sql
2017-03-06 01:36 Artem Proskurnev File Added: published.tar.gz
2017-03-06 02:10 Artem Proskurnev Note Added: 0098672
2017-03-06 02:53 Artem Proskurnev Note Added: 0098674
2017-03-06 02:55 Artem Proskurnev File Added: cf.diff
2017-03-06 03:14 Artem Proskurnev Note Added: 0098675
2017-03-06 03:14 Artem Proskurnev File Added: customform.patch
2017-03-06 06:54 Thaddy de Koning Note Added: 0098677
2017-03-06 16:09 Marco van de Voort Project FPC => Lazarus
2017-03-14 15:32 serbod Note Added: 0098899
2017-03-14 16:46 Artem Proskurnev Note Added: 0098904
2017-03-14 16:53 Artem Proskurnev Note Added: 0098905
2017-03-14 18:54 Artem Proskurnev Note Added: 0098908
2017-03-14 19:03 Artem Proskurnev Note Added: 0098909
2017-03-14 19:04 Artem Proskurnev Note Added: 0098910
2017-03-14 19:24 Artem Proskurnev Note Added: 0098911
2017-03-14 19:26 Artem Proskurnev File Added: cf.patch
2017-03-14 19:45 Ondrej Pokorny Assigned To => Ondrej Pokorny
2017-03-14 19:45 Ondrej Pokorny Status new => assigned
2017-03-14 19:46 Ondrej Pokorny LazTarget => 1.8
2017-03-14 19:46 Ondrej Pokorny Target Version => 1.8
2017-03-18 09:44 Ondrej Pokorny Note Added: 0099001
2017-03-18 10:20 Ondrej Pokorny Fixed in Revision => 54441
2017-03-18 10:20 Ondrej Pokorny Note Added: 0099003
2017-03-18 10:20 Ondrej Pokorny Status assigned => resolved
2017-03-18 10:20 Ondrej Pokorny Resolution open => fixed
2017-03-20 20:56 Artem Proskurnev Note Added: 0099090
2017-03-20 21:03 Ondrej Pokorny Note Added: 0099091
2017-03-20 21:23 Artem Proskurnev Note Added: 0099092
2017-03-20 21:25 Artem Proskurnev Note Added: 0099093
2017-03-21 12:24 Juha Manninen Relationship added related to 0031447
2017-03-22 22:07 Artem Proskurnev Note Added: 0099157
2017-03-22 22:07 Artem Proskurnev Status resolved => closed