App freezes when resizing window?

260 views Asked by At

I'm working on a menubar application and I've made a custom (borderless) NSWindow which I've added programmatically. For some reason when I try to resize the window, it freezes and I'm unable to resize the window and open the menu-bar menu. However I can still move the window but not click things in it. The weird thing is that there is no error message at all, even though I turned on breakpoints and NSZombieMode. So I've no idea what the problem could be.

    // customWindow.m
    - (id)initWithContentRect:(NSRect)contentRect
                    styleMask:(NSUInteger)aStyle
                      backing:(NSBackingStoreType)bufferingType
                        defer:(BOOL)flag {
        // Using NSBorderlessWindowMask results in a window without a title bar.
        self = [super initWithContentRect:contentRect styleMask:NSBorderlessWindowMask | NSResizableWindowMask backing:NSBackingStoreBuffered defer:NO];


if (self != nil) {


        if (![[SharedClass sharedManager] lastColor]) {
        [self setBackgroundColor:[NSColor colorWithRed:(float)252/255 green:(float)249/255 blue:(float)151/255 alpha:1]];

        [[SharedClass sharedManager] setLastColor:self.backgroundColor];
        } else {
        [self setBackgroundColor: [[SharedClass sharedManager] lastColor]];
        }

        [self setLevel:NSNormalWindowLevel];
        // Start with no transparency for all drawing into the window

        // Turn off opacity so that the parts of the window that are not drawn into are transparent.
        [self setOpaque:NO];
       // [self setBackgroundColor:[NSColor clearColor]];
        [self setHasShadow:YES];
        [self setMovableByWindowBackground:YES];
        [self makeKeyAndOrderFront:theTextView];
        panel = [NSColorPanel sharedColorPanel];
        [panel setTarget:self];
        [panel setColor:self.backgroundColor];

        [panel setAction:@selector(colorUpdate:)];
        [panel setShowsAlpha:YES];
        [self setDelegate:self];
        NSRect cFrame = [self frame];
        NSView *theView = [[NSView alloc] initWithFrame:cFrame];

        [self setContentView:theView];



         [self setMinSize:CGSizeMake(100, 100)];

    }


      return self;
    }

       - (NSSize)windowWillResize:(NSWindow *)sender toSize:(NSSize)frameSize {

    exit.frame = NSMakeRect(2,(frameSize.height-12), 10, 10);
    palette.frame = NSMakeRect((frameSize.width-24),(frameSize.height-12), 10, 10);
    locker.frame = NSMakeRect((frameSize.width-12),(frameSize.height-12), 10, 10);
    theTextView.frame = NSRectFromCGRect(CGRectMake(0, 8, frameSize.width, (frameSize.height-20)));

    return frameSize;

}

- (void)windowDidResize:(NSNotification *)notification{
    NSLog(@"resized");
}

Stack trace :

0   DDHotKey                            0x00000001000044ed -[CustomWindow windowDidResize:] + 61
1   CoreFoundation                      0x00007fff9034245c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
2   CoreFoundation                      0x00007fff90232634 _CFXNotificationPost + 3140
3   Foundation                          0x00007fff8d7f59d1 -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
4   AppKit                              0x00007fff89117770 -[NSWindow _setFrameCommon:display:stashSize:] + 2885
5   AppKit                              0x00007fff891d4b73 -[NSWindow setFrame:display:animate:] + 641
6   DDHotKey                            0x000000010000a8c0 -[DDHotKeyAppDelegate setFrame:animated:] + 416
7   DDHotKey                            0x00000001000091ae __53-[DDHotKeyAppDelegate applicationDidFinishLaunching:]_block_invoke + 2318
8   AppKit                              0x00007fff895e5233 GlobalObserverHandler + 117
9   HIToolbox                           0x00007fff88d0ab6c _ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec + 1260
10  HIToolbox                           0x00007fff88d09fae _ZL30SendEventToEventTargetInternalP14OpaqueEventRefP20OpaqueEventTargetRefP14HandlerCallRec + 386
11  HIToolbox                           0x00007fff88d09e22 SendEventToEventTargetWithOptions + 43
12  HIToolbox                           0x00007fff88d46a9e _ZL29ToolboxEventDispatcherHandlerP25OpaqueEventHandlerCallRefP14OpaqueEventRefPv + 1762
13  HIToolbox                           0x00007fff88d0b295 _ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec + 3093
14  HIToolbox                           0x00007fff88d09fae _ZL30SendEventToEventTargetInternalP14OpaqueEventRefP20OpaqueEventTargetRefP14HandlerCallRec + 386
15  HIToolbox                           0x00007fff88d1fcb6 SendEventToEventTarget + 40
16  AppKit                              0x00007fff890d71a2 _DPSNextEvent + 3001
17  AppKit                              0x00007fff890d5f68 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 346
18  AppKit                              0x00007fff890cbbf3 -[NSApplication run] + 594
19  AppKit                              0x00007fff89048354 NSApplicationMain + 1832
20  DDHotKey                            0x0000000100007312 main + 34
21  libdyld.dylib                       0x00007fff8bd335c9 start + 1
0

There are 0 answers