2019-03-08 08:37:50 +00:00
|
|
|
diff --git a/gdk/quartz/GdkQuartzWindow.c b/gdk/quartz/GdkQuartzWindow.c
|
2019-07-12 08:58:20 +00:00
|
|
|
index e8e0de5c7..d0c6e84ec 100644
|
2019-03-08 08:37:50 +00:00
|
|
|
--- a/gdk/quartz/GdkQuartzWindow.c
|
|
|
|
+++ b/gdk/quartz/GdkQuartzWindow.c
|
2019-07-12 08:58:20 +00:00
|
|
|
@@ -24,6 +24,13 @@
|
|
|
|
|
|
|
|
@implementation GdkQuartzWindow
|
|
|
|
|
|
|
|
+-(void)dealloc
|
|
|
|
+{
|
|
|
|
+ // During deallocation, Cocoa resets the delegate to nil
|
|
|
|
+ // We need to track that so that we don't throw an error
|
|
|
|
+ _allowDelegateToBeSetToNil = YES;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
-(BOOL)windowShouldClose:(id)sender
|
|
|
|
{
|
|
|
|
GdkWindow *window = [[self contentView] gdkWindow];
|
|
|
|
@@ -259,6 +266,16 @@
|
2019-03-08 08:37:50 +00:00
|
|
|
return [super makeFirstResponder:responder];
|
|
|
|
}
|
|
|
|
|
|
|
|
+-(void)setDelegate:(id<NSWindowDelegate>)delegate
|
|
|
|
+{
|
2019-07-12 08:58:20 +00:00
|
|
|
+ if ([super delegate] == nil || (_allowDelegateToBeSetToNil && delegate == nil)) {
|
2019-03-08 08:37:50 +00:00
|
|
|
+ [super setDelegate:delegate];
|
|
|
|
+ } else {
|
|
|
|
+ // If we allow the window delegate to be replaced, everything breaks.
|
|
|
|
+ g_critical ("Setting a delegate on GdkQuartzWindow is forbidden, because everything will break.");
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
-(id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)styleMask backing:(NSBackingStoreType)backingType defer:(BOOL)flag screen:(NSScreen *)screen
|
|
|
|
{
|
|
|
|
self = [super initWithContentRect:contentRect
|
2019-07-12 08:58:20 +00:00
|
|
|
@@ -271,6 +288,7 @@
|
|
|
|
[self setDelegate:self];
|
|
|
|
[self setReleasedWhenClosed:YES];
|
|
|
|
|
|
|
|
+ _allowDelegateToBeSetToNil = NO;
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
diff --git a/gdk/quartz/GdkQuartzWindow.h b/gdk/quartz/GdkQuartzWindow.h
|
|
|
|
index 928f9617e..23cde0037 100644
|
|
|
|
--- a/gdk/quartz/GdkQuartzWindow.h
|
|
|
|
+++ b/gdk/quartz/GdkQuartzWindow.h
|
|
|
|
@@ -34,6 +34,8 @@
|
|
|
|
NSPoint initialMoveLocation;
|
|
|
|
NSPoint initialResizeLocation;
|
|
|
|
NSRect initialResizeFrame;
|
|
|
|
+
|
|
|
|
+ BOOL _allowDelegateToBeSetToNil;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(BOOL)isInMove;
|