View Issue Details

IDProjectCategoryView StatusLast Update
0036170LazarusWidgetsetpublic2019-10-20 19:20
ReporterMati UntAssigned ToJuha Manninen 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformWindowsOSWindowsOS Version10
Product Version2.0.4Product Build 
Target VersionFixed in Version 
Summary0036170: When you have multiple toggle boxes and select different ones causes system to lock
DescriptionSwitching on different toggle boxes causes the system to lock. This problem occurs in Lazarus versions after 1.8.4. Have tested it on all the newer versions of Lazarus and on different computers with the same result.
Steps To ReproduceCreate a form with three ToggleBoxes and one ListBox for output. When one is checked un check the others. This simple program will crash in Lazarus versions after 1.8.4

procedure TForm1.ToggleBox1Click(Sender: TObject);
begin
  ToggleBox1.State:= cbChecked;
  ToggleBox2.State:= cbUnChecked;
  ToggleBox3.State:= cbUnChecked;
  ListBox1.Items.Add('Check1');
end;

procedure TForm1.ToggleBox2Click(Sender: TObject);
begin
  ToggleBox2.State:= cbChecked;
  ToggleBox1.State:= cbUnChecked;
  ToggleBox3.State:= cbUnChecked;
  ListBox1.Items.Add('Check2');
end;

procedure TForm1.ToggleBox3Click(Sender: TObject);
begin
  ToggleBox3.State:= cbChecked;
  ToggleBox2.State:= cbUnChecked;
  ToggleBox1.State:= cbUnChecked;
  ListBox1.Items.Add('Check3');
end;
TagsNo tags attached.
Fixed in Revisionr62095
LazTarget-
WidgetsetWin32/Win64
Attached Files
  • project1.lps (1,102 bytes)
  • project1.res (138,928 bytes)
  • unit1.lfm (852 bytes)
  • unit1.pas (1,162 bytes)
    unit Unit1;
    
    {$mode objfpc}{$H+}
    
    interface
    
    uses
      Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls;
    
    type
    
      { TForm1 }
    
      TForm1 = class(TForm)
        ListBox1: TListBox;
        ToggleBox1: TToggleBox;
        ToggleBox2: TToggleBox;
        ToggleBox3: TToggleBox;
        procedure ToggleBox1Click(Sender: TObject);
        procedure ToggleBox2Click(Sender: TObject);
        procedure ToggleBox3Click(Sender: TObject);
      private
    
      public
    
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.lfm}
    
    { TForm1 }
    
    
    
    procedure TForm1.ToggleBox1Click(Sender: TObject);
    begin
      ToggleBox1.State:= cbChecked;
      ToggleBox2.State:= cbUnChecked;
      ToggleBox3.State:= cbUnChecked;
      ListBox1.Items.Add('Check1');
    end;
    
    procedure TForm1.ToggleBox2Click(Sender: TObject);
    begin
      ToggleBox2.State:= cbChecked;
      ToggleBox1.State:= cbUnChecked;
      ToggleBox3.State:= cbUnChecked;
      ListBox1.Items.Add('Check2');
    end;
    
    procedure TForm1.ToggleBox3Click(Sender: TObject);
    begin
      ToggleBox3.State:= cbChecked;
      ToggleBox2.State:= cbUnChecked;
      ToggleBox1.State:= cbUnChecked;
      ListBox1.Items.Add('Check3');
    end;
    
    end.
    
    
    unit1.pas (1,162 bytes)
  • project1.ico (137,040 bytes)
  • project1.lpi (2,044 bytes)
  • project1.lpr (409 bytes)

Relationships

related to 0033076 assignedOndrej Pokorny TCheckBox state change does not trigger OnChange event 
related to 0035018 closedMichl The builded EXE crashes before the formular is showing 

Activities

Mati Unt

2019-10-13 00:27

reporter  

project1.lps (1,102 bytes)
project1.res (138,928 bytes)
unit1.lfm (852 bytes)
unit1.pas (1,162 bytes)
unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls;

type

  { TForm1 }

  TForm1 = class(TForm)
    ListBox1: TListBox;
    ToggleBox1: TToggleBox;
    ToggleBox2: TToggleBox;
    ToggleBox3: TToggleBox;
    procedure ToggleBox1Click(Sender: TObject);
    procedure ToggleBox2Click(Sender: TObject);
    procedure ToggleBox3Click(Sender: TObject);
  private

  public

  end;

