Menu ▾ ▴

#607 After the Uses Clause Manager was opened once, Declare Variable, the formatter and the Code Proofreader no longer find identifiers from other units

New
open
nobody
None
1 day ago
1 day ago
No

The Uses Clause Manager runs a thread (TUnitExportParserThread) that collects the identifiers of the units in the search path. Besides the Identifiers tab of the Uses Clause Manager, its result is used by Declare Variable (TUsesClauseMgrExpert.TryGetIdentifiers), to find the types of identifiers declared in other units, and by the code formatter and the Code Proofreader (TUsesClauseMgrExpert.TryLookupIdentifier), to find how an identifier is spelt.

When the Uses Clause Manager dialog opens, it takes the list of identifiers away from the thread (DetachIdentifiers in TfmUsesManager) and frees it when it is closed. The thread is left without a list, so TryGetIdentifiers and TryLookupIdentifier fail until the active project changes or the Uses Clause Manager is opened again.

Reproduced in Delphi 13.2: a project with function GxFunc554: Integer; in one unit, and X := GxFunc554; in another unit that uses it.

  1. Declare Variable on X offers the type Integer.
  2. Open the Uses Clause Manager, wait until the identifiers are loaded, close it with Cancel.
  3. Declare Variable on X again: the type is empty.

Possible fix: the dialog uses the thread's list without taking it over. The thread is only restarted when the active project changes or the dialog opens, and neither can happen while the modal dialog is shown.

Found while looking into bug [#605].

Related

Bugs: #605

Discussion


Log in to post a comment.