NSOpenPanel stops showing inserted/ejected disks
NSOpenPanel stops showing inserted/ejected disks
- Subject: NSOpenPanel stops showing inserted/ejected disks
- From: Grigory Entin <email@hidden>
- Date: Sat, 16 Apr 2005 18:22:01 +0400
Hello,
Has anybody experienced that? Any comments would be very appreciated.
Just in case, NSOpenPanel gets refreshed for other items (dis)appeared
in the file system, e.g. folders created in Finder and etc..
Currently I narrowed it down to the simple (though "esoteric") case:
If the app calls FindFolder *and* launches any NSTask *before* the app
finishes launching, any NSOpenPanel doesn't get updated with CD disks
inserted/ejected after launch. The Objective C source code for the
simple app that reproduces the problem is at the end.
The app just does the following: calls FindFolder/launches NSTask
(BadThing() call) before the application finishes launching (currently
in main(), but the calls can be placed in e.g. app delegate -init),
and displays NSOpenPanel right in -applicationDidFinishLaunching: of
the delegate. If you insert a CD when the panel is open, it won't be
displayed in the panel. If you eject a CD that has been inserted
before the launch, it won't be removed from the panel. Just in case,
it doesn't depend whether the panel is open at the moment of
insert/eject - all NSOpenPanels "get stuck" until the app is
relaunched. Removing that BadThing call restores the expected behavior
- panels get updated and etc.
It's quite amazing but I indeed need *both* call FindFolder and launch
NSTask to get the problem.. But unfortunately that's what our
real-life app does.
Not including .xcode projects / ib data - they are trivial (app
delegate outlet is connected to an instance of MyController). I can
send the full source package to anybody interested though.
Just in case, I tried to study it with _debug frameworks, but all I
get is just stderr full of DebugAsserts refferring LaunchServices,
_LSGetBundleClassForNode_Exit, GetCatalogInfo_VolumeNotFound,
_FSFlattenFSRef_NoSuchVolume in *both* "normal" and "buggy" cases.
Regards,
Grigory
main.m:
>>>
/* main.m */
#import <Cocoa/Cocoa.h>
extern void BadThing (void);
int main (int argc, char *argv[])
{
// Making the following call anytime before the app
// finishes launching results in NSOpenPanel not refreshed
// when a CD is inserted/ejected after the app launches.
#if 1
BadThing ();
#endif
return NSApplicationMain (argc, (const char **)argv);
}
>>>
MyController.h:
>>>
/* MyController */
/* My controller is the application delegate */
#import <Cocoa/Cocoa.h>
@interface MyController : NSObject
{
}
@end
>>>
MyController.m:
>>>
#import "MyController.h"
void BadThing (void)
{
// Disabling FSFindFolder call or NSTask launch results in no
// problems with NSOpenPanel. Having them both enabled however,
// results in the NSOpenPanel refresh problem.
#if 1
{
FSRef appSupportFSRef;
OSErr err =
FSFindFolder (kUserDomain,
kApplicationSupportFolderType,
kCreateFolder,
&appSupportFSRef);
NSCAssert (noErr == err, @"");
}
#endif
#if 1
{
NSTask *task =
[NSTask launchedTaskWithLaunchPath: @"/usr/bin/true"
arguments: [NSArray array]];
[task waitUntilExit];
int rc = [task terminationStatus];
NSCAssert (0 == rc, @"");
}
#endif
}
@implementation MyController
- (void) applicationDidFinishLaunching: (NSNotification *)n
{
// The following call doesn't result in problems,
// but if you move it e.g. to -[MyController init] it will.
#if 0
BadThing ();
#endif
[[NSOpenPanel openPanel] runModalForTypes: nil];
}
@end
>>>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden