I have a trigger who's scope is limited to one app.
When I start this app, the trigger does not reliably work.
It does work after I switched to a different app and returned to the specific app.
Steps to reproduce
Add a trigger
Limit its scope to an App
Start the App
Try the trigger
Expected behavior
The trigger should work each time.
MacOS Version
macOS 12
Quicksilver Version
Checked out main/Released 2.4.0 (4039)
Relevant Plugins
-/-
Crash Logs or Spindump
-/-
Screenshots
-/-
Additional info
1) QSProcessMonitor.m handles both appChanged (line 51) and appLaunched (line 70) carbon process events.
2) The appLaunched handler schedules an async task on the main thread that posts a notifications on the default notification center.
3) This notification is handled in the future on the main thread and updates the processesDict (in reloadProcesses, line 362).
4) The appChanged handler might be called before step 3 takes place. appChanged uses processObjectWithPSN to get the process information for the newly active app which is not yet stored in processesDict. The result of this call is attached as user info to another notification posted (one of the listeners to this notification updates which triggers are active).
Since in step 4, the processesDict has not been updated in all cases, the newly active app is not known and the triggers do not get updated.
Note: appLaunched calls processObjectWithPSN (in line 80) using the PSN of the new app. This call always returns nil.
I see two ways to fix this:
1) Lazy fix: Drop the call to processObjectWithPSN in appLaunched carbon event handler and move the call to processObjectWithPSN onto the main thread in appChanged.
2) Clean fix: reloadProcesses mentions a addProcessWithPSN which I could not find. If this existed, it should be called in appLaunched (instead of line 80, if it returns the new dictionary) to update the processesDict right away. Everything else could stay the same.
Before submitting your bug report, please confirm you have completed the following steps
Bug description
I have a trigger who's scope is limited to one app. When I start this app, the trigger does not reliably work. It does work after I switched to a different app and returned to the specific app.
Steps to reproduce
Expected behavior
The trigger should work each time.
MacOS Version
macOS 12
Quicksilver Version
Checked out main/Released 2.4.0 (4039)
Relevant Plugins
-/-
Crash Logs or Spindump
-/-
Screenshots
-/-
Additional info
1)
QSProcessMonitor.m
handles bothappChanged
(line 51) andappLaunched
(line 70) carbon process events. 2) TheappLaunched
handler schedules an async task on the main thread that posts a notifications on the default notification center. 3) This notification is handled in the future on the main thread and updates theprocessesDict
(inreloadProcesses
, line 362). 4) TheappChanged
handler might be called before step 3 takes place.appChanged
usesprocessObjectWithPSN
to get the process information for the newly active app which is not yet stored inprocessesDict
. The result of this call is attached as user info to another notification posted (one of the listeners to this notification updates which triggers are active).Since in step 4, the
processesDict
has not been updated in all cases, the newly active app is not known and the triggers do not get updated.Note:
appLaunched
callsprocessObjectWithPSN
(in line 80) using the PSN of the new app. This call always returnsnil
.I see two ways to fix this:
1) Lazy fix: Drop the call to
processObjectWithPSN
inappLaunched
carbon event handler and move the call toprocessObjectWithPSN
onto the main thread inappChanged
.2) Clean fix:
reloadProcesses
mentions aaddProcessWithPSN
which I could not find. If this existed, it should be called inappLaunched
(instead of line 80, if it returns the new dictionary) to update theprocessesDict
right away. Everything else could stay the same.