Bug 121952

Summary: crash when importing non-C++-files
Product: [Applications] umbrello Reporter: Willi Richert <w.richert>
Component: generalAssignee: Oliver Kellogg <okellogg>
Status: RESOLVED FIXED    
Severity: crash    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:

Description Willi Richert 2006-02-14 12:36:37 UTC
Version:           1.5.1 (using KDE 3.5.1-1.5.fc3.kde, Fedora Core release 3 (Heidelberg))
Compiler:          gcc version 3.4.4 20050721 (Red Hat 3.4.4-2)
OS:                Linux (i686) release 2.6.12-1.1381_FC3

Unfortunately, I've found only the possibility to import C++ classes. If I specify Python files there I get:

Using host libthread_db library "/lib/tls/libthread_db.so.1".
`shared object read from target memory' has disappeared; keeping its symbols.
[Thread debugging using libthread_db enabled]
[New Thread -1208763744 (LWP 9801)]
[KCrash handler]
#6  0x030ee74f in QGListIterator::QGListIterator ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#7  0x0814d10d in UMLClassifier::getTemplateList ()
#8  0x0814de8d in UMLClassifier::findTemplate ()
#9  0x081af108 in Import_Utils::addMethodParameter ()
#10 0x081c45ad in PythonImport::parseStmt ()
#11 0x081a2642 in NativeImportBase::parseFile ()
#12 0x0819d25a in NativeImportBase::importFiles ()
#13 0x081a49cd in UMLApp::slotImportClasses ()
#14 0x081d754e in UMLApp::qt_invoke ()
#15 0x02e3d85e in QObject::activate_signal ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#16 0x02e3df34 in QObject::activate_signal ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#17 0x02857263 in KAction::activated () from /usr/lib/libkdeui.so.4
#18 0x029074be in KAction::slotActivated () from /usr/lib/libkdeui.so.4
#19 0x02978cc4 in KAction::slotPopupActivated () from /usr/lib/libkdeui.so.4
#20 0x02978eb8 in KAction::qt_invoke () from /usr/lib/libkdeui.so.4
#21 0x02e3d85e in QObject::activate_signal ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#22 0x0317224d in QSignal::signal () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#23 0x02e564cd in QSignal::activate () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#24 0x02f41444 in QPopupMenu::mouseReleaseEvent ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#25 0x02851bc7 in KPopupMenu::mouseReleaseEvent () from /usr/lib/libkdeui.so.4
#26 0x02e739ca in QWidget::event () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#27 0x02dde5c9 in QApplication::internalNotify ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#28 0x02dde809 in QApplication::notify ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#29 0x02672252 in KApplication::notify () from /usr/lib/libkdecore.so.4
#30 0x02d7bb8a in QETWidget::translateMouseEvent ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#31 0x02d7a17f in QApplication::x11ProcessEvent ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#32 0x02d8cc96 in QEventLoop::processEvents ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#33 0x02df3c65 in QEventLoop::enterLoop ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#34 0x02df3bbe in QEventLoop::exec () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#35 0x02ddd7cb in QApplication::exec () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#36 0x081dae3e in main ()
Comment 1 Oliver Kellogg 2006-02-14 20:11:58 UTC
Please attach the Python source file for which this happens.
Comment 2 Oliver Kellogg 2006-02-15 06:45:14 UTC
Nevermind; to my surprise I see that this happens on alomst any Python code.
Fix is forthcoming.
Comment 3 Oliver Kellogg 2006-02-16 07:45:04 UTC
SVN commit 510038 by okellogg:

Hot fix for PythonImport crash; there are still plenty of rough spots in the
Python import and it needs more work. Patches and contributions are welcome.
BUG:121952


 M  +2 -2      ChangeLog  
 M  +4 -3      umbrello/nativeimportbase.cpp  
 M  +10 -1     umbrello/pythonimport.cpp  


--- branches/KDE/3.5/kdesdk/umbrello/ChangeLog #510037:510038
@@ -9,9 +9,9 @@
 * Multiplicity labels positioned incorrectly when moving entities (120598)
 * Types of entity's attributes are displayed instead of their names (120742)
 * Unable to delete entity from entity list in "UML Model" frame (120750)
-* Unable to delete entity from entity list in "UML Model" frame (120750)
-* Changing font style has no effect on classes (120761)
+* Interface names not italicized in diagram view (120761)
 * Cannot Resize Sequence Diagram Synchronous Messages (120910)
+* Crash when importing Python files (121952)
 
 Version 1.5.1
 
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/nativeimportbase.cpp #510037:510038
@@ -49,9 +49,10 @@
         else
             break;
     }
-    if (m_srcIndex ==  m_source.count() - 1 &&
-            m_source[m_srcIndex].startsWith(m_singleLineCommentIntro)) {
-        // last item in m_source is a comment
+    if (m_srcIndex >= m_source.count() - 1 ||
+        // if last item in m_source is a comment then it is dropped too
+        (m_srcIndex == m_source.count() - 1 &&
+         m_source[m_srcIndex].startsWith(m_singleLineCommentIntro))) {
         return QString::null;
     }
     return m_source[m_srcIndex];
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/pythonimport.cpp #510037:510038
@@ -53,6 +53,7 @@
             m_comment += text.stripWhiteSpace();
         }
         m_source.append(m_singleLineCommentIntro + m_comment);  // denotes comments in `m_source'
+        m_srcIndex++;
         m_comment = "";
         m_inComment = false;
         pos += 3;  // pos now points behind the closed comment
@@ -78,8 +79,10 @@
             if (endpos > pos + 3)  {
                 QString cmnt = line.mid(pos + 3, endpos - pos - 3);
                 cmnt = cmnt.stripWhiteSpace();
-                if (!cmnt.isEmpty())
+                if (!cmnt.isEmpty()) {
                     m_source.append(m_singleLineCommentIntro + cmnt);
+                    m_srcIndex++;
+                }
             }
             endpos += 3;  // endpos now points behind the closed comment
             QString pre;
@@ -98,6 +101,7 @@
     if (pos != -1) {
         QString cmnt = line.mid(pos);
         m_source.append(cmnt);
+        m_srcIndex++;
         if (pos == 0)
             return true;
         line = line.left(pos);
@@ -217,6 +221,11 @@
         return true;
     }
     if (keyword == "def") {
+        if (m_klass == NULL) {
+            // skip functions outside of a class
+            skipBody();
+            return true;
+        }
         const QString& name = advance();
         // operation
         UMLOperation *op = Import_Utils::makeOperation(m_klass, name);