Skip to content

Conversation

@SiboVG
Copy link
Member

@SiboVG SiboVG commented Jan 21, 2025

This PR fixes #2679. The issue was in the Rocket notifyAllListeners code:

private void notifyAllListeners(final ComponentChangeEvent cce) {
		// Copy the list before iterating to prevent concurrent modification exceptions.
		EventListener[] list = listenerList.toArray(new EventListener[0]);
		for (EventListener l : list) {
            { // vvvv DEVEL vvvv
                //System.err.println("notifying listener.  (type= "+l.getClass().getSimpleName()+")");
                //System.err.println("                     (type= "+l.getClass().getName()+")");
            } // ^^^^ DEVEL ^^^^

			if (l instanceof ComponentChangeListener) {
				((ComponentChangeListener) l).componentChanged(cce);
			}
			else if (l instanceof StateChangeListener) {
				((StateChangeListener) l).stateChanged(cce);
			}
		}
	}

The OpenRocketDocument is both a ComponentChangeListener and StateChangeListener, so when it arrives at the first if, only the componentChanged method is called, not the stateChanged method. This PR replaces that else if with a normal if.


I couldn't track down why this bug suddenly appeared, but IMO the above change is a logical one.

Because it causes listeners, e.g. the OpenRocketDocument, which is both a ComponentChangeListener and StateChangeListener, to only call componentChanged
@SiboVG SiboVG merged commit db93e79 into openrocket:unstable Jan 29, 2025
1 check passed
@SiboVG SiboVG deleted the issue-2679 branch January 29, 2025 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OR apparently no longer tracking when files have changed

1 participant