View Single Post
Spira,

Until Tim has a chance to push to master, here's a patch that fixes the assertions:

Code:
Index: OUIEditableFrame.h
===================================================================
--- OUIEditableFrame.h	(revision 154259)
+++ OUIEditableFrame.h	(working copy)
@@ -94,6 +94,7 @@
         // Information about our content
         unsigned immutableContentHasAttributeTransforms:1;     // False if our -attributedText isn't a simple subrange of immutableContent
         unsigned mayHaveBackgroundRanges:1;                    // True unless we know we don't have any ... .
+        unsigned loadingFromNib:1; // Set in initWithCoder. Used to delay registration for scroll notifications until after any parent view's delegates have been set.
     } flags;
     
     // Range selection adjustment and display
Index: OUIEditableFrame.m
===================================================================
--- OUIEditableFrame.m	(revision 154259)
+++ OUIEditableFrame.m	(working copy)
@@ -243,6 +243,7 @@
     self->flags.textNeedsUpdate = 1;
     self->flags.delegateRespondsToLayoutChanged = 0;
     self->flags.showSelectionThumbs = 1;
+    self->flags.loadingFromNib = 0;
     self->selectionDirtyRect = CGRectNull;
     self->markedTextDirtyRect = CGRectNull;
     
@@ -279,7 +280,9 @@
 {
     if (!(self = [super initWithCoder:aDecoder]))
         return nil;
-    return do_init(self);
+    id result = do_init(self);
+    flags.loadingFromNib = YES;
+    return result;
 }
 
 #pragma mark -
@@ -1783,7 +1786,8 @@
 {
     [super didMoveToSuperview];
     DEBUG_SCROLL(@"%s with superview: %@%p", __func__, [self.superview class], self.superview);
-    isRegisteredForScrollNotifications = OUIRegisterForScrollNotificationsAboveView(self);
+    if (!flags.loadingFromNib) // delay if loading from nib
+        isRegisteredForScrollNotifications = OUIRegisterForScrollNotificationsAboveView(self);
 }
 
 - (void)didMoveToWindow
@@ -1803,6 +1807,12 @@
 
     if (!_content)
         [self setAttributedText:nil]; // Triggers all our sanity-ensuring checks
+    
+    if (flags.loadingFromNib) {        
+        // was delayed if loading from nib
+        isRegisteredForScrollNotifications = OUIRegisterForScrollNotificationsAboveView(self);
+        flags.loadingFromNib = NO;
+    }
 }
 
 - (void)setFrame:(CGRect)newFrame
Our internal uses of OUIEditableFrame were all constructing the view programmatically and I missed checking the case where we got the view from a nib.

I'm confused about the missing functions in OUIExportOptionsController. They're there in the current master starting at line 360 of OUIExportOptionsController.m. A fresh pull compiles fine for me. (Xcode 4.2 beta 5, 10.7.2 build 11C35)
__________________
Cheers,

Curt