Board index » delphi » D3: Confirm bug in ComObj ?

D3: Confirm bug in ComObj ?

Hi,

this is a code snippet from ComObj.PAS:

procedure TComObjectFactory.RegisterClassObject;
const
  RegFlags: array[ciSingleInstance..ciMultiInstance] of Integer =
 (REGCLS_SINGLEUSE, REGCLS_MULTIPLEUSE);
begin
  OleCheck(CoRegisterClassObject(FClassID, Self,
    CLSCTX_LOCAL_SERVER,
    RegFlags[FInstancing], FRegister));
end;

To single-step through ComObj.PAS I had compiled "my own copy",
range checks are thus on. Calling

TAutoObjectFactory.Create(ComServer, AClass, Class_Dummy,
                      ciInternal);

will eventually lead to a range check error in
RegisterClassObject because of the way RegFlags is declared and
the method is designed.

Can this problem be safely ignored? I personally would not think
so, as   RegFlags[ciInternal]   is not a defined value and I have
had spurious OLE errors ('wrong parameter') for no apparent
reason which NOW I feel perhaps could be attributed to this.

A *possible* fix could be:

  {$IFDEF Fix}
    if not (FInstancing = ciInternal) then
  {$ENDIF}

    OleCheck(CoRegisterClassObject(FClassID, Self,
      CLSCTX_LOCAL_SERVER,
      RegFlags[FInstancing], FRegister));

I have *no* idea which side-effects this fix may have.

Any thoughts / confirmations? Borland?
--
Stefan.Hoffmeis...@UNI-Passau.DE
http://kakadu.rz.uni-passau.de/~w4hoff01/
University of Passau, Bavaria, Germany

 

Re:D3: Confirm bug in ComObj ?


On Thu, 22 May 1997 11:12:16 GMT, Stefan.Hoffmeis...@Uni-Passau.de

Quote
(Stefan Hoffmeister) wrote:
>Hi,

>this is a code snippet from ComObj.PAS:

>procedure TComObjectFactory.RegisterClassObject;
>const
>  RegFlags: array[ciSingleInstance..ciMultiInstance] of Integer =
> (REGCLS_SINGLEUSE, REGCLS_MULTIPLEUSE);
>begin
>  OleCheck(CoRegisterClassObject(FClassID, Self,
>    CLSCTX_LOCAL_SERVER,
>    RegFlags[FInstancing], FRegister));
>end;

>To single-step through ComObj.PAS I had compiled "my own copy",
>range checks are thus on. Calling

>TAutoObjectFactory.Create(ComServer, AClass, Class_Dummy,
>                      ciInternal);

>will eventually lead to a range check error in
>RegisterClassObject because of the way RegFlags is declared and
>the method is designed.

>Can this problem be safely ignored? I personally would not think
>so, as   RegFlags[ciInternal]   is not a defined value and I have
>had spurious OLE errors ('wrong parameter') for no apparent
>reason which NOW I feel perhaps could be attributed to this.

>A *possible* fix could be:

>  {$IFDEF Fix}
>    if not (FInstancing = ciInternal) then
>  {$ENDIF}

>    OleCheck(CoRegisterClassObject(FClassID, Self,
>      CLSCTX_LOCAL_SERVER,
>      RegFlags[FInstancing], FRegister));

>I have *no* idea which side-effects this fix may have.

>Any thoughts / confirmations? Borland?

This looks very much like a bug to me.
I do not see an easy workaround other than
modifying the ComObj unit itself (or not using
the ciInternal style COM objects of course).

Thinking about it, why would you want to have
a class factory for internal COM objects?
Couldn't you simply create the objects
directly without going through a factory?
Just looked at the ComObj.Pas source
again - there seems to be no way of
creating a TComObject without a
corresponding TComObjectFactory,
so my questions are not valid...

--
Hallvard Vassbotn
Falcon R&D, Reuters Norge

Other Threads