Skip to content

Commit

Permalink
Merge pull request #44 from viatra/issues/synchronizer-leak
Browse files Browse the repository at this point in the history
Ensures IncrementalTransformationSynchronizer cleanup on project close
  • Loading branch information
ujhelyiz authored Nov 5, 2019
2 parents faddc1f + 06b8fea commit 0e1fbc0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.incquerylabs.v4md.expressions.BinaryVQLExpression;
import com.incquerylabs.v4md.internal.IProjectChangedListener;
import com.incquerylabs.v4md.transformations.IncrementalTransformationSynchronizer;
import com.nomagic.ci.persistence.IProject;
import com.nomagic.magicdraw.core.Application;
import com.nomagic.magicdraw.core.Project;
Expand All @@ -18,6 +19,7 @@ private final class V4MDProjectListener extends ProjectEventListenerAdapter impl
@Override
public void projectPreClosed(Project project) {
// There is no need to explicitly initialize adapters; the dispose handles uninitialized adapters correctly
IncrementalTransformationSynchronizer.disposeSynchronizer(project);
ViatraQueryAdapter.disposeAdapter(project);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ private ViatraTransformationSynchronizerManager() {
public ModelSynchronizer apply(Project t) {
return (ModelSynchronizer) storage.computeIfAbsent(t, IncrementalTransformationSynchronizer::new);
}

}
public static void disposeSynchronizer(Project p) {
((ViatraTransformationSynchronizerManager)FACTORY).storage.remove(p);
}

private BatchTransformation transformation;
Expand Down

0 comments on commit 0e1fbc0

Please sign in to comment.