Skip to content

Commit

Permalink
Mark the dependent models dirty and only update them when needed (Ope…
Browse files Browse the repository at this point in the history
…nModelica#12610)

OpenModelica#11926

Avoids calling `getModelInstance` on dependent models. Instead mark them and update when they become active.
This is just a workaround. No performance enhancement is done. We just defer the update operation.
  • Loading branch information
adeas31 committed Jun 18, 2024
1 parent 65c8813 commit 6c0894d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion OMEdit/OMEditLIB/Modeling/ModelWidgetContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8141,7 +8141,7 @@ void ModelWidget::processPendingModelUpdate()
void ModelWidget::updateModelIfDependsOn(const QString &modelName)
{
if (mDiagramViewLoaded && dependsOnModel(modelName)) {
reDrawModelWidget(createModelInfo());
setRequiresUpdate(true);
}
}

Expand Down Expand Up @@ -10141,6 +10141,11 @@ void ModelWidgetContainer::currentModelWidgetChanged(QMdiSubWindow *pSubWindow)
return;
}
mpLastActiveSubWindow = pSubWindow;
// update the model if its require update flag is set.
if (pModelWidget && pModelWidget->requiresUpdate()) {
pModelWidget->setRequiresUpdate(false);
pModelWidget->reDrawModelWidget(pModelWidget->createModelInfo());
}
/* ticket:4983 Update the documentation browser when a new ModelWidget is selected.
* Provided that the Documentation Browser is already visible.
*/
Expand Down
3 changes: 3 additions & 0 deletions OMEdit/OMEditLIB/Modeling/ModelWidgetContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,8 @@ class ModelWidget : public QWidget
void clearDependsOnModels() {mDependsOnModelsList.clear();}
void setHandleCollidingConnectionsNeeded(bool needed) {mHandleCollidingConnectionsNeeded = needed;}
bool isHandleCollidingConnectionsNeeded() {return mHandleCollidingConnectionsNeeded;}
void setRequiresUpdate(bool requiresUpdate) {mRequiresUpdate = requiresUpdate;}
bool requiresUpdate() {return mRequiresUpdate;}

void fetchExtendsModifiers(QString extendsClass);
void reDrawModelWidgetInheritedClasses();
Expand Down Expand Up @@ -678,6 +680,7 @@ class ModelWidget : public QWidget
QStringList mDependsOnModelsList;
bool mHasMissingType = false;
bool mHandleCollidingConnectionsNeeded = false;
bool mRequiresUpdate = false;

void createUndoStack();
void handleCanUndoRedoChanged();
Expand Down

0 comments on commit 6c0894d

Please sign in to comment.