Skip to content

Commit

Permalink
Do not load the class as system library after conversion (#8733)
Browse files Browse the repository at this point in the history
Fixes #8731
  • Loading branch information
adeas31 committed Mar 21, 2022
1 parent e704eb8 commit 6b61a26
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions OMEdit/OMEditLIB/Modeling/ModelicaClassDialog.cpp
Expand Up @@ -1489,6 +1489,7 @@ void ConvertClassUsesAnnotationDialog::convert()
mpProgressLabel->show();
mpOkButton->setEnabled(false);
repaint(); // repaint the dialog so progresslabel is updated.
const QString nameStructure = mpLibraryTreeItem->getNameStructure();
bool reloadClass = false;
bool updatePackageIndex = false;
QTreeWidgetItemIterator usesLibrariesIterator(mpUsesLibrariesTreeWidget);
Expand All @@ -1505,7 +1506,7 @@ void ConvertClassUsesAnnotationDialog::convert()
updatePackageIndex |= true;
}
}
if (MainWindow::instance()->getOMCProxy()->convertPackageToLibrary(mpLibraryTreeItem->getNameStructure(), libraryName, libraryVersion)) {
if (MainWindow::instance()->getOMCProxy()->convertPackageToLibrary(nameStructure, libraryName, libraryVersion)) {
LibraryTreeItem *pLibraryTreeItem = MainWindow::instance()->getLibraryWidget()->getLibraryTreeModel()->findLibraryTreeItemOneLevel(libraryName);
if (pLibraryTreeItem) {
MainWindow::instance()->getLibraryWidget()->getLibraryTreeModel()->unloadClass(pLibraryTreeItem, false, false);
Expand All @@ -1514,14 +1515,18 @@ void ConvertClassUsesAnnotationDialog::convert()
}
++usesLibrariesIterator;
}
// if reloadClass is set then unload the class and it will be reloaded as part of loadDependentLibraries
LibraryTreeModel *pLibraryTreeModel = MainWindow::instance()->getLibraryWidget()->getLibraryTreeModel();
// if reloadClass is set then unload the class and create a LibraryTreeItem for it again.
if (reloadClass) {
if (mpLibraryTreeItem->isFilePathValid()) {
saveLibraryTreeItem(mpLibraryTreeItem);
}
MainWindow::instance()->getLibraryWidget()->getLibraryTreeModel()->unloadClass(mpLibraryTreeItem, false, false);
pLibraryTreeModel->createLibraryTreeItem(nameStructure, pLibraryTreeModel->getRootLibraryTreeItem(), true, false, true);
pLibraryTreeModel->checkIfAnyNonExistingClassLoaded();
}
MainWindow::instance()->getLibraryWidget()->getLibraryTreeModel()->loadDependentLibraries(MainWindow::instance()->getOMCProxy()->getClassNames());
// load any dependent libraries
pLibraryTreeModel->loadDependentLibraries(MainWindow::instance()->getOMCProxy()->getClassNames());
// update the package index if needed
if (updatePackageIndex) {
MainWindow::instance()->getOMCProxy()->updatePackageIndex();
Expand Down

0 comments on commit 6b61a26

Please sign in to comment.