[fpc-pascal] using Interfaces in descendant classes 2.6.4 vs 3.x
mailinglists at geldenhuys.co.uk
Sat Nov 4 00:09:26 CET 2017
Some of my programs were last compiled with FPC 2.6.4, and there I used
Corba-style Interfaces without a problem. I've now recompiled those
projects with FPC 3.0.4 and the program immediately crashes.
Debugging I found that I was trying to use a interface reference, but
forgot to check if it was nil or not. I've fixed the code, but the issue
is still not resolved. The class in question DOES implement the
interface, but FPC 3.x always returns nil, whereas FPC 2.6.4 correctly
returns a Interface reference.
The class hierarchy is as follows...
TBaseApplication = class(TObject, ICmdLineParams);
TX11Application = class(TBaseApplication)
TfpgApplication = class(TX11Application)
In my applications I only work with a TfpgApplication instance. If the
interface is fully implemented in TBaseApplication, why does FPC 3.x
_always_ report that TfpgApplication doesn't support the ICmdLineParams?
My code looks as follows:
if Supports(fpgApplication, ICmdLineParams, cmd) then
if cmd.HasOption('n', 'newinstance') then
else if not AnotherInstance then
// ICmdLineParams interface is not supported
I looked at the wiki and the FPC 3.x "User Changes" pages and the only
reference to Interface changes is this.
The wiki is very vague with what it means. Either way, I don't consider
my code wrong. I'm using a class hierarchy and the base class does
implement the Interface in question fully, so why does FPC 3.x think it
doesn't? Bottom line, is this a FPC bug and how to I change my code to
work until the bug can be fixed?
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
My public PGP key: http://tinyurl.com/graeme-pgp
More information about the fpc-pascal