View Issue Details

IDProjectCategoryView StatusLast Update
0036170LazarusWidgetsetpublic2019-10-20 19:20
ReporterMati Unt Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformWindowsOSWindows 
Product Version2.0.4 
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

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)   
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
  <ProjectSession>
    <PathDelim Value="\"/>
    <Version Value="11"/>
    <BuildModes Active="Default"/>
    <Units Count="2">
      <Unit0>
        <Filename Value="project1.lpr"/>
        <IsPartOfProject Value="True"/>
        <EditorIndex Value="-1"/>
        <WindowIndex Value="-1"/>
        <TopLine Value="-1"/>
        <CursorPos X="-1" Y="-1"/>
        <UsageCount Value="20"/>
      </Unit0>
      <Unit1>
        <Filename Value="unit1.pas"/>
        <IsPartOfProject Value="True"/>
        <ComponentName Value="Form1"/>
        <ResourceBaseClass Value="Form"/>
        <UnitName Value="Unit1"/>
        <IsVisibleTab Value="True"/>
        <TopLine Value="19"/>
        <CursorPos X="44" Y="62"/>
        <UsageCount Value="20"/>
        <Loaded Value="True"/>
        <LoadedDesigner Value="True"/>
      </Unit1>
    </Units>
    <JumpHistory HistoryIndex="-1"/>
    <RunParams>
      <FormatVersion Value="2"/>
      <Modes Count="0" ActiveMode=""/>
    </RunParams>
  </ProjectSession>
</CONFIG>
project1.lps (1,102 bytes)   
project1.res (138,928 bytes)
unit1.lfm (852 bytes)   
object Form1: TForm1
  Left = 570
  Height = 240
  Top = 277
  Width = 666
  Caption = 'Form1'
  ClientHeight = 240
  ClientWidth = 666
  LCLVersion = '2.0.4.0'
  object ListBox1: TListBox
    Left = 42
    Height = 126
    Top = 80
    Width = 363
    ItemHeight = 0
    TabOrder = 0
  end
  object ToggleBox1: TToggleBox
    Left = 50
    Height = 25
    Top = 33
    Width = 75
    Caption = 'ToggleBox1'
    OnClick = ToggleBox1Click
    TabOrder = 1
  end
  object ToggleBox2: TToggleBox
    Left = 170
    Height = 25
    Top = 33
    Width = 75
    Caption = 'ToggleBox2'
    OnClick = ToggleBox2Click
    TabOrder = 2
  end
  object ToggleBox3: TToggleBox
    Left = 310
    Height = 25
    Top = 33
    Width = 75
    Caption = 'ToggleBox3'
    OnClick = ToggleBox3Click
    TabOrder = 3
  end
end
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.ico (137,040 bytes)   
project1.lpi (2,044 bytes)   
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
  <ProjectOptions>
    <Version Value="11"/>
    <PathDelim Value="\"/>
    <General>
      <SessionStorage Value="InProjectDir"/>
      <MainUnit Value="0"/>
      <Title Value="project1"/>
      <Scaled Value="True"/>
      <ResourceType Value="res"/>
      <UseXPManifest Value="True"/>
      <XPManifest>
        <DpiAware Value="True"/>
      </XPManifest>
      <Icon Value="0"/>
    </General>
    <BuildModes Count="1">
      <Item1 Name="Default" Default="True"/>
    </BuildModes>
    <PublishOptions>
      <Version Value="2"/>
      <UseFileFilters Value="True"/>
    </PublishOptions>
    <RunParams>
      <FormatVersion Value="2"/>
      <Modes Count="0"/>
    </RunParams>
    <RequiredPackages Count="1">
      <Item1>
        <PackageName Value="LCL"/>
      </Item1>
    </RequiredPackages>
    <Units Count="2">
      <Unit0>
        <Filename Value="project1.lpr"/>
        <IsPartOfProject Value="True"/>
      </Unit0>
      <Unit1>
        <Filename Value="unit1.pas"/>
        <IsPartOfProject Value="True"/>
        <ComponentName Value="Form1"/>
        <ResourceBaseClass Value="Form"/>
        <UnitName Value="Unit1"/>
      </Unit1>
    </Units>
  </ProjectOptions>
  <CompilerOptions>
    <Version Value="11"/>
    <PathDelim Value="\"/>
    <Target>
      <Filename Value="project1"/>
    </Target>
    <SearchPaths>
      <IncludeFiles Value="$(ProjOutDir)"/>
      <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
    </SearchPaths>
    <Linking>
      <Options>
        <Win32>
          <GraphicApplication Value="True"/>
        </Win32>
      </Options>
    </Linking>
  </CompilerOptions>
  <Debugging>
    <Exceptions Count="3">
      <Item1>
        <Name Value="EAbort"/>
      </Item1>
      <Item2>
        <Name Value="ECodetoolError"/>
      </Item2>
      <Item3>
        <Name Value="EFOpenError"/>
      </Item3>
    </Exceptions>
  </Debugging>
</CONFIG>
project1.lpi (2,044 bytes)   
project1.lpr (409 bytes)   
program project1;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Interfaces, // this includes the LCL widgetset
  Forms, Unit1
  { you can add units after this };

{$R *.res}

begin
  RequireDerivedFormResource:=True;
  Application.Scaled:=True;
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.

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