[ALL TD VERSIONS] Multiple inheritance and qualification

Report bugs and possible workarounds for ANSI TD versions
Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 3447
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

[ALL TD VERSIONS] Multiple inheritance and qualification

Post by Dave Rabelink » 27 Mar 2017, 09:40

This seems to be a very old issue.
I found this during porting from TD15 to TD61 in the case that the sequence of the classes in the "Derived from" section are switched.
Still present in TD7.0


Situation, see screenshot:

SourceCode.png

There are two base classes, each having one instance variable.
There is a class which derives from those two base classes.

To set and get the value of the two instance variables you do for instance:

Code: Select all

    Set nMyMode = 1234
    Set nMyDummy = 9000

A valid qualification for the point of view of an instance of the third class is:

Code: Select all

    hWndForm.ClsDlgBase_Mode.nMyMode
    hWndForm.ClsDlgBase_Dummy.nMyDummy
At least, I expected this to be !

But it depends on the sequence of the classes in the derive from section.

When class ClsDlgBase_Mode is the first item in the section, the qualification to this class is ok.
But then the other qualification to class ClsDlgBase_Dummy will fail.
In the case of the example, the variable nMyDummy has the same value of nMyMode !!!

When switching the sequence of the classes in derived from, the issue is the other way around.
Then nMyMode will have the value set on nMyDummy !!

See screenshot:

MultipleInheritanceIssue.png

IMHO this is wrong.

I post this (even when this issue is found on TD15 up to TD61) to have this designated as defect.
But also to show others that this issue is present and be aware of this.

So it could be fixed or at least mentioned in the documentation on qualification.
When not aware you can get unpredictable results and look for the reason which has cost me quite some time to find.

Use testcase:

- run and see the values for the both variables
- switch the classes in de defived from section
- comment the instance of the dialog and uncomment it (to force recompilation)
- run and see that the issue for the variables is the other way around.

MultipleInheritanceIssue.zip

Testcase is in TD15 format to be used in all TD versions.
You do not have the required permissions to view the files attached to this post.
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

User avatar
Charlie
Canada
Posts: 652
Joined: 07 Mar 2017, 18:52
Location: Fredericton, New Brunswick, Canada

Re: [ALL TD VERSIONS] Multiple inheritance and qualification

Post by Charlie » 27 Mar 2017, 11:21

Excellent sleuthing !!!

I vote for documentation fix.

The last thing I want to see in my code is some well-intentioned fellow code-monkey setting up (using your code sample) "nMyMode" variables in multiple classes in one long class hierarchy, and then having multiple qualified references (in the form window instance) of the various "nMyMode" variables in the various classes of the hierarchy.

Doing that for functions, I completely get (different functions for different circumstances). Doing that for variables gets my eye twitching like Chief Inspector Dreyfus (from the original pink panther series).

Then again, I haven't had my morning caffeine dose yet ...

Return to “Bug Reports (TD 4.2 and older)”

Who is online

Users browsing this forum: [Ccbot] and 1 guest