Re: Crashes while reordering columns in a NSTableView
Re: Crashes while reordering columns in a NSTableView
- Subject: Re: Crashes while reordering columns in a NSTableView
- From: Tim Schmidt <email@hidden>
- Date: Tue, 21 Jul 2009 13:58:27 PDT
First of all, thanks a lot for all the effort! Seems my original
message was to long, so here is the shortened version:
There is also considerable "artifacting" during column drags and
resizing operations (also unaffected cells are often not redrawn
correctly after resizing, leading me to believe that quite a bit of
CG's pixmaps get corrupted (while none of the underlying model changes
in any way)
On Jul 21, 2009, at 9:40 AM, I. Savant wrote:
On Jul 21, 2009, at 12:32 PM, Tim Schmidt wrote:
Obviously CG's bitblock transfers access unallocated memory in this
case. If I accidently free said memory it completely eludes me
where this might happen (I am pretty confident I don't release any
of my model/controller objects unintentionally (I tried running
with all the usual mallocdebug options as well as NSZombies).
Furthermore all NIBs are managed by NSViewController subclasses.
Can anybody point me to some advanced guides on NSTableView (beyond
the class reference and tables guide).
I'll assume you're not customizing the drag and drop process (or
doing anything with the column drag delegate method).
No
My own intuition tells me you might look into your cells. If you
have any custom (header or data) cells for the column(s) involved or
do any custom manipulation of those cells (such as
with ...willDisplayCell:...) that'd be a place to start looking for
memory management no-nos. Especially if it only happens with
particular columns.
There are no custom cells involved so far
Also, if you're using the table datasource protocol, it's possible
your ...objectValue... datasource method is returning an improperly-
managed instance of something or other.
I do provide a datasource (I also understand that NSTableView only
maintains a weak link to said datasource). What would an "improperly-
managed" instance comprise of in this context. (I assume the
associated NSCell subclass attains ownership of what is supplied by
objectValueFor...)
Code here
- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:
(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
{
NSAssert([aTableView isEqual:table_], @"nib consistency");
PEDElement *source = [pomdp_.states objectAtIndex:rowIndex];
if([[aTableColumn identifier] isEqual:PEDSourcesColumnID])
return source.name;
NSString *keyPath=[NSString stringWithFormat:@"%@.%@.%@",[self
valueForKeyPath:@"content.fingerprint"], [source fingerprint],
[[aTableColumn identifier]
respondsToSelector:@selector(fingerprint)] ? [[aTableColumn
identifier] fingerprint] : PEDResidualKey];
return [pomdp_.transitionModel valueForKeyPath:keyPath];
}
If you're doing anything custom, post your code.
The "most" custom thing I do in this instance is dynamically changing
the tableViews columnset at runtime based on some model properties.
(This particular table represents a transition table for a markov
decision process, so when states are added/removed from the model, the
column/row sets have to be adapted accordingly.
Code for this adaptation here: (sorry for the wacky formatting)
-(void) addColumnForState:(PEDElement *)state
{
NSTableColumn *dataColumn=[[[NSTableColumn alloc]
initWithIdentifier:state] autorelease];
[dataColumn bind:@"headerTitle"
toObject:state
withKeyPath:@"name"
options:nil];
[[dataColumn headerCell] setAlignment:NSCenterTextAlignment];
[[dataColumn dataCell] setFormatter:[[[PEDPercentFormatter alloc]
init] autorelease]];
[[dataColumn dataCell] setAlignment:NSRightTextAlignment];
[table_ addTableColumn:dataColumn];
[dataColumn sizeToFit];
// move residual to last position
NSInteger columnCount=[table_ numberOfColumns];
[table_ moveColumn:columnCount-1
toColumn:columnCount-2];
}
-(void) removeColumnForState:(PEDElement *)state
{
NSAssert(state, @"table consistency!");
NSTableColumn *oldColumn=[table_ tableColumnWithIdentifier:state];
NSAssert(oldColumn, @"table consistency!");
[oldColumn unbind:@"headerTitle"];
[table_ removeTableColumn:oldColumn];
}
--
I.S.
On Jul 21, 2009, at 10:32 AM, Tim Schmidt wrote:
Obviously CG's bitblock transfers access unallocated memory in this
case. If I accidently free said memory it completely eludes me
where this might happen (I am pretty confident I don't release any
of my model/controller objects unintentionally (I tried running
with all the usual mallocdebug options as well as NSZombies).
Furthermore all NIBs are managed by NSViewController subclasses.
Can anybody point me to some advanced guides on NSTableView (beyond
the class reference and tables guide).
One thought: Are you using the -CGImage method of NSBitmapImageRep
anywhere? If so, then you absolutely must not deallocate the
NSBitmapImageRep while the CGImageRef is live, because the
CGImageRef acquired via -CGImage is still using the
NSBitmapImageRep's data.
No nothing fancy yet.
Nick Zitzmann
<http://www.chronosnet.com/>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden