Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2009-09

sqlite3connection events

5 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Andrea Mauri

Dear all,
I have some problems with sqlite3connection.
I put a sqlite3connection on a form and then double click on afterconnect event in the object inspector (or beforeconnect or afterdisconnect etc.), lazarus correctly creates in the editor the afterconnect procedure and put the cursor in it. Then I put some code in the afterconnect procedure but if I open again the object inspector the procedure disappear in the object inspector and it is never fired. This happens also with firebird connection. But not with all the other events (FormClick for example).

Lazarus 0.9.29 r21596 FPC 2.2.4 i386-win32-win32/win64

Any hint?
Regards,
Andrea

Reply by email

Andrea Mauri
to Andrea Mauri

anyone can help me?

Andrea Mauri ha scritto:

Show quoted text 27 lines
Dear all, I have some problems with sqlite3connection. I put a sqlite3connection on a form and then double click on afterconnect event in the object inspector (or beforeconnect or afterdisconnect etc.), lazarus correctly creates in the editor the afterconnect procedure and put the cursor in it. Then I put some code in the afterconnect procedure but if I open again the object inspector the procedure disappear in the object inspector and it is never fired. This happens also with firebird connection. But not with all the other events (FormClick for example). Lazarus 0.9.29 r21596 FPC 2.2.4 i386-win32-win32/win64 Any hint? Regards, Andrea -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Mattias Gaertner
to Andrea Mauri
Show quoted text 17 lines
anyone can help me? Andrea Mauri ha scritto: > Dear all, > I have some problems with sqlite3connection. > I put a sqlite3connection on a form and then double click on > afterconnect event in the object inspector (or beforeconnect or > afterdisconnect etc.), lazarus correctly creates in the editor the > afterconnect procedure and put the cursor in it. Then I put some > code in the afterconnect procedure but if I open again the object > inspector the procedure disappear in the object inspector and it > is never fired. This happens also with firebird connection. But not > with all the other events (FormClick for example). > > Lazarus 0.9.29 r21596 FPC 2.2.4 i386-win32-win32/win64 > > Any hint?

Please test with svn revision 21636.

Mattias

Reply by email

Andrea Mauri
to Mattias Gaertner

Dear Mattias,
thanks, now it works.
May I ask you what was the problem? I would like to contribute as much as possible in this project, more I understand more I can help.

Thanks,
Andrea

Mattias Gaertner ha scritto:

Show quoted text 35 lines
On Wed, 09 Sep 2009 19:30:49 +0200 Andrea Mauri wrote: > anyone can help me? > > Andrea Mauri ha scritto: > >> Dear all, >> I have some problems with sqlite3connection. >> I put a sqlite3connection on a form and then double click on >> afterconnect event in the object inspector (or beforeconnect or >> afterdisconnect etc.), lazarus correctly creates in the editor the >> afterconnect procedure and put the cursor in it. Then I put some >> code in the afterconnect procedure but if I open again the object >> inspector the procedure disappear in the object inspector and it >> is never fired. This happens also with firebird connection. But not >> with all the other events (FormClick for example). >> >> Lazarus 0.9.29 r21596 FPC 2.2.4 i386-win32-win32/win64 >> >> Any hint? >> Please test with svn revision 21636. Mattias -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Mattias Gärtner
to Andrea Mauri

Zitat von Andrea Mauri :

Dear Mattias, thanks, now it works. May I ask you what was the problem? I would like to contribute as much as possible in this project, more I understand more I can help.

I will try to explain:

property AfterConnect : TNotifyEvent read FAfterConnect write SetAfterConnect;

The write method is defined as:

procedure TCustomConnection.SetAfterConnect(const AValue: TNotifyEvent);
begin
   if FAfterConnect=AValue then exit;
   FAfterConnect:=AValue;
end;

The problem is that TNotifyEvent is a special "record" of two pointers: Data and Code. At runtime Data is the instance (the Self pointer) and Code is the address of the procedure. At designtime there is no address. Therefore the IDE creates a special fake event, with Data an unique ID and Code=nil.

The comparison "FAfterConnect=AValue" only compares code, not data. Probably it is for Delphi compatibility. Although I wonder, why this happen under mode objfpc. IMHO this feature is inconsistent and almost useless.

Because at designtime the code is always nil, FAfterConnect=AValue is always true. I worked around this by first assigning Code=1 and then Code=nil.

But there is still a bug in the TCustomConnection, because when you switch the event to the method of the same class, but another instance, TCustomConnection will ignore this.

I think, it would be better if FPC changes the comparison in mode objfpc.

Mattias

Reply by email