View Issue Details

IDProjectCategoryView StatusLast Update
0005722JEDI VCL00 JVCL Componentspublic2012-06-11 17:10
ReporterdejoyAssigned Toobones 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionsuspended 
Product Version 
Target VersionFixed in Version 
Summary0005722: Cannot dynamically create subclass of TJvPlugIn, and donate fixed code.
DescriptionWhen your dynamically creating a subclass of TJvPlugIn,you will receive an error message 'Resource not found: subclassname'. your cannot use TJvPlugIn.CreateNew instead of Create to create a TJvPlugIn without using the associated .DFM file to initialize it.
I have add and rewritten procedure of TJvPlugIn.CreateNew process to fix the error.

such as those code:

type
  TNewPlugin = class(TJvPlugIn)
  end;

var
  PluginName: TNewPlugin;
begin
  PluginName := TNewPlugin.CreateNew(Self); //raise a error 'Resource not found'
end;

Steps To ReproduceNew:
//--------------------------- added
  TJvPlugIn = class(TDataModule)
  public
    constructor CreateNew(AOwner: TComponent; Dummy: Integer = 0); override;
  end;

constructor TJvPlugIn.CreateNew(AOwner: TComponent; Dummy: Integer);
begin
  // Create datamodule
  inherited CreateNew(AOwner);

  DesignSize := Point(100, 100);

  // Create commands-collection
  FCommands := TJvPluginCommands.Create(Self);
  FInstanceCount := 1;
end;
//--------------------------------------------

//---------------- rewritten to fixed
constructor TJvPlugIn.Create(AOwner: TComponent);
begin
  // Create datamodule
  CreateNew(AOwner);

  if (ClassType <> TJvPlugIn) and not (csDesigning in ComponentState) then
  begin
    if not InitInheritedComponent(Self, TJvPlugIn) then
      raise EResNotFound.CreateResFmt(@RsEFmtResNotFound, [ClassName]);

    if OldCreateOrder then
      DoCreate;
  end;
end;
//--------------

in new this code run ok:
  PluginName := TPluginName.CreateNew(Self); //OK
TagsNo tags attached.

Activities

2011-11-27 10:03

 

TJvPlugIn.error.rar (4,060 bytes)

dejoy

2011-11-27 10:04

reporter   ~0019140

New:
//--------------------------- added
  TJvPlugIn = class(TDataModule)
  public
    constructor CreateNew(AOwner: TComponent; Dummy: Integer = 0); override;
  end;

constructor TJvPlugIn.CreateNew(AOwner: TComponent; Dummy: Integer);
begin
  // Create datamodule
  inherited CreateNew(AOwner);

  DesignSize := Point(100, 100);

  // Create commands-collection
  FCommands := TJvPluginCommands.Create(Self);
  FInstanceCount := 1;
end;
//--------------------------------------------

//---------------- rewritten to fixed
constructor TJvPlugIn.Create(AOwner: TComponent);
begin
  // Create datamodule
  CreateNew(AOwner);

  if (ClassType <> TJvPlugIn) and not (csDesigning in ComponentState) then
  begin
    if not InitInheritedComponent(Self, TJvPlugIn) then
      raise EResNotFound.CreateResFmt(@RsEFmtResNotFound, [ClassName]);

    if OldCreateOrder then
      DoCreate;
  end;
end;
//--------------

in new this code run ok:
  PluginName := TPluginName.CreateNew(Self); //OK

obones

2012-02-24 16:29

administrator   ~0019539

I tried your application, and clicking on the "CreateNew" button does not crash at all.
I'm using the latest SVN content under D2007

obones

2012-06-11 17:10

administrator   ~0019825

No answers, suspending the issue

Issue History

Date Modified Username Field Change
2011-11-27 10:03 dejoy New Issue
2011-11-27 10:03 dejoy File Added: TJvPlugIn.error.rar
2011-11-27 10:04 dejoy Note Added: 0019140
2012-02-22 14:52 obones Status new => acknowledged
2012-02-24 16:29 obones Note Added: 0019539
2012-02-24 16:29 obones Status acknowledged => feedback
2012-06-11 17:10 obones Note Added: 0019825
2012-06-11 17:10 obones Status feedback => resolved
2012-06-11 17:10 obones Resolution open => suspended
2012-06-11 17:10 obones Assigned To => obones