Recent

Author Topic: Units aren't added to uses clause when components are created  (Read 3395 times)

jedt

  • Newbie
  • Posts: 6
Units aren't added to uses clause when components are created
« on: September 08, 2012, 01:29:18 am »
Hi all,

I've ported some Delphi components to Lazarus; but there's a difference in behavior that I'd like to resolve if I could... 

In both Lazarus and Delphi, when a user drops one of our design-time components on a form, the unit containing the class definition is added to the project.  So far, so good... but Delphi also adds several additional units that contain some supporting data type definitions to the uses clause.  In Lazarus, only the first unit is added. 

For instance, if I drop a TAdsTable component, Delphi adds the adstable (which contains the TAdsTable definition), as well as adsfunc and adsdata units to the uses clause.  In Lazarus, only the adstable unit is added.  Is there something that I can (or need to) change in my package to tell Lazarus to add these additional units when creating the component at design-time, or is there potentially a Lazarus issue that prevents the IDE from adding all necessary units to satisfy all of the dependencies?  Thanks for any suggestions!

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Units aren't added to uses clause when components are created
« Reply #1 on: September 08, 2012, 08:11:02 am »
Quote
Is there something that I can (or need to) change in my package to tell Lazarus to add these additional units when creating the component at design-time, or is there potentially a Lazarus issue that prevents the IDE from adding all necessary units to satisfy all of the dependencies?
No to my knowledge. Lazarus already does the job right IMHO, what should be added is only the unit containing the component. Other units might not be used at all, yet it may contain initialization and/or finalization part which will always be linked, thus unnecessarily increase the code size (except when expected).

Lazarus can do it in other way though. Say you have unit U containing function F returning type T where T is defined in unit U1. If you do (from unit other than U and U1):
Code: [Select]
|x := F; // | <- cursorthen press Ctrl+Shift+C, unit U1 will be automatically added, which is correct behavior.

 

TinyPortal © 2005-2018