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
show proxy object icons more reliably #2179
Conversation
Redid, rebased, and force-pushed to make Travis happy. |
It is.
It seems to make all currently visible
I think it's because the "icon change notification" thingy is made at the wrong level — IIRC most views in prefs are Tables, and those tables use Well, it doesn't (or at least it does the trick for a completely unrelated fix Cell change (because I'll hard reset in 3, 2, 1...)
|
Actually, it's all of them. Not just the ones that are visible. But that's 3 at most.
That's what I was thinking. There aren't that many of these notifications being fired at any given time. And I didn't forget that the results are included in that. (I had actually set a "Log Message" break point to show me the count when the notification was received.)
I know what that code is supposed to do (I wrote it), but it doesn't seem to be working reliably. For what seems like a year, I've only gotten icons for the first 4 or so results. After making this change yesterday, I finally see them all again.
Handling it in Anyway, does the code above seem to work? |
As mentioned in #2069:
The last commit attempts to do this. It was actually releasing the thing too fast, so the command ended up resolving again. To fix that, I moved the delay and hard-coded it to the default (2 seconds). (FYI, a good way to test that the object in the interface is the one the command executes with is Random Track ⇥ Reveal in iTunes. Just wait 10 or so seconds between calling it up, and running the command. It should reveal the same track you saw in QS.) |
That is, once the proxy has been "used", make sure it gets resolved fresh the next time it's requested.
Planning to merge this soon if there are no objections. To sum it up:
|
Also of note… The correct cache time for a proxy is somewhere in between “too short for the user to use the thing” and “so long that the wrong thing is still there when the user grabs the proxy a second time”. In other words, it’s a complete guess that can never be correct 100% of the time. Developers no longer have to do this guessing. |
Sorry Rob I’ve been so quiet lately. I do read your messages and nod my head in agreement, so take that as me chiming in! :P
|
Good to know. Thanks. |
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)interval * NSEC_PER_SEC); | ||
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ | ||
[cache removeObjectForKey:QSProxyTargetCache]; | ||
}); | ||
} |
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.
@skurfer so it seems this is already getting called after a command has executed so like you I'm stumped as to why we need the timer at all. Perhaps for abbreviations? But if the command execution, abbreviation setting, proxy releasing is all run on the same thread (it looks like it is) then it should already be synchronous and there shouldn't be a need for this.
Fixes #2069, which was the original motivation, but I also put this out there to get your opinion on the changes to the observers. I’ve long wondered what would happen if we did this.
(My motivation for trying was to get the mini-icons in a comma trick collection to update. It was either this, or another complicated mess of adding and removing observers for individual objects.)
I think it’s OK because we can tell the OS a billion times that a view needs to be redrawn, but it won’t actually redraw unless it decides it’s a good time to do so. Is that correct? In any case, icon changes don’t come in too rapidly. The only “problem” I see is that all three panes get the notice and ask to be redrawn.
Before this is merged, I’d also like to see if we can get other places to observe icon changes. (Like every view in the Preferences window, and the optional zooming trigger window.)