aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPDatabaseDocument.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2010-07-25 12:05:13 +0000
committerrowanbeentje <rowan@beent.je>2010-07-25 12:05:13 +0000
commit550c112216171aa81487b32c41d7aa64adc2ec7f (patch)
tree1ddbbd28c4d46dec359caeede81e899f5970a0e5 /Source/SPDatabaseDocument.m
parent0dff71796759307023398775fde082e3bdd41d31 (diff)
downloadsequelpro-550c112216171aa81487b32c41d7aa64adc2ec7f.tar.gz
sequelpro-550c112216171aa81487b32c41d7aa64adc2ec7f.tar.bz2
sequelpro-550c112216171aa81487b32c41d7aa64adc2ec7f.zip
- Replace core animation fade of task progress window with custom drawing code, in an attempt to fix Issue #677. It appears from testing that this is only a partial fix, but does reduce hang frequency.
Diffstat (limited to 'Source/SPDatabaseDocument.m')
-rw-r--r--Source/SPDatabaseDocument.m51
1 files changed, 29 insertions, 22 deletions
diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m
index 43b5e844..bace5cb5 100644
--- a/Source/SPDatabaseDocument.m
+++ b/Source/SPDatabaseDocument.m
@@ -119,7 +119,7 @@
taskProgressValue = 0;
taskProgressValueDisplayInterval = 1;
taskDrawTimer = nil;
- taskFadeAnimator = nil;
+ taskFadeInStartDate = nil;
taskCanBeCancelled = NO;
taskCancellationCallbackObject = nil;
taskCancellationCallbackSelector = NULL;
@@ -1304,27 +1304,37 @@
[mainToolbar validateVisibleItems];
[chooseDatabaseButton setEnabled:NO];
- // Schedule appearance of the task window in the near future
- taskDrawTimer = [[NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(showTaskProgressWindow:) userInfo:nil repeats:NO] retain];
+ // Schedule appearance of the task window in the near future, using a frame timer.
+ taskFadeInStartDate = [[NSDate alloc] init];
+ taskDrawTimer = [[NSTimer scheduledTimerWithTimeInterval:1.0 / 30.0 target:self selector:@selector(fadeInTaskProgressWindow:) userInfo:nil repeats:YES] retain];
}
}
/**
* Show the task progress window, after a small delay to minimise flicker.
*/
-- (void) showTaskProgressWindow:(NSTimer *)theTimer
+- (void) fadeInTaskProgressWindow:(NSTimer *)theTimer
{
- if (taskDrawTimer) [taskDrawTimer invalidate], [taskDrawTimer release], taskDrawTimer = nil;
+ float timeSinceFadeInStart = [[NSDate date] timeIntervalSinceDate:taskFadeInStartDate];
- // Center the task window and fade it in
- [self centerTaskWindow];
- NSDictionary *animationDetails = [NSDictionary dictionaryWithObjectsAndKeys:
- NSViewAnimationFadeInEffect, NSViewAnimationEffectKey,
- taskProgressWindow, NSViewAnimationTargetKey,
- nil];
- taskFadeAnimator = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObject:animationDetails]];
- [taskFadeAnimator setDuration:0.6];
- [taskFadeAnimator startAnimation];
+ // Keep the window hidden for the first ~0.5 secs
+ if (timeSinceFadeInStart < 0.5) return;
+
+ CGFloat alphaValue = [taskProgressWindow alphaValue];
+
+ // If the task progress window is still hidden, center it before revealing it
+ if (alphaValue == 0) [self centerTaskWindow];
+
+ // Fade in the task window over 0.6 seconds
+ alphaValue = (timeSinceFadeInStart - 0.5) / 0.6;
+ if (alphaValue > 1.0) alphaValue = 1.0;
+ [taskProgressWindow setAlphaValue:alphaValue];
+
+ // If the window has been fully faded in, clean up the timer.
+ if (alphaValue == 1.0) {
+ [taskDrawTimer invalidate], [taskDrawTimer release], taskDrawTimer = nil;
+ [taskFadeInStartDate release], taskFadeInStartDate = nil;
+ }
}
@@ -1405,12 +1415,9 @@
if (!_isWorkingLevel) {
// Cancel the draw timer if it exists
- if (taskDrawTimer) [taskDrawTimer invalidate], [taskDrawTimer release], taskDrawTimer = nil;
-
- // Cancel the fade-in animator if it exists
- if (taskFadeAnimator) {
- if ([taskFadeAnimator isAnimating]) [taskFadeAnimator stopAnimation];
- [taskFadeAnimator release], taskFadeAnimator = nil;
+ if (taskDrawTimer) {
+ [taskDrawTimer invalidate], [taskDrawTimer release], taskDrawTimer = nil;
+ [taskFadeInStartDate release], taskFadeInStartDate = nil;
}
// Hide the task interface and reset to indeterminate
@@ -4625,8 +4632,8 @@
if (mySQLConnection) [mySQLConnection release];
if (selectedDatabase) [selectedDatabase release];
if (mySQLVersion) [mySQLVersion release];
- if (taskDrawTimer) [taskDrawTimer release];
- if (taskFadeAnimator) [taskFadeAnimator release];
+ if (taskDrawTimer) [taskDrawTimer invalidate], [taskDrawTimer release];
+ if (taskFadeInStartDate) [taskFadeInStartDate release];
if (queryEditorInitString) [queryEditorInitString release];
if (spfFileURL) [spfFileURL release];
if (spfPreferences) [spfPreferences release];