my system refuses to shut down/restart with NSAppleScript class
Asked Answered
R

2

14

I am using CFPlugin for contextual menu and icon overlay on 10.5(same as scplugin). For communication between my application and finder , i am using distributed object. After installing my plugin inside Contextual menu items folder , my system refuse to restart/shutdow/Logout. In activity monitor i am unable to quit finder , only force quit is woking for finder. On console I am getting on 10.5.8

ERROR | -[ApplicationManager(AppleEventHandling) _tryQuitAllForRequestor:replyEvent:] | _tryQuitAllForRequestor - _vproc_set_global_on_demand returned error -1805620379  

Without communication between Finder and my application, system restart/shutdow/Logout are working fine.
On 10.5.4

loginwindow[41]: ERROR | WSActivateApp | SetFrontProcess({0, 7980956}) returned error -600. Unable to activate process.

loginwindow[41]: ERROR | -[ApplicationManager(AppleEventHandling) _tryQuitAllForRequestor:replyEvent:] | _tryQuitAllForRequestor - _vproc_set_global_on_demand returned error -1780878507

Can anyone please help me out?

EDIT

My problem is solved. I was using NSAppleScript for executing apple script. Now i am using NSTask and my system restart/shutdow/Logout are working fine. can anyone please explain me reason for this?

Romaineromains answered 7/2, 2012 at 15:46 Comment(7)
I notice that when you're called from an app other than the Finder, you return "noErr". What do you return when you are called from the Finder?Oversell
If application is finder , i am executing my code.Romaineromains
And then what does it return?Oversell
it will return OSStatus, error or noErr.Romaineromains
without communication module, my plug-in is working fine.Romaineromains
are you initiating a DO transaction in the shutdown process? It looks like Finder is waiting a reply from your IPC server.Popliteal
My problem is solved. I was using NSAppleScript for executing apple script. Now i am using NSTask.Romaineromains
R
0

My problem is solved. I was using NSAppleScript for executing apple script. Now i am using NSTask and my system restart/shutdow/Logout are working fine

Romaineromains answered 7/2, 2012 at 15:46 Comment(0)
R
1

NSAppleScript can only be run from the main thread, so the main thread is going to be blocked while it is running.

Not too sure what is the root cause of the message, but I am supposing the script can not be found or run properly, and then the main thread is blocked or timed out, and all your shutdown sequence gets stuck.

On the opposite side, NSTask is properly multithreaded so the sequence won't be blocked, and your computer will properly shutdown.

Here are a few relevant links gathered around:

Recede answered 7/2, 2012 at 15:46 Comment(2)
I was running Apple script from secondary thread. and only one thread at a time.Romaineromains
From (NSAppleScript not in the main thread)[cocoabuilder.com/archive/cocoa/… 'All NSAppleScript instance seem to use the same ComponentInstance also the ComponentInstance may also be used by the main thread, to set up the application to be AppleScriptable perhaps. Each thread must have its own AppleScript ComponentInstance, in theory this you could have multiple thread each running there own AppleScript' I am assuming that finder is not using NSApplescript class.Romaineromains
R
0

My problem is solved. I was using NSAppleScript for executing apple script. Now i am using NSTask and my system restart/shutdow/Logout are working fine

Romaineromains answered 7/2, 2012 at 15:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.