Skip to content
Browse files

Subviews may not be accessed during initWithCoder. Fixes #1485.

  • Loading branch information...
1 parent 092cb01 commit 9830b2b115e68909d74747eb6962da5ce5610c67 @aparajita aparajita committed Apr 22, 2012
View
31 AppKit/CPScrollView.j
@@ -751,35 +751,42 @@ Notifies the delegate when the scroll view has finished scrolling.
{
[_horizontalScroller setStyle:_scrollerStyle];
[_horizontalScroller unsetThemeState:CPThemeStateSelected];
+
switch (_scrollerKnobStyle)
{
case CPScrollerKnobStyleLight:
[_horizontalScroller unsetThemeState:CPThemeStateScrollerKnobDark];
[_horizontalScroller setThemeState:CPThemeStateScrollerKnobLight];
break;
+
case CPScrollerKnobStyleDark:
[_horizontalScroller unsetThemeState:CPThemeStateScrollerKnobLight];
[_horizontalScroller setThemeState:CPThemeStateScrollerKnobDark];
break;
+
default:
[_horizontalScroller unsetThemeState:CPThemeStateScrollerKnobLight];
[_horizontalScroller unsetThemeState:CPThemeStateScrollerKnobDark];
}
}
+
if (_hasVerticalScroller)
{
[_verticalScroller setStyle:_scrollerStyle];
[_verticalScroller unsetThemeState:CPThemeStateSelected];
+
switch (_scrollerKnobStyle)
{
case CPScrollerKnobStyleLight:
[_verticalScroller unsetThemeState:CPThemeStateScrollerKnobDark];
[_verticalScroller setThemeState:CPThemeStateScrollerKnobLight];
break;
+
case CPScrollerKnobStyleDark:
[_verticalScroller unsetThemeState:CPThemeStateScrollerKnobLight];
[_verticalScroller setThemeState:CPThemeStateScrollerKnobDark];
break;
+
default:
[_verticalScroller unsetThemeState:CPThemeStateScrollerKnobLight];
[_verticalScroller unsetThemeState:CPThemeStateScrollerKnobDark];
@@ -790,6 +797,7 @@ Notifies the delegate when the scroll view has finished scrolling.
{
if (_timerScrollersHide)
[_timerScrollersHide invalidate];
+
_timerScrollersHide = [CPTimer scheduledTimerWithTimeInterval:CPScrollViewFadeOutTime target:self selector:@selector(_hideScrollers:) userInfo:nil repeats:NO];
[[self bottomCornerView] setHidden:YES];
}
@@ -870,6 +878,7 @@ Notifies the delegate when the scroll view has finished scrolling.
var frame = [self _insetBounds];
frame.size.height = _CGRectGetHeight([headerView frame]);
+
if (SHOULD_SHOW_CORNER_VIEW())
frame.size.width -= _CGRectGetWidth([self _cornerViewFrame]);
@@ -1230,6 +1239,7 @@ Notifies the delegate when the scroll view has finished scrolling.
if (_timerScrollersHide)
[_timerScrollersHide invalidate]
+
_timerScrollersHide = [CPTimer scheduledTimerWithTimeInterval:CPScrollViewFadeOutTime target:self selector:@selector(_hideScrollers:) userInfo:nil repeats:NO];
}
@@ -1499,18 +1509,29 @@ var CPScrollViewContentViewKey = @"CPScrollViewContentView",
// Due to the anything goes nature of decoding, our subviews may not exist yet, so layout at the end of the run loop when we're sure everything is in a correct state.
[[CPRunLoop currentRunLoop] performSelector:@selector(_updateCornerAndHeaderView) target:self argument:_contentView order:0 modes:[CPDefaultRunLoopMode]];
- [self setScrollerStyle:[aCoder decodeIntForKey:CPScrollViewScrollerStyleKey] || CPScrollerStyleGlobal];
- [self setScrollerKnobStyle:[aCoder decodeIntForKey:CPScrollViewScrollerKnobStyleKey] || CPScrollerKnobStyleDefault];
+ _scrollerStyle = [aCoder decodeIntForKey:CPScrollViewScrollerStyleKey] || CPScrollerStyleGlobal;
+ _scrollerKnobStyle = [aCoder decodeIntForKey:CPScrollViewScrollerKnobStyleKey] || CPScrollerKnobStyleDefault;
[[CPNotificationCenter defaultCenter] addObserver:self
- selector:@selector(_didReceiveDefaultStyleChange:)
- name:CPScrollerStyleGlobalChangeNotification
- object:nil];
+ selector:@selector(_didReceiveDefaultStyleChange:)
+ name:CPScrollerStyleGlobalChangeNotification
+ object:nil];
}
return self;
}
+/*!
+ @ignore
+
+ Make sure the scroller style is updated. This can only be done after awakening.
+*/
+- (id)awakeAfterUsingCoder:(CPCoder)aCoder
+{
+ [self _updateScrollerStyle];
+ return self;
+}
+
- (void)encodeWithCoder:(CPCoder)aCoder
{
[super encodeWithCoder:aCoder];
View
2 Tests/Manual/CPScrollView2/Resources/MainMenu.cib
1 addition, 1 deletion not shown because the diff is too large. Please use a local Git client to view these changes.
View
112 Tests/Manual/CPScrollView2/Resources/MainMenu.xib
@@ -2,13 +2,13 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">1050</int>
- <string key="IBDocument.SystemVersion">11C74</string>
- <string key="IBDocument.InterfaceBuilderVersion">1938</string>
- <string key="IBDocument.AppKitVersion">1138.23</string>
- <string key="IBDocument.HIToolboxVersion">567.00</string>
+ <string key="IBDocument.SystemVersion">11D50</string>
+ <string key="IBDocument.InterfaceBuilderVersion">2182</string>
+ <string key="IBDocument.AppKitVersion">1138.32</string>
+ <string key="IBDocument.HIToolboxVersion">568.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="NS.object.0">1938</string>
+ <string key="NS.object.0">2182</string>
</object>
<object class="NSArray" key="IBDocument.IntegratedClassDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -1184,6 +1184,7 @@
<string key="NSAction">_doScroller:</string>
<double key="NSCurValue">1</double>
<double key="NSPercent">0.96363627910614014</double>
+ <int key="NSKnobStyle">2</int>
</object>
<object class="NSScroller" id="196713696">
<reference key="NSNextResponder" ref="364286201"/>
@@ -1197,6 +1198,7 @@
<reference key="NSTarget" ref="364286201"/>
<string key="NSAction">_doScroller:</string>
<double key="NSPercent">0.50602412223815918</double>
+ <int key="NSKnobStyle">2</int>
</object>
</object>
<string key="NSFrame">{{20, 300}, {575, 261}}</string>
@@ -1208,6 +1210,7 @@
<reference key="NSVScroller" ref="961292000"/>
<reference key="NSHScroller" ref="196713696"/>
<reference key="NSContentView" ref="175384428"/>
+ <int key="NSScrollerKnobStyle">2</int>
</object>
<object class="NSScrollView" id="17976132">
<reference key="NSNextResponder" ref="439893737"/>
@@ -1420,9 +1423,9 @@
<string key="NSKeyEquivalent"/>
<int key="NSPeriodicDelay">400</int>
<int key="NSPeriodicInterval">75</int>
- <object class="NSMenuItem" key="NSMenuItem" id="914668909">
+ <object class="NSMenuItem" key="NSMenuItem" id="642897130">
<reference key="NSMenu" ref="647805982"/>
- <string key="NSTitle">Dark</string>
+ <string key="NSTitle">Default</string>
<string key="NSKeyEquiv"/>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
@@ -1437,10 +1440,10 @@
<string key="NSTitle">OtherViews</string>
<object class="NSMutableArray" key="NSMenuItems">
<bool key="EncodedWithXMLCoder">YES</bool>
- <reference ref="914668909"/>
- <object class="NSMenuItem" id="1191465">
+ <reference ref="642897130"/>
+ <object class="NSMenuItem" id="914668909">
<reference key="NSMenu" ref="647805982"/>
- <string key="NSTitle">Light</string>
+ <string key="NSTitle">Dark</string>
<string key="NSKeyEquiv"/>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
@@ -1449,9 +1452,9 @@
<string key="NSAction">_popUpItemAction:</string>
<reference key="NSTarget" ref="448836112"/>
</object>
- <object class="NSMenuItem" id="642897130">
+ <object class="NSMenuItem" id="1191465">
<reference key="NSMenu" ref="647805982"/>
- <string key="NSTitle">Default</string>
+ <string key="NSTitle">Light</string>
<string key="NSKeyEquiv"/>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
@@ -1630,7 +1633,7 @@
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="1023031372"/>
</object>
- <string key="NSScreenRect">{{0, 0}, {2560, 1418}}</string>
+ <string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
<string key="NSMaxSize">{10000000000000, 10000000000000}</string>
<bool key="NSWindowIsRestorable">YES</bool>
</object>
@@ -3920,7 +3923,7 @@
<string>83.IBPluginDependency</string>
<string>92.IBPluginDependency</string>
</object>
- <object class="NSMutableArray" key="dict.values">
+ <object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -4142,7 +4145,7 @@
<string>makeShortDocView:</string>
<string>makeSmallDocView:</string>
</object>
- <object class="NSMutableArray" key="dict.values">
+ <object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>id</string>
<string>id</string>
@@ -4169,7 +4172,7 @@
<string>makeShortDocView:</string>
<string>makeSmallDocView:</string>
</object>
- <object class="NSMutableArray" key="dict.values">
+ <object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBActionInfo">
<string key="name">change:</string>
@@ -4218,7 +4221,7 @@
<string>scrollView</string>
<string>scrollView2</string>
</object>
- <object class="NSMutableArray" key="dict.values">
+ <object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>NSView</string>
<string>NSView</string>
@@ -4235,7 +4238,7 @@
<string>scrollView</string>
<string>scrollView2</string>
</object>
- <object class="NSMutableArray" key="dict.values">
+ <object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBToOneOutletInfo">
<string key="name">contentView</string>
@@ -4260,73 +4263,6 @@
<string key="minorKey">./Classes/AppController.h</string>
</object>
</object>
- <object class="IBPartialClassDescription">
- <string key="className">NSDocument</string>
- <object class="NSMutableDictionary" key="actions">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSArray" key="dict.sortedKeys">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <string>printDocument:</string>
- <string>revertDocumentToSaved:</string>
- <string>runPageLayout:</string>
- <string>saveDocument:</string>
- <string>saveDocumentAs:</string>
- <string>saveDocumentTo:</string>
- </object>
- <object class="NSMutableArray" key="dict.values">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <string>id</string>
- <string>id</string>
- <string>id</string>
- <string>id</string>
- <string>id</string>
- <string>id</string>
- </object>
- </object>
- <object class="NSMutableDictionary" key="actionInfosByName">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSArray" key="dict.sortedKeys">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <string>printDocument:</string>
- <string>revertDocumentToSaved:</string>
- <string>runPageLayout:</string>
- <string>saveDocument:</string>
- <string>saveDocumentAs:</string>
- <string>saveDocumentTo:</string>
- </object>
- <object class="NSMutableArray" key="dict.values">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <object class="IBActionInfo">
- <string key="name">printDocument:</string>
- <string key="candidateClassName">id</string>
- </object>
- <object class="IBActionInfo">
- <string key="name">revertDocumentToSaved:</string>
- <string key="candidateClassName">id</string>
- </object>
- <object class="IBActionInfo">
- <string key="name">runPageLayout:</string>
- <string key="candidateClassName">id</string>
- </object>
- <object class="IBActionInfo">
- <string key="name">saveDocument:</string>
- <string key="candidateClassName">id</string>
- </object>
- <object class="IBActionInfo">
- <string key="name">saveDocumentAs:</string>
- <string key="candidateClassName">id</string>
- </object>
- <object class="IBActionInfo">
- <string key="name">saveDocumentTo:</string>
- <string key="candidateClassName">id</string>
- </object>
- </object>
- </object>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBProjectSource</string>
- <string key="minorKey">./Classes/NSDocument.h</string>
- </object>
- </object>
</object>
</object>
<int key="IBDocument.localizationMode">0</int>
@@ -4348,10 +4284,10 @@
<string>NSMenuCheckmark</string>
<string>NSMenuMixedState</string>
</object>
- <object class="NSMutableArray" key="dict.values">
+ <object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
- <string>{9, 8}</string>
- <string>{7, 2}</string>
+ <string>{11, 11}</string>
+ <string>{10, 3}</string>
</object>
</object>
</data>
View
6 Tools/nib2cib/NSScrollView.j
@@ -41,10 +41,10 @@
[self addSubview:_bottomCornerView];
- var knobStyle = 0;
- try { knobStyle = [aCoder decodeObjectForKey:"NSScrollerKnobStyle"]; } catch (e){}
+ _scrollerKnobStyle = [aCoder decodeObjectForKey:"NSScrollerKnobStyle"];
- [self setScrollerKnobStyle:knobStyle];
+ if (_scrollerKnobStyle === nil)
+ _scrollerKnobStyle = CPScrollerKnobStyleDefault;
_hasVerticalScroller = !!(flags & (1 << 4));
_hasHorizontalScroller = !!(flags & (1 << 5));

0 comments on commit 9830b2b

Please sign in to comment.
Something went wrong with that request. Please try again.