Re: NSSearchField crash
Re: NSSearchField crash
- Subject: Re: NSSearchField crash
- From: Michael Rothwell <email@hidden>
- Date: Sun, 6 Feb 2005 19:16:26 -0500
Hm. What string would that be, I wonder. From what I can see,
NSSearchField emits "controlTextDidChange" messages. I listen to those,
in order to set the state of a button, save the current search criteria
in a dictionary (called 'search' in the code below), and notify other
parts of the program that the user wishes to search for something.
Those other parts take the data in the dictionary (currently three
search keys, one being the string value of the search field) and act on
them. Running queries, for example. I'm not providing NSSearchField
with a pointer to anything while doing this. The backtrace indicates
that the crash is happening in relation to the drawing of the
searchfield. It looks like the crash involves NSSearchFieldCell,
NSStringDrawingTextStorage, etc. Am I messing up memory by taking the
stringValue of the search field and shipping it around? Should I copy
the string first?
/**
* controlTextDidChange
*/
- (void)controlTextDidChange:(NSNotification *)aNotification
{
NSString *ss = [searchField stringValue];
if ([ss length]>0)
[saveButton setEnabled:YES];
else
[saveButton setEnabled:NO];
[search setObject:ss forKey:@"val"];
[self notifyForSearch];
};
/**
* notifyForSearch
*/
-(void)notifyForSearch
{
[[NSNotificationCenter defaultCenter]
postNotificationName:@"MRSearchBy"
object:self
userInfo:search ];
};
Michael Rothwell
email@hidden
On Feb 6, 2005, at 5:41 PM, Thomas Davie wrote:
It looks like you've double-freed a string that the search field still
needed access to.
Bob
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden