× General Purpose Components and Libraries, discussions, problems and suggestions

Question TDBLookupComboBox access violation

  • Luca
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
More
4 years 5 months ago - 4 years 5 months ago #9242 by Luca
Hi
Here attached a demo project.
It includes two forms:
- form1 used to refresh data and to showmodal form2,
- form2 containing a memdataset with two fields and a tdblookupcombobox
If you run in CT 5.7 you receive an access violation in TDBLookUp.FetchLookupData second time you push button1 to open form2.

Some informations:
1. if you change form2.showmodal with form2.show all works fine
2. this is just an example to reproduce the error: I found the problem using MSSQL tables-

All works fine in CT 5.4 and Lazarus 1.6.

PS: why breakpoints in lcl unit files is not working in debugging mode?

Regards
Luca
Attachments:
Last edit: 4 years 5 months ago by Luca.

Please Log in or Create an account to join the conversation.

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Away
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
More
4 years 5 months ago #9246 by Sternas Stefanos
Replied by Sternas Stefanos on topic TDBLookupComboBox access violation
Thanks Sir
we will test and report

PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

  • Luca
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
More
4 years 5 months ago - 4 years 5 months ago #9248 by Luca
Replied by Luca on topic TDBLookupComboBox access violation
I found a workround.
It seems the problem is linked to handle changing of form2 (see blogs.embarcadero.com/abauer/2004/02/10/295 ) when you click second time button1.
If I set (directly in Object Inspector),
form2.popumode=pmauto
the handle didn't change and all is fine.

What's really strange is that if you access the handle before showmodal (for example by showing its value) without changing popupmode to pmauto, the error disappears.
  showmessage(inttostr(form2.Handle)); 
  form2.SQLQuery1.Close;
  form2.SQLQuery1.Open;
  form2.ShowModal

Hope this help
Regards
Luca
Last edit: 4 years 5 months ago by Luca.

Please Log in or Create an account to join the conversation.

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Away
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
More
4 years 5 months ago - 4 years 5 months ago #9249 by Sternas Stefanos
Replied by Sternas Stefanos on topic TDBLookupComboBox access violation
Or
add to Form2 OnShow event:
procedure TForm2.FormShow(Sender: TObject);
begin
 MemDataset1.Close;
 MemDataset1.Open;
end;

and call from Form1 only
procedure TForm1.Button1Click(Sender: TObject);
begin
  form2.ShowModal;
end;         

PS: please don't forget CT-LCL is NOT the same with VCL
and never will be...

PilotLogic Architect and Core Programmer
Attachments:
Last edit: 4 years 5 months ago by Sternas Stefanos.

Please Log in or Create an account to join the conversation.

  • Luca
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
More
4 years 5 months ago #9250 by Luca
Replied by Luca on topic TDBLookupComboBox access violation
OK.
I forgot to say that After MemDataset1.Open and Before Form2.ShowModal, I initialized some controls in Form2. So I need to open MemDataset1 before show the form2.
I think to set pmAuto for modal forms.

Regards
Luca

Please Log in or Create an account to join the conversation.

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Away
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
More
4 years 5 months ago #9251 by Sternas Stefanos
Replied by Sternas Stefanos on topic TDBLookupComboBox access violation
As you want

PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.