View Issue Details

IDProjectCategoryView StatusLast Update
0031666LazarusIDEpublic2017-04-19 11:56
ReporterZoran VučenovićAssigned ToMattias Gaertner 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version1.8Product Build 
Target VersionFixed in Version1.8 
Summary0031666: UseUnit dialog cannot add unit to main project file, if you previously added some unit to implementation section
DescriptionUseUnit dialog (Main menu->Source->Add Unit to Uses Section), when called from main project file, doesn't allow to chose between Interface or Implementation section (Radio group at the bottom of the dialog is disabled, which is okay, because main program file doesn't have these sections). But if this disabled radio group is previously set to "Implementation" radio button, it fails.

I'm attaching the patch which ignores radio group selection, and adds unit to uses section of the program (the only one which exists), regardless of what was selected in disabled radio group.
Steps To ReproduceCreate new application in the IDE. When in source editor of Unit1.pas, open UseUnit dialog (Alt+F11 or Main menu->Source->Add Unit to Uses Section).

Choose "Implementation" in radio group at the bottom of the form and click OK.

Now, open main program file (Main menu->Project->View Project Source). Open UseUnit dialog again (now the radio group is disabled, but it has "Implementation" selected).
Choose some unit from the list (you might first need to click on "Show all units" check box and clear the filter to get the units listed).
Click OK and see the error which appears in "Messages" form.
Additional InformationThis patch should be applied in 1.8 before it gets released.
TagsNo tags attached.
Fixed in Revision54620
LazTarget-
Widgetset
Attached Files
  • patch.diff (641 bytes)
    Index: ide/useunitdlg.pas
    ===================================================================
    --- ide/useunitdlg.pas	(revision 54619)
    +++ ide/useunitdlg.pas	(working copy)
    @@ -154,7 +154,7 @@
             begin
               s:=UseUnitDlg.SelectedUnit;
               if s <> '' then begin
    -            if UseUnitDlg.InterfaceSelected then
    +            if UseUnitDlg.InterfaceSelected or (SrcEdit.GetProjectFile = Project1.MainUnitInfo) then
                   CTRes := CodeToolBoss.AddUnitToMainUsesSection(SrcEdit.CodeBuffer, s, '')
                 else
                   CTRes:=CodeToolBoss.AddUnitToImplementationUsesSection(SrcEdit.CodeBuffer, s, '');
    
    patch.diff (641 bytes)

Activities

Zoran Vučenović

2017-04-15 14:55

developer  

patch.diff (641 bytes)
Index: ide/useunitdlg.pas
===================================================================
--- ide/useunitdlg.pas	(revision 54619)
+++ ide/useunitdlg.pas	(working copy)
@@ -154,7 +154,7 @@
         begin
           s:=UseUnitDlg.SelectedUnit;
           if s <> '' then begin
-            if UseUnitDlg.InterfaceSelected then
+            if UseUnitDlg.InterfaceSelected or (SrcEdit.GetProjectFile = Project1.MainUnitInfo) then
               CTRes := CodeToolBoss.AddUnitToMainUsesSection(SrcEdit.CodeBuffer, s, '')
             else
               CTRes:=CodeToolBoss.AddUnitToImplementationUsesSection(SrcEdit.CodeBuffer, s, '');
patch.diff (641 bytes)

Mattias Gaertner

2017-04-15 21:46

manager   ~0099621

Thanks.
I fixed function UseUnitDlg.InterfaceSelected instead.

Zoran Vučenović

2017-04-17 15:25

developer   ~0099643

Thank you, Mattias. Would you please backport to 1.8?

Zoran Vučenović

2017-04-19 11:56

developer   ~0099683

Done, thanks, closing.

Issue History

Date Modified Username Field Change
2017-04-15 14:54 Zoran Vučenović New Issue
2017-04-15 14:55 Zoran Vučenović File Added: patch.diff
2017-04-15 21:46 Mattias Gaertner Fixed in Revision => 54620
2017-04-15 21:46 Mattias Gaertner Note Added: 0099621
2017-04-15 21:46 Mattias Gaertner Status new => resolved
2017-04-15 21:46 Mattias Gaertner Resolution open => fixed
2017-04-15 21:46 Mattias Gaertner Assigned To => Mattias Gaertner
2017-04-17 15:25 Zoran Vučenović Note Added: 0099643
2017-04-19 11:56 Zoran Vučenović Note Added: 0099683
2017-04-19 11:56 Zoran Vučenović Status resolved => closed
2017-04-19 11:56 Zoran Vučenović Fixed in Version => 1.8