BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help required with (D5) build/compile problem.

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.misc
View previous topic :: View next topic  
Author Message
dsr@cix.compulink.co.uk
Guest





PostPosted: Tue Mar 22, 2005 2:02 pm    Post subject: Help required with (D5) build/compile problem. Reply with quote



I've got this problem that I don't understand and wondered if anyone could
throw some light on to what might be happening.

Although I'm describing this with an image control, you don't need to know
anything about images or this control to help me.

Back Ground
===========
I have a project which uses a third party component to cope with loading
and saving non-standard image file formats into an Image control. It does
this by using TPicture.RegisterFileFormat in it's initialization section,
and calls some code to convert the image to a bitmap and then displays it.
I've added a codesite message to this bit of code and it does seem to be
doing this.

Problem
=======
This is where it gets weird (to me at least). If I *build* my project and
then run it, then it will load the new image format into the image control
, but when I try to save it, the component throws an exception that the
image isn't a bitmap. Obviously something has gone wrong.
However if I *compile* my project and run it, all works correctly.

Even if I select Build project and then immediately it's built I select
Compile, it works.
It only fails if I try and run directly after a build.

Now as far as I understand it, when I select build, delphi finds all the
pas files, compiles them into dcu files, then compiles the dpr and then
links everything together into an exe. Similarly when I select compile,
delphi just compiles the dpr and then links everything together into an
exe.

So why would a compile result in a program that works and a build in one
that doesn't ? Does a compile do something extra that I'm missing ?

Anyone any idea how to work out what's going on or suggestions on how to
fix it ?

I've tried compiling/building using DCC32.exe and that exhibits the same
problem, so it doesn't look like it's IDE specific.

(Oh and just to be sure I've removed all the pas files to do with the
troublesome component, so that both the compile & build must be using the
same dcu's)

David
Back to top
Dirk Claessens
Guest





PostPosted: Tue Mar 22, 2005 9:00 pm    Post subject: Re: Help required with (D5) build/compile problem. Reply with quote



Verily, on di 22 mrt 2005 03:02:26p, wrote in
comp.lang.pascal.delphi.misc [news:d1p8hi$c64$1 (AT) thorium (DOT) cix.co.uk]:

Quote:
Problem
=======
This is where it gets weird (to me at least). If I *build* my
project and then run it, then it will load the new image format
into the image control , but when I try to save it, the component
throws an exception that the image isn't a bitmap. Obviously
something has gone wrong. However if I *compile* my project and
run it, all works correctly.


Chances are good you have a initialization problem ( or the lack
thereof <g> )

Depending on choosing build/compile, uninitialized memory ( var's
arrays, pointers, whatever ) *may* persistently contain sensible data
and the app will work. Other times, it just won't.

Whenever I had this kind of weird problem, 9 times out of 10 it was
indeed an initialization problem.


--
Dirk.
No trees were killed in the creation of this message;
however, many electrons were terribly inconvenienced.
http://users.pandora.be/dirk.claessens2

Back to top
dsr@cix.compulink.co.uk
Guest





PostPosted: Wed Mar 23, 2005 11:29 am    Post subject: Re: Help required with (D5) build/compile problem. Reply with quote



Quote:
Obviously
something has gone wrong. However if I *compile* my project and
run it, all works correctly.


Chances are good you have a initialization problem ( or the lack
thereof <g> )

Problem found and in my opinion it's a delphi compiler bug.

I had two units registering the same FileExtension (with
TPicture.RegisterFileFormat).
So unit1's initialization was something like (pseudo code)

initialization
TPicture.RegisterFileFormat('xxx', Txxxhandler);

and unit2's was

initialization
TPicture.RegisterFileFormat('xxx', TAlternatexxxhandler);

It seems that which ever is initialised last is the one which gets to
handle a picture file with that extension.

Where the 'bug' appears is that if I compile the program and then run it,
unit1's initialization gets called and then unit2's, whereas if I do a
build unit2's is called and then unit1's.
So compiling was using a handler that did as I expected whereas building
used the alternate handler that didn't have quite the same functionality

David

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.misc All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.