You are not logged in.
Pages: 1
It turns out that when destroying a TDBRestserver, the registered TSQLVVirtualtableModule 's may already be destroyed...
This causes a very ugly AV in the destructor
destructor TSQLRestServerDB.Destroy;
var i: integer;
begin
try
for i := 0 to high(fRegisteredVirtualTableModule) do
if fRegisteredVirtualTableModule[i]<>nil then
// to avoid GPF in TSQLVirtualTable.Destroy e.g.
fRegisteredVirtualTableModule[i].fServer := nil; // MAY VERY WELL ACCESS A DESTROYEDE COMPONENT!!!
inherited Destroy;
finally
try
fStatementCache.ReleaseAllDBStatements;
finally
fOwnedDB.Free;
end;
end;
end;
Therefor I added an empty, virtual "unregister" method to TSQLRestServer, and an overriden one to TSQLRestServerDB:
// for de-registering a viirtual table module that gets destroyed for some reason
procedure TSQLRestServerDB.UnregisterVirtualTableModule(aVirtualTableObject:TSQLVirtualTableModule);
VAR i,cnt:integer;
begin
cnt:=0;
for i := low(fRegisteredVirtualTableModule) to high(fRegisteredVirtualTableModule) do
begin
if fRegisteredVirtualTableModule[i]=aVirtualTableObject then
fRegisteredVirtualTableModule[i]:=nil;
end;
end;
And added a destructor to TSQLVirtualTableModule:
destructor TSQLVirtualTableModule.Destroy;
VAR i:integer;
begin
if assigned(FServer) then
FServer.UnregisterVirtualTableModule(self);
inherited; // for debugging purpose
end;
And now, my ugly AV has disappeared!
My suggestion would be to use an TObjectList or TList for maitaning a list of objects rather than the fRegisteredVirtualTableModule array of objects. Also for a 'register/Unregister kind of way to manage the list of virtual tables in a TSQLRestServerDB. Hell, why not add an indexed property VirtualTableModule[idx:integer] and a VirtualTableModuleCOunt for that matter... Or maybe a (protected/public) VirtualTableModuleList:TObjectList ...
Regards - Hans
Offline
I am still not able to find out in which circumstances when destroying a TDBRestserver, the registered TSQLVVirtualtableModule 's may already be destroyed...
But I've committed a fix if this occurs, a bit diverse than yours (just overriding TSQLVirtualTableModuleDB.Destroy is enough), but the same idea.
See http://synopse.info/fossil/info/5680d09e81
Thanks for the report.
Offline
Great!
Offline
Pages: 1