-
Notifications
You must be signed in to change notification settings - Fork 22
fix: Error after importing a reticular similar to an existing one and… #858
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
4944df0
ff1956c
f92dacf
8a7bc53
4eeb8f9
19f4ad1
fe493a1
f30d64d
246d36b
3675e1a
db68d9b
de06a85
a80b18c
cf32023
3c48c1a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,10 @@ export class DataService implements OnDestroy { | |
|
|
||
| private destroyed = new Subject<void>(); | ||
|
|
||
| // Counter to force D3 data rebinding when loading new DTO (not for undo/redo) | ||
| // Fixes issue #851: prevents stale object references in D3 callbacks | ||
| private netzgrafikLoadCounter = 0; | ||
|
|
||
| private readonly netzgrafikLoadedInfoSubject = new BehaviorSubject<NetzgrafikLoadedInfo>( | ||
| new NetzgrafikLoadedInfo(true, false), | ||
| ); | ||
|
|
@@ -72,7 +76,12 @@ export class DataService implements OnDestroy { | |
| this.destroyed.complete(); | ||
| } | ||
|
|
||
| getNetzgrafikLoadCounter(): number { | ||
| return this.netzgrafikLoadCounter; | ||
| } | ||
|
|
||
| loadNetzgrafikDto(netzgrafikDto: NetzgrafikDto, preview = false) { | ||
| this.netzgrafikLoadCounter++; | ||
| this.netzgrafikLoadedInfoSubject.next(new NetzgrafikLoadedInfo(true, preview)); | ||
|
|
||
| DataMigration.migrateNetzgrafikDto(netzgrafikDto); | ||
|
|
@@ -151,13 +160,7 @@ export class DataService implements OnDestroy { | |
| this.trainrunSectionService.initializeTrainrunSectionRouting(); | ||
| this.nodeService.validateAllConnections(); | ||
| this.trainrunService.propagateInitialConsecutiveTimes(); | ||
| this.nodeService.nodesUpdated(); | ||
| this.nodeService.transitionsUpdated(); | ||
| this.nodeService.connectionsUpdated(); | ||
| this.trainrunSectionService.trainrunSectionsUpdated(); | ||
| this.noteService.notesUpdated(); | ||
| this.labelService.labelUpdated(); | ||
| this.labelGroupService.labelGroupUpdated(); | ||
| this.triggerViewUpdate(); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It found by hazard this duplicated code. While testing to "clear" all object during load which could overcome the problem. But this leads to more complicated things to do. This was the reason i stop changed the loading stuff. I think we have just to ensure when then callbacks gets correctly handled. Once we face a comparison by object in the code where we compare "rendering system stored / cached objects" with ...Service stored we should focus on id based comparision not on objects. Thus we haven't to change the loading stuff. This problem was located at wrong comparision logic. |
||
|
|
||
| this.netzgrafikColoringService.generateGlobalStyles( | ||
| this.getTrainrunCategories(), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -663,7 +663,7 @@ export class NodesView { | |
| if (dragTransitionInfo !== null) { | ||
| this.reconnectTransition(dragTransitionInfo, endNode); | ||
| } else { | ||
| const startNode: Node = this.editorView.trainrunSectionPreviewLineView.getStartNode(); | ||
| const startNode = this.editorView.trainrunSectionPreviewLineView.getStartNode(); | ||
| this.createNewTrainrunSection(startNode, endNode); | ||
| } | ||
| } | ||
|
|
@@ -729,19 +729,19 @@ export class NodesView { | |
| this.editorView.trainrunSectionPreviewLineView.getExistingTrainrunSection(); | ||
| } | ||
| this.editorView.trainrunSectionPreviewLineView.stopPreviewLine(); | ||
| if (startNode === endNode) { | ||
| if (!startNode || !endNode || startNode?.getId() === endNode?.getId()) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change ensures that even in the worst-case scenario—if the rendering object based on the load counter malfunctions—this check would still be handled correctly. The old check should still be compared to the new, correct one. However, the issue of outdated objects in the rendering (SVG) is resolved by the counter. Therefore, I recommend not reverting this change. |
||
| return; | ||
| } | ||
| if (existingTrainrunSection !== null) { | ||
| if ( | ||
| existingTrainrunSection.getSourceNode() === startNode && | ||
| existingTrainrunSection.getTargetNode() === endNode | ||
| existingTrainrunSection.getSourceNodeId() === startNode.getId() && | ||
| existingTrainrunSection.getTargetNodeId() === endNode.getId() | ||
| ) { | ||
| return; | ||
| } | ||
| if ( | ||
| existingTrainrunSection.getSourceNode() === endNode && | ||
| existingTrainrunSection.getTargetNode() === startNode | ||
| existingTrainrunSection.getSourceNodeId() === endNode.getId() && | ||
| existingTrainrunSection.getTargetNodeId() === startNode.getId() | ||
| ) { | ||
| return; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This load counter is the most important new "thing" I have introduced. The load counter ensures that during runtime each loadNetzgrafikDto will get a new LC and thus the rendering gets updated through ...ViewObjects.key --> change