[Lazarus] Buttons in frames

Mark Morgan Lloyd markMLl.lazarus at telemetry.co.uk
Sun Feb 3 17:48:29 CET 2013


Mattias Gaertner wrote:

>>>> Source -> Unit Information -> General on the new DbConfigCode2(2) tab 
>>>> tells me /usr/local/src/heavywethers/inifiles/trunk/dbconfigcode2.pas 
>>>> [manual transcript] which is what the file should be.
>>> ok
>>>
>>>> ... Unit paths 
>>>> refers to /usr/local/src/heavywethers/inifiles/trunk which is OK. Source 
>>>> paths ditto.
>>> ok
>>>
>>>  
>>>> But Source -> Unit Information -> General on the original DbConfigCode2 
>>>> tab tells me it's /usr/local/src/inifiles/trunk/dbconfigcode2.pas which 
>>>> is wrong.
>>> What is this "original"? When is it opened?
>>> In my former mails I assumed you had opened it yourself.
>> dbconfigcode2 is the name on the tab created when the IDE (at startup) 
>> read the project. I was assuming that dbconfigcode2(2) was the one that 
>> the IDE created when the compiler reported the error, but looking at the 
>> file paths I'm not entirely sure.
> 
> Reading the project simply restores the files last time open. That does
> not count. Question still open: When was the wrong file opened?

It would appear either at the time the unit is first saved, or when a 
frame (possibly form) is opened that crosses an ambiguity.

>>>> I need to be very cautious about jumping to any conclusions over this 
>>>> (having already been wrong once), but it looks as though the compiler is 
>>>> getting and reporting the right path
>>>>
>>>> Compiling /usr/local/src/heavywethers/inifiles/trunk/dbconfigcode2.pas
>>> yes.
>>>
>>>  
>>>> but the IDE at some earlier stage has resolved it to 
>>>> /usr/local/src/inifiles/trunk/dbconfigcode2.pas which it shouldn't. 
>>> What is this "some earlier stage"?
>> When the IDE was opening the project.
> 
> See above.
> 
>  
>>>> That 
>>>> actually fits my experience that given that sort of duplicate tab it's 
>>>> safer to close the older one.
>>>>
>>>> If I close the older tab/pane, save-all and terminate then restart, the 
>>>> one tab that's displayed relating to that file has the correct name 
>>>> /usr/local/src/heavywethers/inifiles/trunk/dbconfigcode2.pas.
>> ..up to this point where I've just done something that makes the 
>> problem go away.
>>
>>> All tabs are named uniquely. If you open two units with the same name
>>> one will get the "(2)" appended. The "(2)" vanishes when the name
>>> becomes unique again.
>> Yes, but which tab gets the suffix: the one that already exists or the 
>> newly-created duplicate?
> 
> When a second is opened it gets the (2), the third gets (3), and so
> forth. It does not matter which one is the project's one.

Which fits in with the original tab (DbConfigCode2) being given the 
wrong filename by the IDE, and the new tab (DbConfigCode2(2)) getting 
the right filename from the compiler's error message.

>> [...]
>>>> However I think that's something to do with the non-working OnClick 
>>>> which I'll get back to presently, this business with tab/pane 
>>>> duplication is at least a few weeks old.
>> So it looks as though it's something to do with the saved state of the 
>> project, i.e. which files are listed as to be opened when the project is 
>> loaded. The file giving the problem had been open (across multiple 
>> sessions of the IDE) ever since the unit and associated frame was 
>> created and saved, I can't remember exactly how I did the save (i.e. 
>> whether it was an explicit save-all or an implicit save when the 
>> compiler was run or the IDE shut down).
> 
> The does not matter for the session.
> 
>  
>> If the compilation is run and finds an error where the file isn't 
>> already open, the file is opened with the correct path and there are no 
>> further problems.
> 
> Nice.

That's what I thought- for a while at least :-)

>> Drat- it's just started happening again. The thing that appears to have 
>> made the difference was telling the IDE to open the frame associated 
>> with the unit, I can now see both forms of the path/name stored in the 
>> .lps file:
>>
>>        <Unit12>
>>          <Filename Value="../../inifiles/trunk/dbconfigcode2.pas"/>
>>          <IsPartOfProject Value="True"/>
>>          <ComponentName Value="DbConfigFrame"/>
>> ..
>>        <Unit15>
>>          <Filename Value="../inifiles/trunk/dbconfigcode2.pas"/>
>>          <ComponentName Value="DbConfigFrame"/>
> 
> You can see that the IDE knows that Unit12 belongs to the
> project, while Unit15 is simply a file on your disk. 
> 
> About "the IDE to open the frame associated with the unit".
> Which file is "the frame" and which file is "the unit"?

If I delete the .lps file and start the IDE it seems to open 
dbconfig2.pas by default, I find this in .lpi:

       <Unit12>
         <Filename Value="..\..\inifiles\trunk\dbconfigcode2.pas"/>
         <IsPartOfProject Value="True"/>
         <ComponentName Value="DbConfigFrame"/>
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Frame"/>
         <UnitName Value="DbConfigCode2"/>
       </Unit12>

If I run the compilation (knowing there's an error in that file) and 
save-all (even without correcting it), I have DbConfigCode2 and 
DbConfigCode2(2) tabs and the new .lps includes

       <Unit12>
         <Filename Value="../../inifiles/trunk/dbconfigcode2.pas"/>
         <IsPartOfProject Value="True"/>
         <ComponentName Value="DbConfigFrame"/>
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Frame"/>
         <UnitName Value="DbConfigCode2"/>
         <EditorIndex Value="0"/>
         <WindowIndex Value="0"/>
         <TopLine Value="1"/>
         <CursorPos X="1" Y="1"/>
         <UsageCount Value="20"/>
         <Loaded Value="True"/>
         <LoadedDesigner Value="True"/>
       </Unit12>
       <Unit13>
         <Filename Value="../inifiles/trunk/dbconfigcode2.pas"/>
         <UnitName Value="DbConfigCode2"/>
         <IsVisibleTab Value="True"/>
         <EditorIndex Value="1"/>
         <WindowIndex Value="0"/>
         <TopLine Value="3"/>
         <CursorPos X="4" Y="22"/>
         <UsageCount Value="10"/>
         <Loaded Value="True"/>
       </Unit13>
     </Units>
     <General>
       <ActiveWindowIndexAtStart Value="0"/>
     </General>
     <JumpHistory Count="1" HistoryIndex="0">
       <Position1>
         <Filename Value="../inifiles/trunk/dbconfigcode2.pas"/>
         <Caret Line="1" Column="1" TopLine="1"/>
       </Position1>
     </JumpHistory>

I think the answer is that unit12 is the frame and unit13 is the form.

Looking at the IDE Source -> Unit Information, the tab DbConfigCode2 is 
/usr/local/src/inifiles/trunk/dbconfigcode2.pas and the tab 
DbConfigCode2(2) is 
/usr/local/src/heavywethers/inifiles/trunk/dbconfigcode2.pas (both of 
those manually transcribed).

Hope that's what you were asking :-)

-- 
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]




More information about the Lazarus mailing list