orderOut: doesn't work as expected when executed in Spaces-mode

  • Hi everyone,

    I've got an application that has several windows. Sometimes they're
    ordered out programmatically. To my surprise, this "fails" when the
    user has activated Spaces. To reproduce, follow these very simple steps:

    1. Create a test application ("Cocoa Application") using XCode.
    2. Create a controller class and instansiate it in Interface Builder
    3. Make the controller the application's delegate (ctrl-dragging in IB
    works just fine).
    4. In the controller's @implementation, add this code:

    - (void)tryClose:(NSTimer *)timer {

      NSLog(@"Before sleep");
      [NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:10]];
      [[NSApp mainWindow] orderOut:self];
      NSLog(@"After sleep");
    }

    - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {

      NSTimer *aTimer = [NSTimer scheduledTimerWithTimeInterval:5
                                                          target:self

    selector:@selector(tryClose:)
                                                        userInfo:nil
                                                        repeats:FALSE];
    }

    5. Launch the application (with a console available)
    6. When it say's "Before sleep", active Spaces (and keep it activated!)
    7. Note how the window disappears after 10 seconds (accompanied by a
    info text in the console)
    8. Left-click in the Space where the window previously was to
    inactivate Spaces (or inactivate Spaces by pressing the Spaces-
    shortcut again) and viola, the window shows up again! This does _not_
    happen if you, from Spaces, go to another Space, and then switch to
    the Space where the window was before we activated Spaces the first
    time.

    Is this a bug, or is it something else that should be done to properly
    order out the window when in Spaces?

    / Mattias
  • On Dec 12, 2007 7:08 AM, Mattias Arrelid <mattias...> wrote:

    > Is this a bug, or is it something else that should be done to properly
    > order out the window when in Spaces?

    Sounds like a bug --> http://developer.apple.com/bugreporter/

    (include your steps to include ...better yet a build-able project that
    shows the issue)

    -Shawn
previous month december 2007 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            
Go to today