Bug 119125 - Preprocessor keywords ignored which causes endless loop in code import
Summary: Preprocessor keywords ignored which causes endless loop in code import
Status: RESOLVED FIXED
Alias: None
Product: umbrello
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: OpenSUSE Linux
: NOR crash with 20 votes (vote)
Target Milestone: ---
Assignee: Umbrello Development Group
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-28 17:55 UTC by William Cleveland
Modified: 2007-05-27 07:54 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
patch for #119125 (1.00 KB, patch)
2007-05-26 23:49 UTC, Antoine Dopffer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description William Cleveland 2005-12-28 17:55:09 UTC
Version:            (using KDE KDE 3.5.0)
Installed from:    SuSE RPMs
OS:                Linux

Importing C++ header files that have circular references (using #include) causes the code import to enter a infinite loop and causes the whole KDE to hang.

Problem stems from preprocessor commands being ignored.

One can argue the following example is bad coding form, but gcc, cc, and msvc have no problems with the files.

( This situation presented itself when we decided to place the child classes in seperate header files and still only require the base.h file to be included in the original source code )

Example problem headers:

base.h contains:

#ifndef __BASE__
#define __BASE__
class Base
{
...
}

// children includes
#include "child.h"
#include "child2.h"

#endif



child.h contains:

#ifndef __CHILD__
#define __CHILD__

#include "base.h"

class Child : public Base
{
...
}
#endif


child2.h contains:

#ifndef __CHILD2__
#define __CHILD2__

#include "base.h"

class Child2 : public Base
{
...
}
#endif
Comment 1 David Wilson 2007-03-27 07:44:25 UTC
I too have similar problems. When I import a class that has an #include it includes all files connected with them. When it includes some of the standard libraries the program crashes. Some one on the #umbrello chat channel said it wasn't supposed to import. 
Comment 2 Antoine Dopffer 2007-05-26 23:49:42 UTC
Created attachment 20700 [details]
patch for #119125

The old code tried not to parse a file if the file was already parsed but this
detection was done too late (after the parsing of the dependences).
Modified function-> CppImport::feedTheModel
Comment 3 Oliver Kellogg 2007-05-27 07:54:49 UTC
SVN commit 668653 by okellogg:

Apply attchment 20700 from Antoine Dopffer
> The old code tried not to parse a file if the file was already parsed but this 
> detection was done too late (after the parsing of the dependences). 
> Modified function-> CppImport::feedTheModel

Thanks for the fix Antoine.
BUG:119125


 M  +1 -0      ChangeLog  
 M  +3 -3      umbrello/codeimport/cppimport.cpp  


--- branches/KDE/3.5/kdesdk/umbrello/ChangeLog #668652:668653
@@ -1,6 +1,7 @@
 Version 1.5.71
 
 * Bugs/wishes from http://bugs.kde.org:
+* Preprocessor keywords ignored which causes endless loop in code import (119125)
 * Unstable saves and loads, class names become dirty (145709)
 * Crash on deleting class in list view (145762)
 * Class attribute documentation not generated for python (145916)
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codeimport/cppimport.cpp #668652:668653
@@ -51,6 +51,9 @@
 CppImport::~CppImport() {}
 
 void CppImport::feedTheModel(const QString& fileName) {
+    if (ms_seenFiles.find(fileName) != ms_seenFiles.end())
+        return;
+    ms_seenFiles.append(fileName);
     QMap<QString, Dependence> deps = ms_driver->dependences(fileName);
     if (! deps.empty()) {
         QMap<QString, Dependence>::Iterator it;
@@ -68,9 +71,6 @@
                 feedTheModel(includeFile);
         }
     }
-    if (ms_seenFiles.find(fileName) != ms_seenFiles.end())
-        return;
-    ms_seenFiles.append(fileName);
     TranslationUnitAST *ast = ms_driver->translationUnit( fileName );
     if (ast == NULL) {
         kError() << "CppImport::feedTheModel: " << fileName << " not found" << endl;