Bug 73420

Summary: One can add the same file twice in QMake Manager
Product: [Applications] kdevelop Reporter: Stefan Zickler <szickler>
Component: Build tools: QMakeAssignee: KDevelop Developers <kdevelop-devel>
Status: RESOLVED FIXED    
Severity: normal CC: jeroen.dierckx
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In:

Description Stefan Zickler 2004-01-24 18:15:46 UTC
Version:           3.0 RC 1 (using KDE KDE 3.1.5)
Installed from:    Gentoo Packages
Compiler:          gcc 3.3.2-r5 
OS:          Linux

Ok,  this is actually two bugs:
1) One can add the exact same file multiple times in the qmake manager, which will (of course) result in compilation errors. I am not sure if this is behavior is desired, at least I can't think of any scenario where you wanted the same file twice in your soruces.

This bug is really annoying when I am copying a bunch of external source into my project and simply add all of it to the qmake manager which will sometimes result in files being added twice.

2) Worse, when one tries to remove one of those doubles from the qmake-manager, it will remove the one desired instance of the icons. However, internally it seems to remove BOTH instances from the makefiles, which means it won't compile anymore either, due to undefined references etc.


To make it more clear, here Directions To reproduce:

1)
Start kdevelop and create a new C++ -> QMake project -> Application.
Now in the QMake manager (for subproject 'src'), there should already be a 'main.cpp' under sources.
Click the button to 'Add existing files' and select that exact same file 'main.cpp'. It will be added another time, so now there are two main.cpp's in the qmake manager.
Trying to compile will naturally give a compiler error due to multiple declarations.

2)
Assuming you did the above.
Select one of those 'main.cpp' and select 'Remove File'.
Now that one selected icon will disappear as expected, leaving only one main.cpp in the qmake manager.
However, trying to compile will give a compiler error due to "undefined reference to 'main'" which means that even though main.cpp is listed once in the qmake manager it has been completely removed from the makefiles.

3) workaround:
remove all main.cpp's from the qmake manager and add it again once. Now it will all compile just fine.
Comment 1 Tim Hawkins 2004-03-31 04:57:44 UTC
I can confirm this problem, it does this with the "add new class" wizard, ie you can specify the same class name twice and end up with the same file in the project twice, however only if the class originly generated by the wizard
 is unedited. 
Comment 2 Alexander Dymo 2004-07-17 22:34:47 UTC
CVS commit by dymo: 

Do not allow to add the same file twice.
CCMAIL: 73420-done@bugs.kde.org


  M +2 -1      trollprojectpart.cpp   1.76


--- kdevelop/buildtools/qmake/trollprojectpart.cpp  #1.75:1.76
@@ -383,4 +383,5 @@ void TrollProjectPart::addFiles ( const 
     for (QStringList::iterator it = files.begin(); it != files.end(); ++it)
 //        if (!(*it).contains(projectDirectory()))
+        if (!isProjectFile(projectDirectory() + "/" + (*it)))
         *it = projectDirectory() + "/" + (*it);
 


Comment 3 Amilcar do Carmo Lucas 2004-07-19 23:25:04 UTC
*** Bug 83774 has been marked as a duplicate of this bug. ***