Joost van der Sluis wrote:
Op donderdag 24-01-2008 om 00:09 uur [tijdzone +1100], schreef John:
Snip
It does, in so far as the parameter specs are now retained, but now the database property of sqlquery is not read, so it still can't work properly. In fact, I can't even set the database from the Lazarus object inspector.

Huh? Are you sure? Did you recompile everything correclty?
You won't often catch me saying "Yes I am *sure* I compiled everything correctly" ! I think I did, though.

This is my version of set database:

procedure TCustomSQLQuery.SetDatabase(Value : TDatabase);

var db : tsqlconnection;

begin
 if (Database <> Value) then
   begin
   {$IFDEF DBDEBUG}
   if dbdbgOn then
     Writeln(dbdbg, 'TCustomSQLQuery.database is being set to "',
                    Value.DatabaseName, '".');
   {$ENDIF}
   if assigned(value) and not (Value is TSQLConnection) then
     DatabaseErrorFmt(SErrNotASQLConnection,[value.Name],self);
   if not (csLoading in ComponentState) then
     begin
     UnPrepare;
if assigned(FCursor) then TSQLConnection(DataBase).DeAllocateCursorHandle(FCursor);
     db := TSQLConnection(Value);
if assigned(value) and (Transaction = nil) and (Assigned(db.Transaction)) then
       transaction := Db.Transaction;
     {$IFDEF DBDEBUG}
     if dbdbgOn then
       Writeln(dbdbg, 'Calling TCustomSQLQuery.OnChangeSQL because ',
                      'TCustomSQLQuery.database has been set to "',
                      Value.DatabaseName, '".');
     {$ENDIF}
     OnChangeSQL(Self);
     end;
   end;
end;

The bits in the {$IFDEF DBDEBUG} are what I have been using to trace the execution. (Just tracing is not helpful, as I can't read the properties, so I can't tell where I am). According to this, SetDatabase gets called once only, from inside DoFixupReferences. At this point the component state indeed includes csLoading, so db never gets assigned. (I have also checked this with breakpoints). This makes sense according to my (limited) understanding of the loader, which is that if a property that is being loaded is a class, it is always pushed into the fixups list, not set at the time.

Caveats:

I am rather behind in my svn version, 9468, compared to the one you generated the diff for. Once I started adding the debug lines, I was reticent to update and have them all wiped out. Also, I have had to add the diff in manually, as I am not sure about applying a diff to my working copy.

I will take just the 'if not (csLoading in ComponentState) then begin' (and 'end') out and see if I get the original behaviour again.

cheers,
John Sunderland

_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to