Commit 2d09517e authored by David Fuhrmann's avatar David Fuhrmann Committed by Felix Paul Kühne

macosx: fix memleaks in podcast handling, remove unnecessary module restart

(cherry picked from commit 3788f1cb25bea9f38d19a22e496474bfdd5a6ef1)
Signed-off-by: default avatarFelix Paul Kühne <fkuehne@videolan.org>
parent ccaac06a
...@@ -1279,11 +1279,13 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -1279,11 +1279,13 @@ static VLCMainWindow *_o_sharedInstance = nil;
- (IBAction)removePodcast:(id)sender - (IBAction)removePodcast:(id)sender
{ {
if (config_GetPsz(VLCIntf, "podcast-urls") != NULL) { char *psz_urls = var_InheritString(pl_Get(VLCIntf), "podcast-urls");
if (psz_urls != NULL) {
[o_podcast_unsubscribe_pop removeAllItems]; [o_podcast_unsubscribe_pop removeAllItems];
[o_podcast_unsubscribe_pop addItemsWithTitles:[[NSString stringWithUTF8String:config_GetPsz(VLCIntf, "podcast-urls")] componentsSeparatedByString:@"|"]]; [o_podcast_unsubscribe_pop addItemsWithTitles:[toNSStr(psz_urls) componentsSeparatedByString:@"|"]];
[NSApp beginSheet:o_podcast_unsubscribe_window modalForWindow:self modalDelegate:self didEndSelector:NULL contextInfo:nil]; [NSApp beginSheet:o_podcast_unsubscribe_window modalForWindow:self modalDelegate:self didEndSelector:NULL contextInfo:nil];
} }
free(psz_urls);
} }
- (IBAction)removePodcastWindowAction:(id)sender - (IBAction)removePodcastWindowAction:(id)sender
...@@ -1292,17 +1294,20 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -1292,17 +1294,20 @@ static VLCMainWindow *_o_sharedInstance = nil;
[NSApp endSheet: o_podcast_unsubscribe_window]; [NSApp endSheet: o_podcast_unsubscribe_window];
if (sender == o_podcast_unsubscribe_ok_btn) { if (sender == o_podcast_unsubscribe_ok_btn) {
playlist_t * p_playlist = pl_Get(VLCIntf);
char *psz_urls = var_InheritString(p_playlist, "podcast-urls");
NSMutableArray * urls = [[NSMutableArray alloc] initWithArray:[[NSString stringWithUTF8String:config_GetPsz(VLCIntf, "podcast-urls")] componentsSeparatedByString:@"|"]]; NSMutableArray * urls = [[NSMutableArray alloc] initWithArray:[[NSString stringWithUTF8String:config_GetPsz(VLCIntf, "podcast-urls")] componentsSeparatedByString:@"|"]];
[urls removeObjectAtIndex: [o_podcast_unsubscribe_pop indexOfSelectedItem]]; [urls removeObjectAtIndex: [o_podcast_unsubscribe_pop indexOfSelectedItem]];
config_PutPsz(VLCIntf, "podcast-urls", [[urls componentsJoinedByString:@"|"] UTF8String]); const char *psz_new_urls = [[urls componentsJoinedByString:@"|"] UTF8String];
var_SetString(pl_Get(VLCIntf), "podcast-urls", config_GetPsz(VLCIntf, "podcast-urls")); var_SetString(pl_Get(VLCIntf), "podcast-urls", psz_new_urls);
config_PutPsz(VLCIntf, "podcast-urls", psz_new_urls);
[urls release]; [urls release];
/* reload the podcast module, since it won't update its list when removing podcasts */ free(psz_urls);
playlist_t * p_playlist = pl_Get(VLCIntf);
/* update playlist table */
if (playlist_IsServicesDiscoveryLoaded(p_playlist, "podcast{longname=\"Podcasts\"}")) { if (playlist_IsServicesDiscoveryLoaded(p_playlist, "podcast{longname=\"Podcasts\"}")) {
playlist_ServicesDiscoveryRemove(p_playlist, "podcast{longname=\"Podcasts\"}");
playlist_ServicesDiscoveryAdd(p_playlist, "podcast{longname=\"Podcasts\"}");
[[[VLCMain sharedInstance] playlist] playlistUpdated]; [[[VLCMain sharedInstance] playlist] playlistUpdated];
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment