Fix possible problem iterating array of apps

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@22376 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2006-01-27 18:13:46 +00:00
parent b4882e2268
commit 8586e3f3b9

View file

@ -24,6 +24,7 @@
#include <Foundation/NSString.h>
#include <Foundation/NSAutoreleasePool.h>
#include <Foundation/NSException.h>
#include <Foundation/NSPropertyList.h>
#include <AppKit/NSApplication.h>
#include <AppKit/NSWorkspace.h>
@ -42,6 +43,17 @@ main(int argc, char** argv, char **env_c)
workspace = [NSWorkspace sharedWorkspace];
launched = [workspace launchedApplications];
/*
* Hack ... if the array is from a workspace application it may actually
* be a proxy, and if we terminate that application the proxy will become
* invalid while we are iterating through the array. To avoid that
* problem we serialize the array into an NSData object and deserialize
* that into local memory.
*/
launched = [NSPropertyListSerialization propertyListFromData:
[NSPropertyListSerialization dataFromPropertyList: launched format: NSPropertyListBinaryFormat_v1_0 errorDescription: 0] mutabilityOption: NSPropertyListImmutable format: 0 errorDescription: 0];
enumerator = [launched objectEnumerator];
while ((info = [enumerator nextObject]) != nil)
{