Hi,

On Friday, May 6, 2011 01:43 CEST, Riccardo Mottola 
<[email protected]> wrote: 
 
> Hi Fred,
> 
> I cleaned up some of the old apps that way, but only recently discovered 
> that the apps do not start up at all if written that way. Sebastian 
> essentially confirms this.
> 
> Even if the fix is quite simple, I don't understand why it broke. It 
> doesn't work for me on plain 32biit x86 and sparc on linux or NetBSD 
> iwth the gcc runtime. Thus it is not at all libobjc2 or clang.

attached diff includes the change i sent before, but removes even more 
compilation warnings, regarding unused variables and the like.
only one warning left, where it uses a private method of NSColor, 
+colorFromString:. Don't know how to replace this with sth. better.
Further, instead of using this playsound command, I changed it to use NSSound, 
which works for me so far so good. I only see one problem yet, where the cuckoo 
sound is played in a loop. I here the sound only once, but don't know why, 
maybe someone can tell me what is wrong there?

cheers,
Sebastian


> 
> Riccardo
> 
> Fred Kiefer wrote:
> > All these patches are nice and fine and should be applied. But there 
> > seems to be an underlying issue with libobjc2 that should be fixed as 
> > well. The old code is sub-optimal but I cannot see an obvious bug in 
> > it, it should actually work. And if it doesn't then it is the runtime 
> > that is at fault here.
> >
> > David, could you please look into this? And if it isn't the runtime 
> > that is wrong here, please explain why the old code was wrong. We or 
> > at least I could learn a bit more about the details of Objective-C here.
> >
> > On 05.05.2011 16:39, Sebastian Reitenbach wrote:
> >> attached a similar fix to get AClock from gap CVS to start up. 
> >> Actually the same as for LapisPuzzle.
> >> Further the URL in the Info... window points to a nonexistent host, 
> >> but since there is no special page on GAP for it (yet) I did not 
> >> updated it too.
> >> Anyone knows what this playsound binary is, which is used to play the 
> >> sounds?
> >
> >
> > _______________________________________________
> > Discuss-gnustep mailing list
> > [email protected]
> > https://lists.gnu.org/mailman/listinfo/discuss-gnustep
> 
> 
> _______________________________________________
> Discuss-gnustep mailing list
> [email protected]
> https://lists.gnu.org/mailman/listinfo/discuss-gnustep
 
 
 
 
Index: AppController.h
===================================================================
RCS file: /sources/gap/gap/user-apps/AClock/AppController.h,v
retrieving revision 1.1
diff -u -r1.1 AppController.h
--- AppController.h	2 May 2010 05:16:14 -0000	1.1
+++ AppController.h	6 May 2011 13:23:54 -0000
@@ -45,4 +45,5 @@
 - (void) setFrequency: (id)sender;
 - (void) setSecond: (id)sender;
 - (void) setNumberType: (id)sender;
+- (void) playCuckoo:(int) round;
 @end
Index: AppController.m
===================================================================
RCS file: /sources/gap/gap/user-apps/AClock/AppController.m,v
retrieving revision 1.1
diff -u -r1.1 AppController.m
--- AppController.m	2 May 2010 05:16:14 -0000	1.1
+++ AppController.m	6 May 2011 13:23:55 -0000
@@ -46,8 +46,12 @@
 - (void) setRing: (id) sender
 {
 	useRing = [sender intValue]?YES:NO;
-	if (useRing)
-		system([[NSString stringWithFormat:@"playsound %@ &", [[NSBundle mainBundle] pathForResource:@"ring.wav" ofType:nil]] lossyCString]);
+	if (useRing) {
+		NSSound *ring = [[NSSound alloc] initWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"ring.wav" ofType:nil] byReference: NO];
+		[ring retain];
+		[ring play];
+		[ring release];
+	}
 	[defaults setObject:useRing?@"YES":@"NO" forKey:@"Ring"];
 	[defaults synchronize];
 }
