Skip to content

Commit 391e451

Browse files
committed
Merge pull request #55 from Papercloud/issue/54
CADisplayLinks are removed by invalidating.
2 parents 57cd39f + 3ced222 commit 391e451

13 files changed

+39
-39
lines changed

Classes/NavigationController/UINavigationController+M13ProgressViewBar.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ - (void)setProgress:(CGFloat)progress animated:(BOOL)animated
4949
if (animated == NO) {
5050
if (displayLink) {
5151
//Kill running animations
52-
[displayLink removeFromRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
52+
[displayLink invalidate];
5353
[self setDisplayLink:nil];
5454
}
5555
[self setProgress:progress];
@@ -59,7 +59,7 @@ - (void)setProgress:(CGFloat)progress animated:(BOOL)animated
5959
[self setAnimationToValue:progress];
6060
if (!displayLink) {
6161
//Create and setup the display link
62-
[displayLink removeFromRunLoop:NSRunLoop.mainRunLoop forMode:NSRunLoopCommonModes];
62+
[displayLink invalidate];
6363
displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(animateProgress:)];
6464
[self setDisplayLink:displayLink];
6565
[displayLink addToRunLoop:NSRunLoop.mainRunLoop forMode:NSRunLoopCommonModes];
@@ -75,7 +75,7 @@ - (void)animateProgress:(CADisplayLink *)displayLink
7575
CGFloat dt = (displayLink.timestamp - [self getAnimationStartTime]) / [self getAnimationDuration];
7676
if (dt >= 1.0) {
7777
//Order is important! Otherwise concurrency will cause errors, because setProgress: will detect an animation in progress and try to stop it by itself. Once over one, set to actual progress amount. Animation is over.
78-
[displayLink removeFromRunLoop:NSRunLoop.mainRunLoop forMode:NSRunLoopCommonModes];
78+
[displayLink invalidate];
7979
[self setDisplayLink:nil];
8080
[self setProgress:[self getAnimationToValue]];
8181
return;

Classes/ProgressViews/M13ProgressViewBar.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ - (void)setProgress:(CGFloat)progress animated:(BOOL)animated
192192
if (animated == NO) {
193193
if (_displayLink) {
194194
//Kill running animations
195-
[_displayLink removeFromRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
195+
[_displayLink invalidate];
196196
_displayLink = nil;
197197
}
198198
[super setProgress:progress animated:NO];
@@ -203,7 +203,7 @@ - (void)setProgress:(CGFloat)progress animated:(BOOL)animated
203203
_animationToValue = progress;
204204
if (!_displayLink) {
205205
//Create and setup the display link
206-
[self.displayLink removeFromRunLoop:NSRunLoop.mainRunLoop forMode:NSRunLoopCommonModes];
206+
[self.displayLink invalidate];
207207
self.displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(animateProgress:)];
208208
[self.displayLink addToRunLoop:NSRunLoop.mainRunLoop forMode:NSRunLoopCommonModes];
209209
} /*else {
@@ -218,7 +218,7 @@ - (void)animateProgress:(CADisplayLink *)displayLink
218218
CGFloat dt = (displayLink.timestamp - _animationStartTime) / self.animationDuration;
219219
if (dt >= 1.0) {
220220
//Order is important! Otherwise concurrency will cause errors, because setProgress: will detect an animation in progress and try to stop it by itself. Once over one, set to actual progress amount. Animation is over.
221-
[self.displayLink removeFromRunLoop:NSRunLoop.mainRunLoop forMode:NSRunLoopCommonModes];
221+
[self.displayLink invalidate];
222222
self.displayLink = nil;
223223
[super setProgress:_animationToValue animated:NO];
224224
[self setNeedsDisplay];

Classes/ProgressViews/M13ProgressViewBorderedBar.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ - (void)setProgress:(CGFloat)progress animated:(BOOL)animated
179179
if (animated == NO) {
180180
if (_displayLink) {
181181
//Kill running animations
182-
[_displayLink removeFromRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
182+
[_displayLink invalidate];
183183
_displayLink = nil;
184184
}
185185
[super setProgress:progress animated:NO];
@@ -190,7 +190,7 @@ - (void)setProgress:(CGFloat)progress animated:(BOOL)animated
190190
_animationToValue = progress;
191191
if (!_displayLink) {
192192
//Create and setup the display link
193-
[self.displayLink removeFromRunLoop:NSRunLoop.mainRunLoop forMode:NSRunLoopCommonModes];
193+
[self.displayLink invalidate];
194194
self.displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(animateProgress:)];
195195
[self.displayLink addToRunLoop:NSRunLoop.mainRunLoop forMode:NSRunLoopCommonModes];
196196
} /*else {
@@ -205,7 +205,7 @@ - (void)animateProgress:(CADisplayLink *)displayLink
205205
CGFloat dt = (displayLink.timestamp - _animationStartTime) / self.animationDuration;
206206
if (dt >= 1.0) {
207207
//Order is important! Otherwise concurrency will cause errors, because setProgress: will detect an animation in progress and try to stop it by itself. Once over one, set to actual progress amount. Animation is over.
208-
[self.displayLink removeFromRunLoop:NSRunLoop.mainRunLoop forMode:NSRunLoopCommonModes];
208+
[self.displayLink invalidate];
209209
self.displayLink = nil;
210210
[super setProgress:_animationToValue animated:NO];
211211
[self setNeedsDisplay];

Classes/ProgressViews/M13ProgressViewFilteredImage.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ - (void)setProgress:(CGFloat)progress animated:(BOOL)animated
102102
if (animated == NO) {
103103
if (_displayLink) {
104104
//Kill running animations
105-
[_displayLink removeFromRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
105+
[_displayLink invalidate];
106106
_displayLink = nil;
107107
}
108108
[super setProgress:progress animated:NO];
@@ -113,7 +113,7 @@ - (void)setProgress:(CGFloat)progress animated:(BOOL)animated
113113
_animationToValue = progress;
114114
if (!_displayLink) {
115115
//Create and setup the display link
116-
[self.displayLink removeFromRunLoop:NSRunLoop.mainRunLoop forMode:NSRunLoopCommonModes];
116+
[self.displayLink invalidate];
117117
self.displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(animateProgress:)];
118118
[self.displayLink addToRunLoop:NSRunLoop.mainRunLoop forMode:NSRunLoopCommonModes];
119119
} /*else {
@@ -128,7 +128,7 @@ - (void)animateProgress:(CADisplayLink *)displayLink
128128
CGFloat dt = (displayLink.timestamp - _animationStartTime) / self.animationDuration;
129129
if (dt >= 1.0) {
130130
//Order is important! Otherwise concurrency will cause errors, because setProgress: will detect an animation in progress and try to stop it by itself. Once over one, set to actual progress amount. Animation is over.
131-
[self.displayLink removeFromRunLoop:NSRunLoop.mainRunLoop forMode:NSRunLoopCommonModes];
131+
[self.displayLink invalidate];
132132
self.displayLink = nil;
133133
[super setProgress:_animationToValue animated:NO];
134134
[self setNeedsDisplay];

Classes/ProgressViews/M13ProgressViewImage.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ - (void)setProgress:(CGFloat)progress animated:(BOOL)animated
111111
if (animated == NO) {
112112
if (_displayLink) {
113113
//Kill running animations
114-
[_displayLink removeFromRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
114+
[_displayLink invalidate];
115115
_displayLink = nil;
116116
}
117117
[super setProgress:progress animated:NO];
@@ -122,7 +122,7 @@ - (void)setProgress:(CGFloat)progress animated:(BOOL)animated
122122
_animationToValue = progress;
123123
if (!_displayLink) {
124124
//Create and setup the display link
125-
[self.displayLink removeFromRunLoop:NSRunLoop.mainRunLoop forMode:NSRunLoopCommonModes];
125+
[self.displayLink invalidate];
126126
self.displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(animateProgress:)];
127127
[self.displayLink addToRunLoop:NSRunLoop.mainRunLoop forMode:NSRunLoopCommonModes];
128128
} /*else {
@@ -137,7 +137,7 @@ - (void)animateProgress:(CADisplayLink *)displayLink
137137
CGFloat dt = (displayLink.timestamp - _animationStartTime) / self.animationDuration;
138138
if (dt >= 1.0) {
139139
//Order is important! Otherwise concurrency will cause errors, because setProgress: will detect an animation in progress and try to stop it by itself. Once over one, set to actual progress amount. Animation is over.
140-
[self.displayLink removeFromRunLoop:NSRunLoop.mainRunLoop forMode:NSRunLoopCommonModes];
140+
[self.displayLink invalidate];
141141
self.displayLink = nil;
142142
[super setProgress:_animationToValue animated:NO];
143143
[self setNeedsDisplay];

Classes/ProgressViews/M13ProgressViewLetterpress.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ - (void)setProgress:(CGFloat)progress animated:(BOOL)animated
170170
if (animated == NO) {
171171
if (_displayLink) {
172172
//Kill running animations
173-
[_displayLink removeFromRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
173+
[_displayLink invalidate];
174174
_displayLink = nil;
175175
}
176176
[super setProgress:progress animated:NO];
@@ -181,7 +181,7 @@ - (void)setProgress:(CGFloat)progress animated:(BOOL)animated
181181
_animationToValue = progress;
182182
if (!_displayLink) {
183183
//Create and setup the display link
184-
[self.displayLink removeFromRunLoop:NSRunLoop.mainRunLoop forMode:NSRunLoopCommonModes];
184+
[self.displayLink invalidate];
185185
self.displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(animateProgress:)];
186186
[self.displayLink addToRunLoop:NSRunLoop.mainRunLoop forMode:NSRunLoopCommonModes];
187187
} /*else {
@@ -196,7 +196,7 @@ - (void)animateProgress:(CADisplayLink *)displayLink
196196
CGFloat dt = (displayLink.timestamp - _animationStartTime) / self.animationDuration;
197197
if (dt >= 1.0) {
198198
//Order is important! Otherwise concurrency will cause errors, because setProgress: will detect an animation in progress and try to stop it by itself. Once over one, set to actual progress amount. Animation is over.
199-
[self.displayLink removeFromRunLoop:NSRunLoop.mainRunLoop forMode:NSRunLoopCommonModes];
199+
[self.displayLink invalidate];
200200
self.displayLink = nil;
201201
[super setProgress:_animationToValue animated:NO];
202202
[self setNeedsDisplay];

Classes/ProgressViews/M13ProgressViewMetro.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ - (void)setProgress:(CGFloat)progress animated:(BOOL)animated
238238
if (animated == NO) {
239239
if (_displayLink) {
240240
//Kill running animations
241-
[_displayLink removeFromRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
241+
[_displayLink invalidate];
242242
_displayLink = nil;
243243
}
244244
[super setProgress:progress animated:NO];
@@ -249,7 +249,7 @@ - (void)setProgress:(CGFloat)progress animated:(BOOL)animated
249249
_animationToValue = progress;
250250
if (!_displayLink) {
251251
//Create and setup the display link
252-
[self.displayLink removeFromRunLoop:NSRunLoop.mainRunLoop forMode:NSRunLoopCommonModes];
252+
[self.displayLink invalidate];
253253
self.displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(animateProgress:)];
254254
[self.displayLink addToRunLoop:NSRunLoop.mainRunLoop forMode:NSRunLoopCommonModes];
255255
} /*else {
@@ -264,7 +264,7 @@ - (void)animateProgress:(CADisplayLink *)displayLink
264264
CGFloat dt = (displayLink.timestamp - _animationStartTime) / self.animationDuration;
265265
if (dt >= 1.0) {
266266
//Order is important! Otherwise concurrency will cause errors, because setProgress: will detect an animation in progress and try to stop it by itself. Once over one, set to actual progress amount. Animation is over.
267-
[self.displayLink removeFromRunLoop:NSRunLoop.mainRunLoop forMode:NSRunLoopCommonModes];
267+
[self.displayLink invalidate];
268268
self.displayLink = nil;
269269
[super setProgress:_animationToValue animated:NO];
270270
[self showProgress];

Classes/ProgressViews/M13ProgressViewPie.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ - (void)setProgress:(CGFloat)progress animated:(BOOL)animated
158158
if (animated == NO) {
159159
if (_displayLink) {
160160
//Kill running animations
161-
[_displayLink removeFromRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
161+
[_displayLink invalidate];
162162
_displayLink = nil;
163163
}
164164
[super setProgress:progress animated:animated];
@@ -169,7 +169,7 @@ - (void)setProgress:(CGFloat)progress animated:(BOOL)animated
169169
_animationToValue = progress;
170170
if (!_displayLink) {
171171
//Create and setup the display link
172-
[self.displayLink removeFromRunLoop:NSRunLoop.mainRunLoop forMode:NSRunLoopCommonModes];
172+
[self.displayLink invalidate];
173173
self.displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(animateProgress:)];
174174
[self.displayLink addToRunLoop:NSRunLoop.mainRunLoop forMode:NSRunLoopCommonModes];
175175
} /*else {
@@ -184,7 +184,7 @@ - (void)animateProgress:(CADisplayLink *)displayLink
184184
CGFloat dt = (displayLink.timestamp - _animationStartTime) / self.animationDuration;
185185
if (dt >= 1.0) {
186186
//Order is important! Otherwise concurrency will cause errors, because setProgress: will detect an animation in progress and try to stop it by itself. Once over one, set to actual progress amount. Animation is over.
187-
[self.displayLink removeFromRunLoop:NSRunLoop.mainRunLoop forMode:NSRunLoopCommonModes];
187+
[self.displayLink invalidate];
188188
self.displayLink = nil;
189189
[super setProgress:_animationToValue animated:NO];
190190
[self setNeedsDisplay];

Classes/ProgressViews/M13ProgressViewRadiative.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ - (void)setProgress:(CGFloat)progress animated:(BOOL)animated
145145
if (animated == NO) {
146146
if (_displayLink) {
147147
//Kill running animations
148-
[_displayLink removeFromRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
148+
[_displayLink invalidate];
149149
_displayLink = nil;
150150
}
151151
[super setProgress:progress animated:NO];
@@ -156,7 +156,7 @@ - (void)setProgress:(CGFloat)progress animated:(BOOL)animated
156156
_animationToValue = progress;
157157
if (!_displayLink) {
158158
//Create and setup the display link
159-
[self.displayLink removeFromRunLoop:NSRunLoop.mainRunLoop forMode:NSRunLoopCommonModes];
159+
[self.displayLink invalidate];
160160
self.displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(animateProgress:)];
161161
[self.displayLink addToRunLoop:NSRunLoop.mainRunLoop forMode:NSRunLoopCommonModes];
162162
} /*else {
@@ -171,7 +171,7 @@ - (void)animateProgress:(CADisplayLink *)displayLink
171171
CGFloat dt = (displayLink.timestamp - _animationStartTime) / self.animationDuration;
172172
if (dt >= 1.0) {
173173
//Order is important! Otherwise concurrency will cause errors, because setProgress: will detect an animation in progress and try to stop it by itself. Once over one, set to actual progress amount. Animation is over.
174-
[self.displayLink removeFromRunLoop:NSRunLoop.mainRunLoop forMode:NSRunLoopCommonModes];
174+
[self.displayLink invalidate];
175175
self.displayLink = nil;
176176
[super setProgress:_animationToValue animated:NO];
177177
[self setNeedsDisplay];

Classes/ProgressViews/M13ProgressViewRing.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ - (void)setProgress:(CGFloat)progress animated:(BOOL)animated
186186
if (animated == NO) {
187187
if (_displayLink) {
188188
//Kill running animations
189-
[_displayLink removeFromRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
189+
[_displayLink invalidate];
190190
_displayLink = nil;
191191
}
192192
[super setProgress:progress animated:animated];
@@ -197,7 +197,7 @@ - (void)setProgress:(CGFloat)progress animated:(BOOL)animated
197197
_animationToValue = progress;
198198
if (!_displayLink) {
199199
//Create and setup the display link
200-
[self.displayLink removeFromRunLoop:NSRunLoop.mainRunLoop forMode:NSRunLoopCommonModes];
200+
[self.displayLink invalidate];
201201
self.displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(animateProgress:)];
202202
[self.displayLink addToRunLoop:NSRunLoop.mainRunLoop forMode:NSRunLoopCommonModes];
203203
} /*else {
@@ -212,7 +212,7 @@ - (void)animateProgress:(CADisplayLink *)displayLink
212212
CGFloat dt = (displayLink.timestamp - _animationStartTime) / self.animationDuration;
213213
if (dt >= 1.0) {
214214
//Order is important! Otherwise concurrency will cause errors, because setProgress: will detect an animation in progress and try to stop it by itself. Once over one, set to actual progress amount. Animation is over.
215-
[self.displayLink removeFromRunLoop:NSRunLoop.mainRunLoop forMode:NSRunLoopCommonModes];
215+
[self.displayLink invalidate];
216216
self.displayLink = nil;
217217
[super setProgress:_animationToValue animated:NO];
218218
[self setNeedsDisplay];

0 commit comments

Comments
 (0)