[fpc-devel] Bug report 12110 needs a cleanup in the bug tracker system?

Michael Van Canneyt michael at freepascal.org
Sun Sep 14 11:35:36 CEST 2008



On Sat, 13 Sep 2008, ABorka wrote:

> Hi Michael,
> 
> I see 12110 is applied now, super :)
> 
> I am trying to improve on the fcl-web and the next step would be to fix the
> apache module related things. However, there is a problem I could use some
> help with.
> It seems that when the apache module (TCustomApacheApplication) tries to
> create an instance of the TFPWebModule when a web request comes in, it just
> crashes:
> To my best knowledge this happens in (fpapache.pp)
> TCustomApacheApplication.HandleRequest at line
> 
> M:=MC.Create(Self);
> 
> MC and M are declared
>   MC : TCustomHTTPModuleClass;
>   M  : TCustomHTTPModule;
> 
> I believe I've tracked the problem to (rtl/objpas/classes/dm.inc)
> 
> Constructor TDataModule.Create(AOwner: TComponent);
> begin
>   CreateNew(AOwner);
>   if (ClassType <> TDataModule) and
>     not (csDesigning in ComponentState) then
>     begin
>     if not InitInheritedComponent(Self, TDataModule) then
>       raise EStreamError.CreateFmt(SErrNoSTreaming, [ClassName]);
>     if OldCreateOrder then
>       DoCreate;
>     end;
> end;
> 
> The raise always seems to be happening when anything other than a TDataModule
> class is created (including TDataModule descendants).
> I've tried with all the TDataModule descendants in fcl-web up till
> TFPWebModule:
> TFPWebModule -> TCustomFPWebModule -> TSessionHTTPModule -> TCustomHTTPModule
> -> TDataModule
> 
> All of them generate this exception, except TDataModule (of course, because
> the exception raising code is not even running then).
> 
> My knowledge proved insufficient to solve this so I ask if you guys can come
> up with something.
> This exception problem exists even if I just create a normal application and
> do a
> 
> var  M : TCustomHTTPModule;
> begin
>       M:=TCustomHTTPModule.Create(Form1{Self});//<- crashing here
>       M.Free;
> end;
> 
> for any TDataModule descendant in the above object chain.
> "Failed to initialize component: No streaming method available."
> exception is always triggered.

It is correct. TDataModule is intended to be designed in an IDE, and to load
itself from a stream. I assume you are not using Lazarus to create your descendents;
if you were, they would be streamed correctly.

In that case, we should maybe enable support for non-streamed webdatamodules.
The only way I can think of is to have a Class method:
  Class Function Streamed : Boolean;
which by default returns True. In that case 'CreateNew()' should be used to instantiate
the datamodule.

In case you are using Lazarus to do all this, it means you forgot the lresources
clause in your program's uses clause.

Michael.



More information about the fpc-devel mailing list