Solved

What is wrong with my code ?

Posted on 2004-10-08
10
238 Views
Last Modified: 2012-05-05
I write a vcl that use own editor.
I load into package next code and install it. All is perfect. I reCompile how many I wish. All is perfect.

I drop a mine vcl to a form. If I wish I can recompile the package and all is OK.

The problem come from here :

I double click on my vcl and open my editor. OK . Close it. OK. But if I try to recompile the vcl get an rtl60.dpk error message.

OR ... drop my vcl.. double click to open my editor...close my editor.. try to close my Delphi ... get an error message as my Delphi can read some memory address.

The code is next ( a sample code not my real code from vcl but get some errors )/

COMPONENT CODE:

unit Test;

interface

uses
  Windows, Messages, SysUtils, Classes, Controls, DesignIntf, DesignEditors;

type
  TTest = class(TCustomControl)
  private
    { Private declarations }
  protected
    { Protected declarations }
  public
    { Public declarations }
  published
    { Published declarations }
  end;

  type
  TgnEditor = class(TComponentEditor)
    procedure ExecuteVerb(Index: Integer); override;
    function GetVerb(Index: Integer): string; override;
    function GetVerbCount: Integer; override;
  end;

procedure Register;

implementation

uses editor;

// 8<-------- TgnEditor -------->8 \\

procedure TgnEditor.ExecuteVerb(Index: Integer);
begin
  case Index of
    0: ShowEditor(TTest(Component));
  end;
end;

function TgnEditor.GetVerb(Index: Integer): string;
begin
  case Index of
    0: Result := 'Edit...';
  end;
end;

function TgnEditor.GetVerbCount: Integer;
begin
  Result := 1;
end;


procedure Register;
begin
  RegisterComponents('Samples', [TTest]);
  RegisterComponentEditor(TTest, TgnEditor);
end;

end.
0
Comment
Question by:ginsonic
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
10 Comments
 
LVL 9

Author Comment

by:ginsonic
ID: 12261070
EDITOR CODE:

unit editor;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, dialogs,
  test;

  procedure ShowEditor(FTest: TTest);

type
  TEdits = class(TForm)
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Edits: TEdits;

implementation

{$R *.dfm}

procedure ShowEditor(FTest: TTest);
var FForm: TEdits;
begin;
  FForm := TEdits.Create(nil);
  FForm.Caption := Format(' %s Editor', [FTest.Name]);
  FForm.Show;
end;

end.
0
 
LVL 13

Expert Comment

by:BlackTigerX
ID: 12262893
one thing I can see right away is this:

procedure ShowEditor(FTest: TTest);
var FForm: TEdits;
begin;
  FForm := TEdits.Create(nil);
  FForm.Caption := Format(' %s Editor', [FTest.Name]);
  FForm.Show;

  FForm.Free //add this line!!!
end;

you need to free that variable there, else is a memory leak problem
0
 
LVL 9

Author Comment

by:ginsonic
ID: 12262997
My editor can be close just if click on close button from title bar ( the X one ). I think that is enough to free the form editor.

Somebody else get same problems when use the code ?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Author Comment

by:ginsonic
ID: 12263029
In same time I'm sure that isn't a FForm.Free problem. How you can see is a blank form so not much memmory used.

I tested with FForm opened ( to see if is a destroy problem ) to recompile my package. Same rtl60.dpk error.
0
 
LVL 13

Accepted Solution

by:
BlackTigerX earned 500 total points
ID: 12263424
unless you have caFree in the Action of the OnClose event, the form is not freed automatically
0
 
LVL 9

Author Comment

by:ginsonic
ID: 12265189
If I use a ShowModal all work perfect. The problem to bee the free of form !?!?
BlackTigerX can you tell me more about how to use an action to free ?
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 12265237
procedure ShowEditor(FTest: TTest);
var FForm: TEdits;
begin;
  FForm := TEdits.Create(nil);
  try
    FForm.Caption := Format(' %s Editor', [FTest.Name]);
    FForm.ShowModal;
  finally
//    FForm.Release; // if is TForm
    FForm.Free;
  end;
end;
0
 
LVL 9

Author Comment

by:ginsonic
ID: 12265252
Don't wish to use a modal form. The BlackTigerX comment is the solution to my problem. Thanks to all for support!
See you on net :)
0
 
LVL 13

Expert Comment

by:BlackTigerX
ID: 12267306
please disregard this (my own) comment:

FForm.Show;

  FForm.Free //add this line!!!

(duh... the form would be shown and immediatly be gone)...
0
 
LVL 9

Author Comment

by:ginsonic
ID: 12269260
Ni problem :) The answer was the caFree action on close. Thanks again !
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Correct Component for Shopping Cart. 2 121
can't find the executable in Simulator 1 113
Delphi problems to abort a printjob 9 36
Firemonkey Queue list 1 33
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question