var
  Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }



procedure TForm1.ToggleBox1Click(Sender: TObject);
begin
  ToggleBox1.State:= cbChecked;
  ToggleBox2.State:= cbUnChecked;
  ToggleBox3.State:= cbUnChecked;
  ListBox1.Items.Add('Check1');
end;

procedure TForm1.ToggleBox2Click(Sender: TObject);
begin
  ToggleBox2.State:= cbChecked;
  ToggleBox1.State:= cbUnChecked;
  ToggleBox3.State:= cbUnChecked;
  ListBox1.Items.Add('Check2');
end;

procedure TForm1.ToggleBox3Click(Sender: TObject);
begin
  ToggleBox3.State:= cbChecked;
  ToggleBox2.State:= cbUnChecked;
  ToggleBox1.State:= cbUnChecked;
  ListBox1.Items.Add('Check3');
end;

end.

unit1.pas (1,162 bytes)
project1.ico (137,040 bytes)
project1.lpi (2,044 bytes)
project1.lpr (409 bytes)

jamie philbrook

2019-10-13 03:56

reporter   ~0118538

Sure, it seems someone decided to effect all widget sets to fix a GTK problem, I thought this was a NO-NO,
procedure TCustomCheckBox.SetState(Value: TCheckBoxState);
var
  OldState: TCheckBoxState;
begin
  if FState <> Value then
  begin
    OldState := FState;
    FState := Value;
    if Action is TCustomAction then
      TCustomAction(Action).Checked := FState = cbChecked;
    ApplyChanges;
    //some widgetsets (gtk*) does not allow to uncheck a radio button
    //only call OnChange if effectivelly changed
    FState := RetrieveState;
    if (FState <> OldState) and not (csLoading in ComponentState) then
      DoClickOnChange;
  end;
end;

OnChange should never get called when code changes this, only user interaction should be calling OnClick/OnChange..

Juha Manninen

2019-10-13 07:56

developer   ~0118543

Those changes were made in r57155, issue 0033076. The original bug was not about GTK2, the reporter also used Windows.
Can you guys please figure out a way to fix both this and the related issue? If not possible then we must revert r57155. A regression which causes an application to freeze is quite serious after all.
I wonder why nobody noticed earlier. The commit happened nearly 2 years ago (January 2018).

Juha Manninen

2019-10-20 19:20

developer   ~0118732

I reverted both r57155 and a later r60340. The related issue remains open. If possible please try to fix it and provide a patch there which does not brake anything.

Issue History

Date Modified Username Field Change
2019-10-13 00:27 Mati Unt New Issue
2019-10-13 00:27 Mati Unt File Added: project1.lps
2019-10-13 00:27 Mati Unt File Added: project1.res
2019-10-13 00:27 Mati Unt File Added: unit1.lfm
2019-10-13 00:27 Mati Unt File Added: unit1.pas
2019-10-13 00:27 Mati Unt File Added: project1.ico
2019-10-13 00:27 Mati Unt File Added: project1.lpi
2019-10-13 00:27 Mati Unt File Added: project1.lpr
2019-10-13 03:56 jamie philbrook Note Added: 0118538
2019-10-13 07:44 Juha Manninen Relationship added related to 0033076
2019-10-13 07:56 Juha Manninen Note Added: 0118543
2019-10-20 16:39 Juha Manninen Assigned To => Juha Manninen
2019-10-20 16:39 Juha Manninen Status new => assigned
2019-10-20 19:01 Juha Manninen Relationship added related to 0036018
2019-10-20 19:02 Juha Manninen Relationship deleted related to 0036018
2019-10-20 19:02 Juha Manninen Relationship added related to 0035018
2019-10-20 19:20 Juha Manninen Status assigned => resolved
2019-10-20 19:20 Juha Manninen Resolution open => fixed
2019-10-20 19:20 Juha Manninen Fixed in Revision => r62095
2019-10-20 19:20 Juha Manninen LazTarget => -
2019-10-20 19:20 Juha Manninen Widgetset Win32/Win64 => Win32/Win64
2019-10-20 19:20 Juha Manninen Note Added: 0118732