• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: App crashes on thread exit
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: App crashes on thread exit


  • Subject: Re: App crashes on thread exit
  • From: Fabio Genoese <email@hidden>
  • Date: Sat, 12 Oct 2002 19:33:50 +0200

Am Samstag, 12.10.02 um 19:01 Uhr schrieb Shawn Erickson:

Some source would help us help you.

Yeah, of course that would help. Sorry, here's some source:

This is the secondary thread:

- (void)sThread:(id)address
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSLock *theLock = [[NSLock alloc] init];
Server *s = [[Server alloc] init];
NSMutableDictionary *record = [[NSMutableDictionary alloc] init];

if ([theLock tryLock]) {
s = [qstat queryServer:address];
record = [s data];
[records addObject:record];
}
[theLock unlock];
[pool release];
}

From my qstat.m file (short explanatory: it calls the Unix tool qstat to query a Quake3 server, the rest of the method is about getting the output...):

+ (Server *)queryServer:(NSString *)address
{
NSString *players;
NSString *map;
NSString *ping;
NSString *name;
NSTask *q3s = [[NSTask alloc] init];
Server *s = [[Server alloc] init];
NSData *inData = nil;
NSPipe *sPipe = [NSPipe pipe];
NSFileHandle *sHandle = [sPipe fileHandleForReading];
NSArray *args = [[NSArray alloc] initWithObjects:@"-q3s",address,@"-nh",@"-raw",@"_,_", nil];
NSString *output2;
NSArray *output3;

[q3s setStandardOutput:sPipe];
[q3s setLaunchPath: [[NSBundle mainBundle] pathForResource:@"qstat" ofType:nil]];
[q3s setArguments:args];
[q3s launch];

inData = [sHandle readDataToEndOfFile];
output2 = [[NSString alloc] initWithData:[inData subdataWithRange:NSMakeRange(0, [inData length]-2)] encoding:NSASCIIStringEncoding];
output3 = [output2 componentsSeparatedByString:@"_,_"];
if ([output3 count] > 4) { //the queried server is UP
name = [output3 objectAtIndex:2];
address = [output3 objectAtIndex:1];
map = [output3 objectAtIndex:3];
players = [[[output3 objectAtIndex:5] stringByAppendingString:@"/"]stringByAppendingString:[output3 objectAtIndex:4]];
ping = [output3 objectAtIndex:6];
[s createServerWithName:name Address:address Players:players Map:map AndPing:ping];
} else //the queried server is DOWN or doesn't exist
[s createServerWithName:[output3 objectAtIndex:2] Address:[output3 objectAtIndex:3] Players:@"" Map:@"" AndPing:@""];

[q3s release]
return s;
}

Don't laugh about my code organisation, I'm obviously new to this. ;)
Fabio
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: App crashes on thread exit
      • From: Cameron Hayne <email@hidden>
References: 
 >Re: App crashes on thread exit (From: Shawn Erickson <email@hidden>)

  • Prev by Date: Re: App crashes on thread exit
  • Next by Date: Re: Centering an NSImageView in NSScrollView (again)
  • Previous by thread: Re: App crashes on thread exit
  • Next by thread: Re: App crashes on thread exit
  • Index(es):
    • Date
    • Thread