Skip to content

Commit 95a7111

Browse files
[Cherrypick] DYN-10098: Dynamo Pan/Zoom gives CER crash (#16891) (#16928)
Co-authored-by: Jason <jasonstratton@users.noreply.github.com>
1 parent 84ec5cd commit 95a7111

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/DynamoCore/Graph/Nodes/CodeBlockNode.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,8 @@ private void LoadAndCreateConnectors(OrderedDictionary inportConnections, Ordere
11551155
i);
11561156
//during an undo operation we should set the new input connector
11571157
//to have the same id as the old connector.
1158-
if (context == SaveContext.Undo)
1158+
// Null check: Make() returns null if port indices are no longer valid
1159+
if (context == SaveContext.Undo && connector != null)
11591160
{
11601161
connector.GUID = oldConnector.GUID;
11611162
}
@@ -1209,7 +1210,8 @@ private void LoadAndCreateConnectors(OrderedDictionary inportConnections, Ordere
12091210

12101211
// During an undo operation we should set the new output connector
12111212
// to have the same id as the old connector.
1212-
if (context == SaveContext.Undo)
1213+
// Null check: Make() returns null if port indices are no longer valid
1214+
if (context == SaveContext.Undo && connector != null)
12131215
{
12141216
connector.GUID = oldConnector.GUID;
12151217
}

src/DynamoCoreWpf/Views/Core/WorkspaceView.xaml.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,6 @@ private void ClearNodeViewCache()
723723
private void UpdateNodeViewCacheScale()
724724
{
725725
var nodes = this.ChildrenOfType<NodeView>();
726-
BitmapCache sharedCache = null;
727726
foreach (var node in nodes)
728727
{
729728
if (node.CacheMode is BitmapCache cache)
@@ -732,11 +731,10 @@ private void UpdateNodeViewCacheScale()
732731
}
733732
else
734733
{
735-
if (sharedCache == null)
736-
{
737-
sharedCache = new BitmapCache(currentRenderScale);
738-
}
739-
node.CacheMode = sharedCache;
734+
// Create a unique BitmapCache for each node to ensure thread-safety and reentrancy.
735+
// Sharing a single cache instance across multiple nodes causes race conditions in WPF's
736+
// rendering thread, leading to pure virtual function calls during concurrent access.
737+
node.CacheMode = new BitmapCache(currentRenderScale);
740738
}
741739
}
742740
}

0 commit comments

Comments
 (0)