Skip to content

Commit

Permalink
Avoid the NULL pointer exception.
Browse files Browse the repository at this point in the history
  • Loading branch information
adeas31 committed Jun 13, 2018
1 parent 7e3111a commit e076b38
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion OMEdit/OMEditGUI/Modeling/ModelWidgetContainer.cpp
Expand Up @@ -3667,7 +3667,7 @@ bool ModelWidget::modelicaEditorTextChanged(LibraryTreeItem **pLibraryTreeItem)
OMCProxy *pOMCProxy = MainWindow::instance()->getOMCProxy();
QString modelicaText = pModelicaEditor->getPlainText();
QString stringToLoad;
LibraryTreeItem *pParentLibraryTreeItem = MainWindow::instance()->getLibraryWidget()->getLibraryTreeModel()->getContainingFileParentLibraryTreeItem(mpLibraryTreeItem);
LibraryTreeItem *pParentLibraryTreeItem = pLibraryTreeModel->getContainingFileParentLibraryTreeItem(mpLibraryTreeItem);
removeDynamicResults(); // show static values during editing
if (pParentLibraryTreeItem != mpLibraryTreeItem) {
stringToLoad = mpLibraryTreeItem->getClassTextBefore() + modelicaText + mpLibraryTreeItem->getClassTextAfter();
Expand All @@ -3679,6 +3679,9 @@ bool ModelWidget::modelicaEditorTextChanged(LibraryTreeItem **pLibraryTreeItem)
* then update the package contents with new invalid code because we open P when user clicks on the error message.
*/
if (mpLibraryTreeItem->isInPackageOneFile()) {
if (!pParentLibraryTreeItem->getModelWidget()) {
pLibraryTreeModel->showModelWidget(pParentLibraryTreeItem, false);
}
pParentLibraryTreeItem->getModelWidget()->createModelWidgetComponents();
ModelicaEditor *pModelicaEditor = dynamic_cast<ModelicaEditor*>(pParentLibraryTreeItem->getModelWidget()->getEditor());
if (pModelicaEditor) {
Expand Down

0 comments on commit e076b38

Please sign in to comment.