I am using a mutex to prevent my application from being started multiple times.
On Mac using a compiled application, the initial launch everything works as intended, however, subsequent launches produce the below error when executing the “quit” command.
[quote=96932:@Jason Hel]I am using a mutex to prevent my application from being started multiple times.
On Mac using a compiled application, the initial launch everything works as intended, however, subsequent launches produce the below error when executing the “quit” command.
[/quote]
No need on OS X
It does this by default
how are you starting it ?
using the open command or something else ?
and what kind of project did you start with ?
this almost look like a GUI app that is being started from a terminal with no window server attached or something
never mind my work around isnt working… still dumps a stacktrace…
In the App.open method I used the mutex:
appMutex = new Mutex(“com.foobar.MyApp”)
// grab command line args…
Dim args As String
dim commandArgs() as string
commandArgs = split(system.commandLine, " ")
if uBound(commandArgs) > 0 then
dim arg As String
arg = commandArgs(1)
handleArgument
end if
// try to get a lock on mutex
if not appMutex.TryEnter then
shutdown() // just calls quit
else
self.isMainApp = True
splashWindow.Show
end if
As you can see in the “open” method of App I launch my app’s splash screen window. I just tried having the startup window being hidden and calling shutdown from there… same exception
Sure but you still haven’t said how you start this
From another app with or without a user slogged in ?
If its without one then a GUI app (desktop app) probably will not work as it requires window manager
I tried launching an app by calling the Unix executable inside from the terminal. It does not release the terminal until the application has quit or the process being killed from another window. The 'NSInternalInconsistencyException', reason: 'NSApp with wrong _running count' error may simply mean that the app.quit is using an inappropriate method to kill its own process.
However, I could not reproduce the error.
I am pretty sure calling an app by the Unix executable would not be sanctioned by Apple as a supported way of launching a GUI app. Better use Open <path to the .app>.
I attempted to use the open program on the mac and I saw the same error.
I believe I have found a solution to this, in the window where I was calling the quit I changed the code to the below and I am not seeing the exception.
// shutdown the app without crashing.
App.AutoQuit = True
self.Close