From a649a6ebac69caa5d11caf0102f3de895ab79023 Mon Sep 17 00:00:00 2001 From: Didier Korthoudt Date: Wed, 2 Dec 2015 00:03:59 +0100 Subject: [PATCH] CIB-fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For some (yet unknown) reason, when declaring a view with tracking area in a CIB, there’s some weird things happening that try to use the _trackingAreas array when it’s not yet initialized… So, replacing _trackingAreas.length by [_trackingAreas count] resolves the problem. --- AppKit/CPTrackingArea.j | 19 ++++++++++--------- AppKit/CPView.j | 14 +++++++------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/AppKit/CPTrackingArea.j b/AppKit/CPTrackingArea.j index 3f262683e..0b422b1c3 100644 --- a/AppKit/CPTrackingArea.j +++ b/AppKit/CPTrackingArea.j @@ -23,16 +23,17 @@ @import @import "CPView.j" +/* @group CPTrackingAreaOptions */ @typedef CPTrackingAreaOptions -CPTrackingMouseEnteredAndExited = 1 << 1, -CPTrackingMouseMoved = 1 << 2, -CPTrackingCursorUpdate = 1 << 3, -CPTrackingActiveWhenFirstResponder = 1 << 4, -CPTrackingActiveInKeyWindow = 1 << 5, -CPTrackingActiveInActiveApp = 1 << 6, -CPTrackingActiveAlways = 1 << 7, -CPTrackingAssumeInside = 1 << 8, -CPTrackingInVisibleRect = 1 << 9, +CPTrackingMouseEnteredAndExited = 1 << 1; +CPTrackingMouseMoved = 1 << 2; +CPTrackingCursorUpdate = 1 << 3; +CPTrackingActiveWhenFirstResponder = 1 << 4; +CPTrackingActiveInKeyWindow = 1 << 5; +CPTrackingActiveInActiveApp = 1 << 6; +CPTrackingActiveAlways = 1 << 7; +CPTrackingAssumeInside = 1 << 8; +CPTrackingInVisibleRect = 1 << 9; CPTrackingEnabledDuringMouseDrag = 1 << 10; var CPTrackingAreaRectKey = @"CPTrackinkAreaRectKey", diff --git a/AppKit/CPView.j b/AppKit/CPView.j index 36656fdf8..05bf3cc45 100644 --- a/AppKit/CPView.j +++ b/AppKit/CPView.j @@ -3535,7 +3535,7 @@ setBoundsOrigin: // We also do special treatment and notify the view itself if it has no tracking area to // enable the use of updateTrackingAreas as a mean to install tracking areas. - if (_trackingAreas.length > 0) + if ([_trackingAreas count] > 0) var ownersToNotify = [self _prepareOwnersToNotify]; else var ownersToNotify = @[ self ]; @@ -3551,7 +3551,7 @@ setBoundsOrigin: var ownersToNotify = []; - for (var i = 0; i < _trackingAreas.length; i++) + for (var i = 0, count = [_trackingAreas count]; i < count; i++) { var trackingArea = _trackingAreas[i]; @@ -3626,6 +3626,11 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask", if (self) { + _trackingAreas = [aCoder decodeObjectForKey:CPViewTrackingAreasKey]; + + if (!_trackingAreas) + _trackingAreas = []; + // We have to manually check because it may be 0, so we can't use || _tag = [aCoder containsValueForKey:CPViewTagKey] ? [aCoder decodeIntForKey:CPViewTagKey] : -1; _identifier = [aCoder decodeObjectForKey:CPReuseIdentifierKey]; @@ -3699,11 +3704,6 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask", [self setAppearance:[aCoder decodeObjectForKey:CPViewAppearanceKey]]; - _trackingAreas = [aCoder decodeObjectForKey:CPViewTrackingAreasKey]; - - if (!_trackingAreas) - _trackingAreas = []; - [self setNeedsDisplay:YES]; [self setNeedsLayout]; }