Skip to content

Commit

Permalink
Fixes #3793
Browse files Browse the repository at this point in the history
Call loadString with the new text of the class before creating the LibraryTreeItem.
  • Loading branch information
adeas31 committed Mar 24, 2016
1 parent e0629d9 commit 8d5d64f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions OMEdit/OMEditGUI/Modeling/ModelicaClassDialog.cpp
Expand Up @@ -806,6 +806,15 @@ void DuplicateClassDialog::duplicateClass()
}
// if everything is fine then duplicate the class.
if (mpMainWindow->getOMCProxy()->copyClass(mpLibraryTreeItem->getNameStructure(), mpNameTextBox->text(), mpPathTextBox->text())) {
/* Ticket #3793
* We need to call loadString with the new text of the class before creating the LibraryTreeItem
* So that the getClassInformation returns the correct line number information.
* Otherwise we have the problems like the one reported in Ticket #3793.
*/
QString fileName = mpPathTextBox->text().isEmpty() ? mpNameTextBox->text() : mpPathTextBox->text() + "." + mpNameTextBox->text();
QString classText = QString("within %1;%2").arg(mpPathTextBox->text()).arg(mpMainWindow->getOMCProxy()->listFile(fileName));
mpMainWindow->getOMCProxy()->loadString(classText, fileName, Helper::utf8, false, false);
// create the new LibraryTreeItem
LibraryTreeItem *pLibraryTreeItem;
pLibraryTreeItem = pLibraryTreeModel->createLibraryTreeItem(mpNameTextBox->text().trimmed(), pParentLibraryTreeItem, false, false, true);
pLibraryTreeItem->setSaveContentsType(mpLibraryTreeItem->getSaveContentsType());
Expand Down

0 comments on commit 8d5d64f

Please sign in to comment.