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.
This commit is contained in:
Didier Korthoudt
2015-12-02 00:03:59 +01:00
parent 634a8b4532
commit a649a6ebac
2 changed files with 17 additions and 16 deletions
+10 -9
View File
@@ -23,16 +23,17 @@
@import <Foundation/Foundation.j>
@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",
+7 -7
View File
@@ -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];
}