Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Strange irregular EConvertionError Exceptions with my component

Status
Not open for further replies.

MedFly

Programmer
Sep 28, 2005
4
DE
Hi there,
I am new to the group and hope someone can help me with a problem that is almost driving me crazy.

I developed a component (adaption from open source EzDICOMax) that reads and displays medical image format DICOM. Most of the time the component works fine but sometimes after compiling an application that uses this component I get a lot of EConvertion Exceptions with images that loaded without problems before. Even very "save" type convertion like CARDINAL or WORD to INTEGER raise these exceptions, in this case Integer Overflow.
example:
var
i:INTEGER;
e_len:CARDINAL;
begin
e_len := 0;
.
.
.
i := e_len - 1;
.
.

I found out, that when I unregister the component, delete the dcu's, and reregister it, everything works fine again...
This happens quite often, most of the time when I changed source of the component, but sometimes even when I did not touch the component and only worked on the parent application.

Does anybody have a clue?

regards,
Andreas
 
There are two possible scenarios that i CAN THINK could cause the problem you mention:

Scenario A - You are building the application that uses the component with packages

To check if the application that uses your component is being built with packages
- From delphi main menu select "Project|Options" to open Project Options window
- Select Packages section
If "Build with packages" option is ticked

If you are building with packages each time you change the source code of your component you MUST rebuild the package that contains it to make sure your application is using the latest changes.


Scenario B - You are building your application without packages

Even if you are not building your application with packages it is possible to be in a situation that your component related ".dcu" files dont get rebuild with the application that uses them. Briefly speaking just because you change the source code of your component does not guarantie that it will be recompiled when recompiling the application that uses it.

You should be aware that delphi will only rebuild those units that it find in its Search Path directories. In fact the units (be they .dcu or .pas) in search path directories are the only ones used to compile the application.

"Only those files on the compiler's search path or the library search path will be included in the build." taken from delphi help (click on help button while viewing Tools|Options window with Library-Win32 selected to view it all)

So it could be the case that your components ".dcu" files are in the search path but ".pas" files are not. In such case, changing your components source code ".pas" files will have no effect on ".dcu" files when you compile the application that uses the component. Of course compiling the package containing the component will rebuild the ".dcu" properly.

To check what search path directories is delphi using:
- Select from delphi main menu "Tools|Options" to open options window
- On options window select "Environment Options|Delphi options|Library - Win32"
- Click on the [...] button at the right handside of "Library path" label
- You will see Directories window listing all directories in SEarch Path


If you dont find the directory of your component related ".pas" files in the search path list than this is potentially your problem. To solve it, add the directory of containing component "*.pas" files in the search path.


I hope this helps you find your problem.




"It is in our collective behaviour that we are most mysterious" Lewis Thomas
 
Hi bledazemi,

thanks for this comprehensive answer!
Unfortunately my application is neither built with packages nor is the search path for the component's .pas and .dcu files wrong or missing.

My first idea was, that there are some uninitialized variables causing this problem, but I could not detect any.
Another thought was, that there is a problem with memory allocation, because some routines use getMem and freeMem a lot. Anyway, I don't know what to think of this problem.
Luckily, I know what to do to get rid of the exeptions: recompile the component befor the application ;-)

regards,
Andreas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top