I need to throw up a dialog box if my app catches another juce app with a particular name running when it starts up.
On windows, that wasn’t hard, I copied the lock code from juce into my moreThanOnceInstanceAllowed() routine:
InterProcessLock* appLock = 0;
appLock = new InterProcessLock ("juceAppLock_" + theOtherAppName);
if (! appLock->enter(0)){
//other app found. Put up dialog
}
This works on windows, but the same code on the mac fails. The Lock seems to work, and my dialog is never seen. What’s the correct way to go about doing this on the mac?
I knew that the MacOS prevents multiple instances from running. What I’m really trying to do is to find out if my (just launched) process is going to be killed because it’s a second instance.
On the Mac, it appears that the interprocesslock wasn’t what was preventing the second process from launching as it did on the PC, but clearly something else was.
Thanks for the tip about the bug fix. I’ll synch up.
The 1.45 mac code does work if I launch a second instance of the same application. I’m trying to test to see if an application who’s name is set in the InterProcessLock constructor is running.
Could it be that InterProcessLock() isn’t using the lock string passed in the constructor to do its comparisions?
Oh, I see. It shouldn’t matter about the process - you can see that it uses a shared file which gets created in juce_posix_SharedCode.cpp. The filename should be based on whatever string you use.