Skip to content
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

webadmin: Fix reseting of graphics #328

Merged
merged 1 commit into from
May 19, 2022

Conversation

ljelinkova
Copy link
Contributor

When the BIOS type changed, the graphics list was always reset even though the video type stayed the same.

This was because the setting of the items and selected item was separated in https://gerrit.ovirt.org/c/ovirt-engine/+/118132

This patch goes back to setting the items and selected item at once but making sure that the selection model is not
used to avoid issues fixed by https://gerrit.ovirt.org/c/ovirt-engine/+/118132

Bug-Url: https://bugzilla.redhat.com/2078193

@ljelinkova ljelinkova added the virt label May 4, 2022
@ljelinkova ljelinkova requested a review from ahadas May 4, 2022 11:29
@ljelinkova ljelinkova requested a review from sgratch as a code owner May 4, 2022 11:29
@ljelinkova
Copy link
Contributor Author

/ost

@ahadas ahadas requested a review from rszwajko May 8, 2022 15:34
@smelamud smelamud self-requested a review May 8, 2022 22:00
@rszwajko
Copy link
Member

rszwajko commented May 9, 2022

Looking at https://gerrit.ovirt.org/c/ovirt-engine/+/118132 it seems that the main problem was that:

ListModel:setItems(Collection value, T selectedItem) [...] uses OvirtSelectionModel, but is not synchronized with method setSelectedItem()

However looking at ListModel constructor (link below) this should work - the handler should synchronize value from OvirtSelectionModel to ListModel.

Regarding the new flag useSelectionModel - it explicitly de-synchronizes between OvirtSelectionModel and ListModel which breaks the contract. Perhaps we should use/create a different model instead?

this.selectionModel.addSelectionChangeHandler(e -> synchronizeSelection());

@ljelinkova
Copy link
Contributor Author

Yes, the value is synchronized from the selection model to the selected item(s) but the problem is the other way around - when you set item(s) using setSelectedItem(s)(), it is not propagated to the selection mode. And if you mix those two together (setSelectedItem() with setItems(items, selectedItem)), the selected item is overridden by selection model.

This could be fixed but given that this is the key model used across the whole webadmin, it could break many other dialogs.

@rszwajko
Copy link
Member

rszwajko commented May 9, 2022

@ljelinkova

if you mix those two together (setSelectedItem() with setItems(items, selectedItem)), the selected item is overridden by selection model.

This could be fixed but given that this is the key model used across the whole webadmin, it could break many other dialogs.

OK. Fixing this problem is risky indeed. I would rather leave the responsibility for correct handling such cases close to the usage: either the code uses selection model or not. If it does use it then it should make sure that setSelectedItem() is not called. Otherwise the selection model should be disabled to avoid synchronization issues.

In case of displayType, it seems that we are not using selection model functionality so lets disable it entirely in that one place i.e. by creating and using a constructor

public ListModel(boolean useSelectionModel) {
   // ...
  if (useSelectionModel) {
      this.selectionModel = new OvirtSelectionModel<>(isSingleSelectionOnly());
      // ...
  } else {
      this.selectionModel = new DummySelectionModel();
  }

What do you think?

@ljelinkova
Copy link
Contributor Author

I like the idea to explicitly mark "do not use the selection model" in the constructor. I'll update the PR.

@rszwajko
Copy link
Member

GWT library code seems to perform null-checks before accessing selection models but this is not consistent.
However GWT uses also another way - NoSelectionModel that could be more useful in our case. This mode was missing in our higher order model. Please check PR #357 for details.

When the BIOS type changed, the graphics list was always
reset even though the video type stayed the same.

This was because the setting of the items and selected item
was separated in https://gerrit.ovirt.org/c/ovirt-engine/+/118132

This patch introduces a new constructor ListModel that allows
to configure the selection model. That allows to set the video type
field with NO_SELECTION model and avoid the synchronization that
caused problems mentioned in https://gerrit.ovirt.org/c/ovirt-engine/+/118132.

Bug-Url: https://bugzilla.redhat.com/2078193
Copy link
Member

@ahadas ahadas left a comment

Choose a reason for hiding this comment

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

minor comment, other than that - lgtm

@ahadas ahadas merged commit 2e6b59f into oVirt:master May 19, 2022
@ljelinkova ljelinkova deleted the fix-graphics-reset branch June 15, 2022 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants