Permalink
Browse files

fixing some mem leaks, adding KVO to SMFComplexDropShadowControl

  • Loading branch information...
1 parent b2b8ac3 commit c66a493e225958ca34207a09c8c06c00161aad78 @tomcool420 committed Mar 3, 2011
@@ -39,7 +39,7 @@ -(NSMutableDictionary *)getInformation
t = [self.asset mediaSummary];
if (t!=nil) {[d setObject:t forKey:kSMFMovieSummary];}
if ([asset respondsToSelector:@selector(coverArt)]) {
- BRImage *i = [self.asset coverArt];
+ BRImage *i = [(BRPhotoMediaAsset *)self.asset coverArt];
if (i==nil) [d setObject:i forKey:kSMFMoviePoster];
}
@@ -24,8 +24,12 @@
BRListControl *_list;
NSObject *delegate;
}
-@property(retain)NSString *title;
-@property(retain)NSString *subtitle;
+/*
+ * If you want to change the title and subtitle while the control is up,
+ * you can just change the two properties
+ */
+@property(copy)NSString *title;
+@property(copy)NSString *subtitle;
@property(readonly,assign)SMFProgressBarControl *progress;
@property(readwrite,assign)BOOL blocking;
@property(readwrite,assign)NSObject *delegate;
@@ -41,6 +45,6 @@
-(void)setBlocking:(BOOL)blocking;
-(BOOL)blocking;
-(id)attributedStringForString:(NSString*)s;
-- (void)updateSubtitle:(NSString *)t;
-- (void)updateTitle:(NSString *)t;
+-(void)updateHeader;
+
@end
@@ -34,6 +34,8 @@ -(id)init
self.subtitle=@" ";
[self setContent:_bg];
_text=[[NSMutableString alloc] initWithString:@" "];
+ [self addObserver:self forKeyPath:@"title" options:0 context:nil];
+ [self addObserver:self forKeyPath:@"subtitle" options:0 context:nil];
return self;
}
-(void)addToController:(BRController *)ctrl
@@ -46,6 +48,20 @@ -(void)addToController:(BRController *)ctrl
[ctrl _setFocus:self];
}
+- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)o change:(NSDictionary *)change context:(void *)context
+{
+ if (o==self && [keyPath isEqualToString:@"title"]) {
+ NSLog(@"changing title");
+ [_titleControl setTitle:_title];
+ [_titleControl layoutSubcontrols];
+ }
+ else if(o==self && [keyPath isEqualToString:@"subtitle"])
+ {
+ NSLog(@"changing subtitle");
+ [_titleControl setTitleSubtext:_subtitle];
+ [_titleControl layoutSubcontrols];
+ }
+}
-(void)reload
{
[_bg _removeAllControls];
@@ -129,18 +145,23 @@ -(BOOL)showsWaitSpinner
{
return _showWaitSpinner;
}
-
-- (void)updateTitle:(NSString *)t
-{
- _title = t;
- [self reload];
-}
-
-- (void)updateSubtitle:(NSString *)t
+-(void)updateHeader
{
- _subtitle = t;
- [self reload];
+ [_titleControl setTitle:_title];
+ [_titleControl setTitleSubtext:_subtitle];
+ [_titleControl layoutSubcontrols];
}
+//- (void)updateTitle:(NSString *)t
+//{
+// _title = t;
+// [self reload];
+//}
+//
+//- (void)updateSubtitle:(NSString *)t
+//{
+// _subtitle = t;
+// [self reload];
+//}
-(void)dealloc
{
@@ -156,6 +177,8 @@ -(void)dealloc
_spinner = nil;
_list=nil;
+ [self removeObserver:self forKeyPath:@"title"];
+ [self removeObserver:self forKeyPath:@"subtitle"];
self.title=nil;
self.subtitle=nil;
[super dealloc];
@@ -14,7 +14,7 @@
BOOL finished;
int returnCode;
}
-@property (readwrite,retain)NSString *ap;
+@property (readwrite,copy)NSString *ap;
@property (readonly) int returnCode;
@property (readonly) BOOL finished;
@end
@@ -30,6 +30,11 @@ -(void)controlWasActivated
[super controlWasActivated];
[self performSelectorInBackground:@selector(runProcess) withObject:nil];
}
+-(void)dealloc
+{
+ self.ap=nil;
+ [super dealloc];
+}
-(int)runProcess
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
View
@@ -156,11 +156,11 @@ -(BRControl *)controlForImageProxy:(BRURLImageProxy *)imageProxy title:(NSString
returnObj.titleWidthScale=1.3999999761581421;
returnObj.titleVerticalOffset=-0.054999999701976776;
returnObj.reflectionAmount=0.14000000059604645;
- return returnObj;
+ return [returnObj autorelease];
}
else {
BRAsyncImageControl *returnObj = [BRAsyncImageControl imageControlWithImageProxy:imageProxy];
-#warning did not test this one, but seemed to make sense for it to use the proxy too ^^
+//#warning did not test this one, but seemed to make sense for it to use the proxy too ^^
[returnObj setAcceptsFocus:YES];
return returnObj;
}
@@ -347,7 +347,7 @@ -(void)reload
checkNil(_buttons);
_buttons=[[NSMutableArray alloc]init];
- NSArray *buttons=[NSArray array];
+ NSArray *buttons=nil;//[NSArray array];
if ([self.datasource respondsToSelector:@selector(buttons)]) {
buttons = [self.datasource buttons];
}
View
@@ -269,7 +269,7 @@ static int IOSurfaceAcceleratorSave(NSString *path, IOSurfaceID searchId,int min
}
BOOL d = [imageData writeToFile:path atomically:YES];
if (d) {
- NSLog("IOSurface was successfully written to %@",path);
+ NSLog(@"IOSurface was successfully written to %@",path);
}
else {
NSLog(@"image not saved");
View
@@ -1,6 +1,6 @@
Package: org.tomcool.smframework
Name: SMFramework
-Version: 0.7.0
+Version: 0.7.2b
Architecture: iphoneos-arm
Description: Framework for most packages written by me
Maintainer: Thomas Cool <thomas.cool@me.com>

0 comments on commit c66a493

Please sign in to comment.