From 802d50d70b29418eaae3c5724fbc73f96f83ee93 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 5 Aug 2007 14:04:34 -0700 Subject: [PATCH] Working around an extremely annoying apple bug in NSTreeController and an NSOutlineView. When the contentArray is bound on an NSTreeController, the observing can go haywire and just crash randomly. * English.lproj/Debugger.nib: Unbinding RegisterController's content array * Source/DebuggerConnection.m: ([DebuggerConnection registerRecieved:]): Sending [_windowController setRegister:] the entire document instead of the rootElement * Source/DebuggerWindowController.h: Removed _register ivar and changed setRegister: to take an NSXMLDocument * Source/DebuggerWindowController.m: ([DebuggerWindowController setRegister:]): Instead of changing a property and letting KVO do the work (and subsequently and randomly crash), force the controller to have new content --- English.lproj/Debugger.nib/keyedobjects.nib | Bin 16828 -> 16676 bytes Source/DebuggerConnection.m | 2 +- Source/DebuggerWindowController.h | 3 +-- Source/DebuggerWindowController.m | 24 +++++++++++++------- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/English.lproj/Debugger.nib/keyedobjects.nib b/English.lproj/Debugger.nib/keyedobjects.nib index 191f5ec6e84574e32bc71e010dc4962423680c27..16861e8125f57d210f2d64e02900f1628c085992 100644 GIT binary patch delta 6019 zcmZWr2Y3`!*WTIOneDr?z4zW`X6I4@k=|P9***cQeg~V8kImjNcqbN5 z2aQ1!&;qmt?La5c8DxWQpa;kWy}@8G7EA>1f=S>#Fd0k%Q^9ml0cL^OU=ElI=7VLR z3M>cJU=14Af{(!_G;Ri;f*ol59P9*pz+P|w90W(fF>o530T;kUa0Oficfb>*@dtPg z{=|84oR6pB02kmwT!f2pC8)wxxEeR1(TrPgHyS;-7o5gJIE^!SZM+Vifxm$_!JFc( z@YeVMd=UOFz6Ae_KZpMVz7_v3z75-iZ^w7wpW{2x$``x`_%8fQd^f%a-^-ta@HoVJ3TcRD&p6Ebi5*>+7L}#K4kwtVR z-XyY#ZbS~zo#>IwOtYBylZbp`FfoKEAchi!L=iEJC??8?5ya??i_->UzD5bGGJ$nZ zU_B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r_(%Cm{Wbo{ z{zd-n{+<5a{x|%4{rmj;{g?gM{PzO7fFWQG*aFUgJKzmG6&MlV0#gIe2WAE0a{_Y% z^8(uf#{-Rln}Kfvw*x-}ehT~?R0Tu9*1@*H>|jnXH<%YJ3>F1P21fMWufOoOGCRtyF+h=_QpeRh4zQu2^|g{4ZR;a8~QYKIdnC2Ep$C}JM>fNVHkw* zuso~{+rs{EX1E|cG(0{$H#|R_4A+O3hL?v|gx?OI3;!7YIs9w*Uid-yVFZh~B5fms zB10m>A|oQBB4Z-sB6B0JMh-*{Mc#`Xi=2p@jGT^q8%>Lyoek@7L%jN60(%6A)h6uk#Ca+$alzh z$@j>kDxWH#`cng`A=IciRYxtMmQyRK zSE;qs2I_Tc3)MjFr1nsIskfNxcQb(;E!I!9fgE>SnBpJQn;P0SIC##+ZZ z#(Ks2$414fVu{$|*t*!(*tXb?*uL1?v4gSWbOxPCx1rn7Idm@FiSA5yqkGW3=st8m zdH_9$9zqw=@gjNzT}+RrOXyO%jIN-o=?U~R^t1F7I!;fer_(d(+4LOxC3*q9h_0uX z(97wS^eTEay_ViUZ=^TVTj>UR2fd4agWgN;qYu!>n3hZ?)0W9*IxwA>E=+f(CzH<< zFawyuOd&IzDQ3nnR1C?WMVC>jdidt*2DVP02^W> zEXl@LhHb{SU^CcEwhf!bX0thLE}O^pV0*Cx*+J}3b~HPN9miI)6M0P^KL62*zwl^% I{L9YzKLtAzOaK4? diff --git a/Source/DebuggerConnection.m b/Source/DebuggerConnection.m index 32fb186..a8cd955 100644 --- a/Source/DebuggerConnection.m +++ b/Source/DebuggerConnection.m @@ -263,7 +263,7 @@ - (void)registerReceived: (NSData *)packet { NSXMLDocument *doc = [[NSXMLDocument alloc] initWithData: packet options: NSXMLDocumentTidyXML error: nil]; - [_windowController setRegister: [doc rootElement]]; + [_windowController setRegister: doc]; [doc release]; } diff --git a/Source/DebuggerWindowController.h b/Source/DebuggerWindowController.h index 26a20fc..e8cfea5 100644 --- a/Source/DebuggerWindowController.h +++ b/Source/DebuggerWindowController.h @@ -25,7 +25,6 @@ IBOutlet NSArrayController *_stackController; NSArray *_stack; - NSXMLElement *_register; IBOutlet NSTreeController *_registerController; IBOutlet NSTextField *_status; @@ -45,7 +44,7 @@ - (void)setStatus: (NSString *)status; - (void)setError: (NSString *)error; - (void)setStack: (NSArray *)node; -- (void)setRegister: (NSXMLElement *)reg; +- (void)setRegister: (NSXMLDocument *)reg; - (void)addChildren: (NSArray *)children toNode: (id)node; diff --git a/Source/DebuggerWindowController.m b/Source/DebuggerWindowController.m index 86482f8..897ea82 100644 --- a/Source/DebuggerWindowController.m +++ b/Source/DebuggerWindowController.m @@ -123,15 +123,23 @@ /** * Sets the stack root element so that the NSOutlineView can display it */ -- (void)setRegister: (NSXMLElement *)elm +- (void)setRegister: (NSXMLDocument *)elm { - if (_register != nil) - { - [_register release]; - } - - _register = elm; - [_register retain]; + /* + [_registerController willChangeValueForKey: @"rootElement.children"]; + [_registerController unbind: @"contentArray"]; + [_registerController bind: @"contentArray" toObject: elm withKeyPath: @"rootElement.children" options: nil]; + [_registerController didChangeValueForKey: @"rootElement.children"]; + */ + // XXX: Doing anything short of this will cause bindings to crash spectacularly for no reason whatsoever, and + // in seemingly arbitrary places. The class that crashes is _NSKeyValueObservationInfoCreateByRemoving. + // http://boredzo.org/blog/archives/2006-01-29/have-you-seen-this-crash says that this means nothing is + // being observed, but I doubt that he was using an NSOutlineView which seems to be one f!cking piece of + // sh!t when used with NSTreeController. http://www.cocoadev.com/index.pl?NSTreeControllerBugOrDeveloperError + // was the inspiration for this fix (below) but the author says that inserting does not work too well, but + // that's okay for us as we just need to replace the entire thing. + [_registerController setContent: nil]; + [_registerController setContent: [[elm rootElement] children]]; } /** -- 2.43.5