@@ -158,8 +162,11 @@
 {
 	if ([alarmWindow isVisible] && extracount)
 	{
-		NSLog([NSString stringWithFormat:@"playsound --volume %0.1f %@ &",volume, [[NSBundle mainBundle] pathForResource:@"ring.wav" ofType:nil]]);
-		system([[NSString stringWithFormat:@"playsound --volume %0.1f %@ &",volume, [[NSBundle mainBundle] pathForResource:@"ring.wav" ofType:nil]] lossyCString]);
+		NSSound *ring = [[NSSound alloc] initWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"ring.wav" ofType:nil] byReference: NO];
+		[ring setVolume: volume];
+		[ring retain];
+		[ring play];
+		[ring release];
 		extracount--;
 		volume += volume_append;
 		if (volume > 1.0) volume = 1.0;
@@ -291,7 +298,6 @@
 
 	{ /* initialize the clock so it won't flick */
 		NSCalendarDate *d = [NSCalendarDate date];
-		NSTimeInterval g = [d timeIntervalSinceReferenceDate];
 		double time;
 		time = [d hourOfDay] * 3600 + [d minuteOfHour] * 60 + [d secondOfMinute];
 		[_clock setHandsTimeNoAlarm: time];
@@ -314,7 +320,6 @@
 	NSTimeInterval g = [d timeIntervalSinceReferenceDate];
 	double time;
 	NSInteger hod = [d hourOfDay];
-	NSInteger moh = [d minuteOfHour];
 
 	if (useCuckoo && lastHourOfDay != hod)
 	{
@@ -339,7 +344,6 @@
 	[clicon setHandsTime: time];
 }
 
-static int cround;
 static int cstate = -1;
 NSTimer *ctimer;
 - (void) cuckoo
@@ -362,8 +366,15 @@
 {
 	if (cstate == -1)
 	{
+		int loop = 0;
 		cstate = 20 * round;
-		system([[NSString stringWithFormat:@"playsound --loop %d %@ &", round - 1, [[NSBundle mainBundle] pathForResource:@"cuckoo.wav" ofType:nil]] lossyCString]);
+		NSSound *cuckoo = [[NSSound alloc] initWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"cuckoo.wav" ofType:nil] byReference: NO];
+		[cuckoo retain];
+		while (loop < round) {
+			[cuckoo play];
+			loop++;
+		}
+		[cuckoo release];
 		NSInvocation *inv;
 		inv = [NSInvocation invocationWithMethodSignature:
 						 [self methodSignatureForSelector:@selector(cuckoo)]];
Index: Clock.h
===================================================================
RCS file: /sources/gap/gap/user-apps/AClock/Clock.h,v
retrieving revision 1.1
diff -u -r1.1 Clock.h
--- Clock.h	2 May 2010 05:16:14 -0000	1.1
+++ Clock.h	6 May 2011 13:23:55 -0000
@@ -88,6 +88,7 @@
 -(double) alarmInterval;
 -(void) setAlarmInterval: (double)time;
 -(void) setHandsTimeNoAlarm: (double)time;
+- (void) setCuckooState:(int)st;
 
 @end
 
Index: Clock.m
===================================================================
RCS file: /sources/gap/gap/user-apps/AClock/Clock.m,v
retrieving revision 1.1
diff -u -r1.1 Clock.m
--- Clock.m	2 May 2010 05:16:14 -0000	1.1
+++ Clock.m	6 May 2011 13:23:55 -0000
@@ -57,14 +57,6 @@
 
 /** Internally used functions/methods **/
 
-static double wrap_time(double time)
-{
-	int i;
-	i=floor(time/1440);
-	return time-i*1440;
-}
-
-
 -(void) _frameChanged
 {
 	NSRect r=[self bounds];
@@ -363,7 +355,6 @@
 -(void) drawRect: (NSRect)r
 {
 	NSGraphicsContext *ctxt=GSCurrentContext();
-	id defaults = [NSUserDefaults standardUserDefaults];
 	/*
 	BOOL smoothSeconds = [defaults boolForKey: @"SmoothSeconds"];
 	*/
@@ -687,7 +678,7 @@
 	/* draw arc */
 	if (showsArc)
 	{
-		double a1,a2,x,y;
+		double a1,a2;
 		double r1;
 
 		a1 = 90 - (handsTime - 43200 * floor(handsTime/43200))/43200 * 360;
@@ -919,7 +910,7 @@
 	}
 }
 
-- (void) setCuckooState:(int)st;
+- (void) setCuckooState:(int)st
 {
 	if (st != cstate)
 	{
@@ -1021,8 +1012,6 @@
 
 -(void) setAlarmInterval: (double)time
 {
-	int n = handsTime / 43200;
-
 	alarmInterval = floor(handsTime / 43200) * 43200 + fmod(time, 43200.);
 
 	if (alarmInterval < handsTime) alarmInterval += 43200;
Index: main.m
===================================================================
RCS file: /sources/gap/gap/user-apps/AClock/main.m,v
retrieving revision 1.1
diff -u -r1.1 main.m
--- main.m	2 May 2010 05:16:15 -0000	1.1
+++ main.m	6 May 2011 13:23:55 -0000
@@ -1,10 +1,6 @@
 #include <AppKit/AppKit.h>
 
-int main(int argc, char **argv)
+int main(int argc, const char **argv)
 {
-	CREATE_AUTORELEASE_POOL(pool);
-	[NSApplication sharedApplication];
-	[NSApp run];
-	DESTROY(pool);
-	return 0;
+	return NSApplicationMain (argc, argv);
 }
_______________________________________________
Discuss-gnustep mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/discuss-gnustep

Reply via email to