NSProgressIndicator will not disappear (determinate)

790 Views Asked by At

I have a determinate progress indicator. It is working just like I would expect it to but it does not disappear after it reaches maxValue. I have set the progress indicator to not display when stopped in the main.nib file, I have also entered it into the awakeFromNib{} method. I put a log at the end of the routine to make sure the [displayWhenStopped] setting was still set to NO and it is.

Here is my code :

-(void)getEvents:(NSURL *)mffFile{

NSMutableArray * eventTypeResults =[[NSMutableArray alloc]init];

EWaveformRecording  *ptrToRcdFile = [EWaveformRecording openRecording:mffFile permission:readOnly user:nil convertFileFormat:NO openReadOnlyAnyway:NO];
NSArray *events = [ptrToRcdFile getEvents];
//get the size of events for the progressbar and instantiate a loop counter
NSInteger total = [events count];
int loop = 0;

//set progress bar params
[self->meter_ setUsesThreadedAnimation:YES];
[self->meter_ setControlSize:NSMiniControlSize];
[self->meter_ setMaxValue:(double)total];

for(EEvent* event in events){
    loop ++;
    if(![eventTypeResults containsObject:event.code]){
     NSLog(@"check eventNames in getEvents %@", event.code);
     [eventTypeResults addObject: event.code];
    }//end if
//display loop increment in progress bar
[self->meter_ setDoubleValue:(1000*(double)loop)/1000];
}//end for

//send the eventTypesResults array to the EventExport class
[evtPtr setEventsAvailableList:eventTypeResults];
 }

What I have tried:

with and without [setUsesThreadedAnimation] which I don't totally understand; it does slow down the progress bar which makes it look better but the docs say only indeterminate types should be effected by animation.

I have tried using [start & stop animation] I have tried [setDisplayWhenStopped:NO] after my loop

Any help is greatly appreciated MIke

1

There are 1 best solutions below

0
On

This is what I learned.

I should not be allowing the progress bar to run on a different thread even though it looks like its working because the NSProgressIndicator can no longer respond to the settings in the main thread, so the proper thing to do is to not instantiate that method, however , that was not the solution to my problem; I was doing everything else right, but the main thread could not redraw the progress because it's busy with all the other calls in the UI. The solution was to implement NSRunLoop so that each iteration of the loop interrupts the main thread and redraws the progress meter , then returns control.