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

managing the source array from plug-ins #804

Merged
merged 8 commits into from May 7, 2012
Merged

managing the source array from plug-ins #804

merged 8 commits into from May 7, 2012

Conversation

skurfer
Copy link
Member

@skurfer skurfer commented Apr 10, 2012

Nothing inspires confidence like a third try, right? :-)

This is the same as #801, minus a few commits that require a new iVar in QSActionProvider.

Again, this is to address the issues in #768.

skurfer added 7 commits Apr 10, 2012
* making a mutable copy in `showArray:withDirectObject:` breaks the ability to update it later
Previously, it would be observed by 6 instances of QSSearchObjectView.
* This will allow us to refer back to the sender of the notification later.
* This is the typical convention.
Initially, they're the same object. When the user types and alters the results, they become different, which will prevent unwanted further updates.
@skurfer skurfer mentioned this pull request Apr 16, 2012
@skurfer
Copy link
Member Author

@skurfer skurfer commented May 4, 2012

Added a constant as suggested. Here’s some code you can put into an action to test.

NSMutableArray *someArray = [NSMutableArray arrayWithCapacity:1];
NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:someArray, kQSResultArrayKey, nil];
QSObject *a = [QSObject objectWithString:@"One"];
QSObject *b = [QSObject objectWithString:@"Two"];
QSObject *c = [QSObject objectWithString:@"Three"];
[someArray addObject:a];
[[NSNotificationCenter defaultCenter] postNotificationName:@"QSSourceArrayCreated" object:self userInfo:userInfo];
sleep(2);
[someArray addObject:b];
[[NSNotificationCenter defaultCenter] postNotificationName:@"QSSourceArrayUpdated" object:self userInfo:userInfo];
sleep(2);
[someArray addObject:c];
[someArray removeObject:a];
[[NSNotificationCenter defaultCenter] postNotificationName:@"QSSourceArrayUpdated" object:self userInfo:userInfo];
return nil;

@pjrobertson
Copy link
Member

@pjrobertson pjrobertson commented May 5, 2012

We could just remove the 'run tasks in background' option and make it default. What would we lose?

It certainly creates a lot of problems when testing

@skurfer
Copy link
Member Author

@skurfer skurfer commented May 7, 2012

For posterity, if you don’t enable the “Run tasks in background” option, the example code above won’t update the results list in real-time. You get the initial list (One), then when the action returns after 4 seconds, you see the final result (Two, Three). The intermediate list (One, Two) is never visible.

For a couple of reasons, I don’t think anything needs to be changed in this pull request.

  1. This is how it would have behaved before. I’m not introducing a new “problem”.
  2. While this can lead to weird results, I’m not sure if it’s technically broken. If you don’t run tasks in the background, the interface is held hostage until the action returns. There are many other undesirable things that result from this. It’s not specific to the results array and it’s not new.
  3. The example above is a little convoluted. In the only practical example in existence (from the Spotlight plug-in), there won’t be intermediate results. There will just be an initial place-holder object, then the final results when the action completes. So in practice, users shouldn’t see this weird behavior regardless of their preferences.

We could just remove the 'run tasks in background' option and make it default. What would we lose?

I can only speculate, but I’m guessing this was implemented as an optional experimental feature. I think its stability is proven at this point, and I can only think of examples where having it off causes problems, but none where having it on does. But that’s a larger discussion for another place.

pjrobertson added a commit that referenced this issue May 7, 2012
managing the source array from plug-ins
@pjrobertson pjrobertson merged commit 5d245f4 into quicksilver:master May 7, 2012
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.

None yet

2 participants