Skip to content

CSSTUDIO-3164 Bugfix: reset 'pv_value' when the PV name changes. #3406

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

Merged
merged 1 commit into from
May 21, 2025

Conversation

abrahamwolk
Copy link
Collaborator

@abrahamwolk abrahamwolk commented May 21, 2025

This pull request fixes a bug that can be reproduced in the following way:

  1. Create a TextUpdate widget and connect it to a PV PV1.
  2. At runtime of the OPI:
    2.a. Change the TextUpdate widget's PV to a non-existent PV PV2, causing the TextUpdate widget to display <PV2> and a disconnected status.
    2.b. Change the TextUpdate widget's PV back to the original PV PV1. Instead of displaying the value of the original PV, the TextUpdate widget now disiplays <PV2>. (But it no longer displays the disconnected status.)

The reason for this behavior is an optimization in the class PropertyChangeHandler, which doesn't notify listeners if the value of a property remains unchanged:

// Any change at all?
if (new_value != null && old_value != null && !forceNotify && new_value.equals(old_value))
return;

When the PV name was changed in step 2.a above, the property pv_value in the class PVWidget remained unchanged, since PV2 didn't exist. In step 2.b, when the PV name was changed back to PV1, the optimization in PropertyChangeHandler prevented the notification of the TextUpdate widget, and the displayed text was not updated from <PV2> to the value of PV1.

This pull request adds a WidgetPropertyListener to the property pv_name that resets the property pv_value to null whenever pv_name is updated.

Copy link
Collaborator

@kasemir kasemir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

@abrahamwolk abrahamwolk merged commit e204d50 into master May 21, 2025
3 checks passed
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.

3 participants