[dasher: 7/28] MacOS: fix crash at startup on 10.7
- From: Patrick Welche <pwelche src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dasher: 7/28] MacOS: fix crash at startup on 10.7
- Date: Tue, 22 Nov 2011 17:03:15 +0000 (UTC)
commit ee7c90600927dace7c4e10809cacaae16cd78fa5
Author: Alan Lawrence <acl33 inf phy cam ac uk>
Date: Wed Sep 21 17:26:07 2011 +0100
MacOS: fix crash at startup on 10.7
Src/MacOSX/DasherApp.h | 1 -
Src/MacOSX/DasherApp.mm | 22 +++++++---------------
Src/MacOSX/DasherTextView.mm | 3 ++-
3 files changed, 9 insertions(+), 17 deletions(-)
---
diff --git a/Src/MacOSX/DasherApp.h b/Src/MacOSX/DasherApp.h
index 9f4a48b..3333118 100644
--- a/Src/MacOSX/DasherApp.h
+++ b/Src/MacOSX/DasherApp.h
@@ -58,7 +58,6 @@
- (void)startTimer;
- (void)shutdownTimer;
- (NSTimer *)timer;
-- (void)setTimer:(NSTimer *)newTimer;
- (void)timerCallback:(NSTimer *)aTimer;
- (void)dealloc;
- (bool)supportsSpeech;
diff --git a/Src/MacOSX/DasherApp.mm b/Src/MacOSX/DasherApp.mm
index 51590eb..bec5cd9 100644
--- a/Src/MacOSX/DasherApp.mm
+++ b/Src/MacOSX/DasherApp.mm
@@ -197,9 +197,9 @@ static NSString *FilenameToUntitledName = @"NilToUntitled";
- (void)startTimer {
#define FPS 40.0f
-
+ [self shutdownTimer]; //in case there was one before
NSTimer *timer = [NSTimer timerWithTimeInterval:(1.0f/FPS) target:self selector:@selector(timerCallback:) userInfo:nil repeats:YES];
- [self setTimer:timer];
+ _timer = [timer retain];
[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode];
[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSEventTrackingRunLoopMode];
@@ -207,24 +207,16 @@ static NSString *FilenameToUntitledName = @"NilToUntitled";
}
- (void)shutdownTimer {
- [self setTimer:nil];
+ [_timer invalidate];
+ [_timer release];
+ _timer = nil;
}
- (NSTimer *)timer {
return _timer;
}
-- (void)setTimer:(NSTimer *)newTimer {
- if (_timer != newTimer) {
- NSTimer *oldValue = _timer;
- _timer = [newTimer retain];
- [oldValue invalidate];
- [oldValue release];
- }
-}
-
-- (void)timerCallback:(NSTimer *)aTimer
-{
+- (void)timerCallback:(NSTimer *)aTimer {
aquaDasherControl->TimerFired([dasherView mouseLocation]);
}
@@ -249,7 +241,7 @@ static NSString *FilenameToUntitledName = @"NilToUntitled";
}
- (void)dealloc {
- [self setTimer:nil];
+ [self shutdownTimer];
[super dealloc];
}
diff --git a/Src/MacOSX/DasherTextView.mm b/Src/MacOSX/DasherTextView.mm
index d90bb44..edf1087 100644
--- a/Src/MacOSX/DasherTextView.mm
+++ b/Src/MacOSX/DasherTextView.mm
@@ -173,8 +173,9 @@
-(void)textViewDidChangeSelection:(NSNotification *)notification {
if (dasherApp.gameModeOn) return;
+ if (suppressCursorEvents) return;
//NSLog(@"DidChangeSelection %i+%i",[textView selectedRange].location,[textView selectedRange].length);
- if (!suppressCursorEvents)
+ if ([dasherApp timer]) //timer set when Realize() completed
[dasherApp aquaDasherControl]->SetOffset([self selectedRange].location, false);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]