Board index » delphi » BDS 2006 and Quality Central

BDS 2006 and Quality Central


2005-12-08 07:49:49 PM
delphi89
I have received my copy of BDS 2006 yesterday and well... it is really sweet
indeed! What a good change from D2005!
I have started upgrading my project from Delphi 7 to D2006 and so far so good. I
noticed that on the Partner DVD there is GExperts, which is nice to have
indeed. Also, there is JCL 1.96 and JVCL 1.31. I thought I'd install
them, but the directory structure has changed and since I use only snippets
of both those libraries, I cannot be bothered with this at this stage. Not
to mention that these versions of JCL and JVCL are not on the official
website. So I decided to stick to JCL 1.95 and JVCL 1.30 for the time being,
which mean I had to modify a few things here and there (mainly add {$IFDEF
VER180} and all that follows wherever required). That was enough to get
things working.
I did, however, come across an interesting bug, which makes the whole IDE
crash straight away. I was trying to recompile a library (DeCAL - Delphi
Container and Algorithm Library). At some point, there is a piece of code
that reads:
procedure FreeAndClear(var container);
var con : DContainer;
begin
con := DContainer(container);
if assigned(con) then
begin
ObjFree(con);
con.free;
DContainer(con) := nil; <--- Pascal Hint
end;
end;
D2006 will hint to me that the value assigned to 'con' is never used. Well,
for one, it is not correct, but then again, I can appreciate that it may not
be trivial to get the algorithm to realise that. No worries there therefore.
The problem, however, is that that library is part of a package of
components that I use in my application. If I try to build the package (i.e.
Shift+F9 for instance) then the IDE is going to crash straight away. If,
however, I compile the package (i.e. Ctrl+F9 for instance) the everything's
'fine'.
Since I don't like messages anyway, I modified the code above so that it now
reads:
procedure FreeAndClear(var container);
begin
if assigned(DContainer(container)) then
begin
ObjFree(DContainer(container));
FreeAndNil(DContainer(container));
end;
end;
Not great, but at least now the IDE doesn't crash when building/compiling my
package.
Ok, now to QualityCentral to file this... :)
Alan.
 
 

Re:BDS 2006 and Quality Central

"Alan Garny" <XXXX@XXXXX.COM>writes
Quote
procedure FreeAndClear(var container);
var con : DContainer;
begin
con := DContainer(container);
if assigned(con) then
begin
ObjFree(con);
con.free;
DContainer(con) := nil; <--- Pascal Hint
end;
end;

D2006 will hint to me that the value assigned to 'con' is never used.
Well, for one, it is not correct, but then again,
The compiler is correct, and this is probably the reason for your "bug".
You only nil out the local copy of the reference in con - you don't modify
the original var container at all.
Your modified version of the code looks correct.
 

Re:BDS 2006 and Quality Central

"Alan Garny" <XXXX@XXXXX.COM>writes
Quote
I had to modify a few things here and there (mainly add {$IFDEF VER180}
and all that follows wherever required). That was enough to get things
working.

Borland now recommend using {$IF CompilerVersion>= X.X} and {$IF RTLVersion
Quote
X.X} instead of {$IF VERxxx} - Refer to the comments in the system.pas
unit.
--
regards,
John
The Fastcode Project:
www.fastcodeproject.org/
 

Re:BDS 2006 and Quality Central

Alan Garny a écrit :
Quote
Also, there is JCL 1.96 and JVCL 1.31. I thought I'd install
them, but the directory structure has changed and since I use only snippets
of both those libraries, I cannot be bothered with this at this stage. Not
to mention that these versions of JCL and JVCL are not on the official
website.
Official releases of the JCL and JVCL will be out in few days (there are
some installation issues that should be solved before); the cvs versions
of the JCL and JVCL are able to install the libraries for D2006.
Quote
So I decided to stick to JCL 1.95 and JVCL 1.30 for the time being,
JVCL 1.30 is really old :) Because you are using JCL 1.95, I think you
meant JVCL 3.0.
--
Florent Ouchet
JCL administrator
 

Re:BDS 2006 and Quality Central

Quote
Your modified version of the code looks correct.
Typecasting a freed variable looked dodgy to me too. And there seemed little
point given that it was local, so it looks like a bug. The modified version also
looks correct to me, not to mention easier to understand :-) I am not sure all
the typecasting is necessary even now, though.
Cheers,
Jim Cooper
__________________________________________
Jim Cooper XXXX@XXXXX.COM
Skype : jim.cooper
Tabdee Ltd www.tabdee.ltd.uk
TurboSync - Connecting Delphi to your Palm
__________________________________________
 

Re:BDS 2006 and Quality Central

"Hallvard Vassbotn" <XXXX@XXXXX.COM>writes
Quote

"Alan Garny" <XXXX@XXXXX.COM>writes
news:43981db7$XXXX@XXXXX.COM...
>procedure FreeAndClear(var container);
>var con : DContainer;
>begin
>con := DContainer(container);
>if assigned(con) then
>begin
>ObjFree(con);
>con.free;
>DContainer(con) := nil; <--- Pascal Hint
>end;
>end;
>
>D2006 will hint to me that the value assigned to 'con' is never used.
>Well, for one, it is not correct, but then again,

The compiler is correct, and this is probably the reason for your "bug".

You only nil out the local copy of the reference in con - you don't modify
the original var container at all.
Oops, indeed! it is not my code and I guess I just took it for granted that
it worked, but obviously it doesn't do what was probably originally
intended. Good, therefore, to see that D2006 can now pick up this kind of
things (compared with D7).
Quote
Your modified version of the code looks correct.
Phew! :)
Alan.
 

Re:BDS 2006 and Quality Central

"Florent Ouchet" <XXXX@XXXXX.COM>writes
Quote
Alan Garny a écrit :
>Also, there is JCL 1.96 and JVCL 1.31. I thought I'd install
>them, but the directory structure has changed and since I use only
>snippets of both those libraries, I cannot be bothered with this at this
>stage. Not to mention that these versions of JCL and JVCL are not on the
>official website.
Official releases of the JCL and JVCL will be out in few days (there are
some installation issues that should be solved before); the cvs versions
of the JCL and JVCL are able to install the libraries for D2006.
Good to read!
Quote
>So I decided to stick to JCL 1.95 and JVCL 1.30 for the time being,
JVCL 1.30 is really old :) Because you are using JCL 1.95, I think you
meant JVCL 3.0.
Oops... I indeed meant JVCL 3.0... :)
Alan.
 

Re:BDS 2006 and Quality Central

"Jim Cooper" <XXXX@XXXXX.COM>writes
Quote
>Your modified version of the code looks correct.
Typecasting a freed variable looked dodgy to me too. And there seemed
little point given that it was local, so it looks like a bug. The modified
version also looks correct to me, not to mention easier to understand :-)
I'm not sure all the typecasting is necessary even now, though.
Indeed, that is not necessary... I just had a quick look at the FreeAndNil
and implementation and it looks like the FreeAndClear function I mentioned
in my original post could look like:
procedure FreeAndClear(var container);
var con : DContainer;
begin
con := DContainer(container);
if assigned(con) then
begin
ObjFree(con);
con.free;
Pointer(container) := nil;
end;
end;
Alan.