Commit 2f52cf17 authored by Ralf Habacker's avatar Ralf Habacker

Fix crash importing python file with more than 32 classes.

BUG:328064
FIXED-IN:4.11.4
(cherry picked from commit 098d0b47)
parent 185332fa
......@@ -257,7 +257,8 @@ bool AdaImport::parseStmt()
umldoc->addAssociation(assoc);
skipStmt();
} else {
m_scope[++m_scopeIndex] = static_cast<UMLPackage*>(ns);
m_scope.append(static_cast<UMLPackage*>(ns));
m_scopeIndex = m_scope.size() - 1;
}
} else if (m_source[m_srcIndex] == "renames") {
m_renaming[name] = advance();
......@@ -441,7 +442,8 @@ bool AdaImport::parseStmt()
uError() << "end: expecting " << scopeName << ", found "
<< m_source[m_srcIndex];
}
m_scopeIndex--;
m_scope.takeLast();
m_scopeIndex = m_scope.size() - 1;
m_currentAccess = Uml::Visibility::Public; // @todo make a stack for this
} else {
uError() << "importAda: too many \"end\"";
......
......@@ -413,7 +413,7 @@ bool NativeImportBase::parseFile(const QString& filename)
m_klass = NULL;
m_currentAccess = Uml::Visibility::Public;
m_scopeIndex = 0;
m_scope[0] = NULL; // index 0 is reserved for global scope
m_scope.append(NULL); // index 0 is reserved for global scope
const int srcLength = m_source.count();
for (m_srcIndex = 0; m_srcIndex < srcLength; ++m_srcIndex) {
const QString& firstToken = m_source[m_srcIndex];
......
......@@ -88,7 +88,7 @@ protected:
QString m_singleLineCommentIntro; ///< start token of a single line comment
QStringList m_source; ///< the scanned lexemes
int m_srcIndex; ///< used for indexing m_source
UMLPackage *m_scope[32]; ///< stack of scopes for use by the specific importer
QList<UMLPackage *> m_scope; ///< stack of scopes for use by the specific importer
uint m_scopeIndex; ///< indexes m_scope, index 0 is reserved for global scope
UMLClassifier *m_klass; ///< class currently being processed
Uml::Visibility::Enum m_currentAccess; ///< current access (public/protected/private)
......
......@@ -211,7 +211,8 @@ bool PythonImport::parseStmt()
const QString& name = advance();
UMLObject *ns = Import_Utils::createUMLObject(UMLObject::ot_Class, name,
m_scope[m_scopeIndex], m_comment);
m_scope[++m_scopeIndex] = m_klass = static_cast<UMLClassifier*>(ns);
m_scope.append(m_klass = static_cast<UMLClassifier*>(ns));
m_scopeIndex = m_scope.size() - 1;
m_comment.clear();
if (advance() == "(") {
while (m_srcIndex < srcLength - 1 && advance() != ")") {
......@@ -256,8 +257,10 @@ bool PythonImport::parseStmt()
return true;
}
if (keyword == "}") {
if (m_scopeIndex)
m_klass = dynamic_cast<UMLClassifier*>(m_scope[--m_scopeIndex]);
if (m_scopeIndex) {
m_klass = dynamic_cast<UMLClassifier*>(m_scope.takeLast());
m_scopeIndex = m_scope.size() - 1;
}
else
uError() << "parsing: too many }";
return true;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment