Mercurial > dwindows
diff mac/dw.m @ 2617:d17e3fb76bde
dw_menu_popup() should also set handle NULL and add safety checks if missing.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Fri, 23 Jul 2021 19:42:06 +0000 |
parents | ac51cbdcfbe5 |
children | 156ad91481eb |
line wrap: on
line diff
--- a/mac/dw.m Fri Jul 23 19:26:01 2021 +0000 +++ b/mac/dw.m Fri Jul 23 19:42:06 2021 +0000 @@ -9432,25 +9432,29 @@ */ void API dw_menu_popup(HMENUI *menu, HWND parent, int x, int y) { - NSMenu *thismenu = (NSMenu *)*menu; - id object = parent; - NSView *view = [object isKindOfClass:[NSWindow class]] ? [object contentView] : parent; - NSWindow *window = [view window]; - NSEvent *event = [DWApp currentEvent]; - if(!window) - window = [event window]; - [thismenu autorelease]; - NSPoint p = NSMakePoint(x, [[NSScreen mainScreen] frame].size.height - y); - NSEvent* fake = [NSEvent mouseEventWithType:DWEventTypeRightMouseDown - location:_dw_windowPointFromScreen(window, p) - modifierFlags:0 - timestamp:[event timestamp] - windowNumber:[window windowNumber] - context:[NSGraphicsContext currentContext] - eventNumber:1 - clickCount:1 - pressure:0.0]; - [NSMenu popUpContextMenu:thismenu withEvent:fake forView:view]; + if(menu) + { + NSMenu *thismenu = (NSMenu *)*menu; + id object = parent; + NSView *view = [object isKindOfClass:[NSWindow class]] ? [object contentView] : parent; + NSWindow *window = [view window]; + NSEvent *event = [DWApp currentEvent]; + if(!window) + window = [event window]; + [thismenu autorelease]; + NSPoint p = NSMakePoint(x, [[NSScreen mainScreen] frame].size.height - y); + NSEvent* fake = [NSEvent mouseEventWithType:DWEventTypeRightMouseDown + location:_dw_windowPointFromScreen(window, p) + modifierFlags:0 + timestamp:[event timestamp] + windowNumber:[window windowNumber] + context:[NSGraphicsContext currentContext] + eventNumber:1 + clickCount:1 + pressure:0.0]; + [NSMenu popUpContextMenu:thismenu withEvent:fake forView:view]; + *menu = NULL; + } } char _dw_removetilde(char *dest, const char *src)