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

[Fixed] trying to remove listener where given id is undefined #9547

Merged
merged 16 commits into from Sep 11, 2019

Conversation

mever
Copy link
Contributor

@mever mever commented Jul 18, 2018

This PR fixes an exception where given argument to removeListenerById is undefined. I got this when trying to destroy a widget. With this fix all seems to work now.

@johnspackman
Copy link
Member

I'd like to know more about exactly what the cause or your original issue was - when I've come across this myself, it's always as a side effect of another problem (often to do with lists and controllers), and triggered by recursive binding (eg part way through binding a widget, an event causes the model or selection of the original widget to change, causing the binding to be redone part way through).

IMHO there are definitely opportunities to improve error detection in bindings because when it goes wrong it is hard to track down what on earth is really going on, but this also makes me cautious about applying fixes which may be only masking the "real" problem.

@mever
Copy link
Contributor Author

mever commented Jul 20, 2018

You are totally right. I am debugging now.

@mever
Copy link
Contributor Author

mever commented Jul 20, 2018

On line 257 of SingleValueBinding.js there is a similar check. When do the lengths of sources and listenerIds differ? When can I expect this to happen?

@johnspackman
Copy link
Member

johnspackman commented Jul 20, 2018

Do you mean here ?

That looks like a redundant check, otherwise it would be a symptom of a resource leak (ie an un-freed listener) because it is not possible to release a listenerId without the object to release it from.

ie this code might be "more correct" (not that I'm suggesting that you make this change, but just to illustrate):

        for (var i = 0; i < sources.length; i++) {
          // check if a source is available
          if (listenerIds[i]) {
            if (qx.core.Environment.get("qx.debug")) {
              if (!sources[i]) {
                throw new Error("Lost source and cannot remove listener");
              }
            }
            sources[i].removeListenerById(listenerIds[i]);
          }
        }

@mever
Copy link
Contributor Author

mever commented Jul 20, 2018

Yes. Debugging the SingleValueBinding class is a real pain I must admit. My time is very limited so with some luck I can dig into it on Sunday when I continue.

@hkollmann
Copy link
Member

@mever: Did you have found some time to continue this issue?

@@ -1185,14 +1185,14 @@ qx.Class.define("qx.data.SingleValueBinding",
// go threw all added listeners (source)
for (var i = 0; i < id.sources.length; i++) {
// check if a source is available
if (id.sources[i]) {
if (id.sources[i] && id.listenerIds[i]) {
Copy link
Member

Choose a reason for hiding this comment

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

@mever it would maybe help to add a this.error in the situation where somehow sources gets "out of sync" from listenerIds. we hesitate to merge this as the situation could be caused by a bug somewhere else which is then silenced by this pr. A this.error would help here as it offers a stack trace.

cajus added a commit that referenced this pull request Dec 18, 2018
Fixed removing listeners from binding chain with incomplete binding (see #9547)
@cboulanger cboulanger added waiting for feedback enhancement New features, give me a PR!!! labels Jun 14, 2019
@cboulanger
Copy link
Contributor

@mever could you update the PR as per @level420's suggestion? Thank you.

@level420
Copy link
Member

merging. thank you @mever for the initial PR which was hijacked by me ;-)

@level420 level420 merged commit aee1cc4 into qooxdoo:master Sep 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New features, give me a PR!!! waiting for feedback
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants