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
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.
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
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;