Changeset 6fba236cbc4be069c84a70d81c0cbb8f46e9552b

Show
Ignore:
Timestamp:
02/13/08 19:57:32 (6 months ago)
Author:
Pierre d'Herbemont <pdherbemont@videolan.org>
git-committer:
Pierre d'Herbemont <pdherbemont@videolan.org> 1202929052 +0000
git-parent:

[d206ed68debdf3b71866e730d6b494ed9b121be1]

git-author:
Pierre d'Herbemont <pdherbemont@videolan.org> 1202929052 +0000
Message:

macosx/framework: Correctly set the children of the nodes.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • projects/macosx/framework/Sources/VLCMediaListAspect.m

    rb3372f1 r6fba236  
    4444 
    4545@implementation VLCMediaListAspectNode 
     46- (id)init 
     47{ 
     48    if(self = [super init]) 
     49    { 
     50        media = nil; 
     51        children = nil;         
     52    } 
     53    return self; 
     54} 
     55- (void)dealloc 
     56{ 
     57    [media release]; 
     58    [children release]; 
     59    [super dealloc]; 
     60} 
     61 
    4662@synthesize media; 
    4763@synthesize children; 
     
    4965- (BOOL)isLeaf 
    5066{ 
    51     return self.children == NULL; 
    52 
    53  
    54 -(void)dealloc 
    55 
    56     [self.children release]; 
    57     [super dealloc]; 
    58 
     67    return self.children == nil; 
     68
     69 
    5970@end 
    6071 
     
    114125    [super dealloc]; 
    115126} 
     127 
     128- (void)release 
     129{ 
     130    @synchronized(self) 
     131    { 
     132        if([self retainCount] <= 1) 
     133        { 
     134            /* We must make sure we won't receive new event after an upcoming dealloc 
     135             * We also may receive a -retain in some event callback that may occcur 
     136             * Before libvlc_event_detach. So this can't happen in dealloc */ 
     137            libvlc_event_manager_t * p_em = libvlc_media_list_view_event_manager(p_mlv); 
     138            libvlc_event_detach(p_em, libvlc_MediaListViewItemDeleted, HandleMediaListViewItemDeleted, self, NULL); 
     139            libvlc_event_detach(p_em, libvlc_MediaListViewItemAdded,   HandleMediaListViewItemAdded,   self, NULL); 
     140        } 
     141        [super release]; 
     142    } 
     143} 
     144 
    116145- (NSString *)description 
    117146{ 
     
    156185    VLCMediaListAspectNode * node = [[[VLCMediaListAspectNode alloc] init] autorelease]; 
    157186    [node setMedia:[self mediaAtIndex: index]]; 
     187    libvlc_media_list_view_t * p_sub_mlv = libvlc_media_list_view_children_for_item([self libVLCMediaListView], [node.media libVLCMediaDescriptor], NULL); 
     188    if( p_sub_mlv ) 
     189    { 
     190        [node setChildren:[VLCMediaListAspect mediaListAspectWithLibVLCMediaListView: p_sub_mlv]]; 
     191        libvlc_media_list_view_release(p_sub_mlv); 
     192    } 
    158193    return node; 
    159194} 
     
    219254            [node setMedia:[VLCMedia mediaWithLibVLCMediaDescriptor: p_md]]; 
    220255            [node setChildren: p_sub_mlv ? [VLCMediaListAspect mediaListAspectWithLibVLCMediaListView: p_sub_mlv] : nil]; 
     256            if( p_sub_mlv ) NSAssert(![node isLeaf], @"Not leaf"); 
     257 
    221258            [cachedNode addObject:node]; 
    222259            libvlc_media_descriptor_release(p_md); 
     
    267304        VLCMediaListAspectNode * node = [[[VLCMediaListAspectNode alloc] init] autorelease]; 
    268305        [node setMedia:media]; 
    269         [node setChildren:[self childrenAtIndex:index]]; 
     306 
     307        /* Set the sub media list view we enventually have */ 
     308        libvlc_media_list_view_t * p_sub_mlv = libvlc_media_list_view_children_for_item([self libVLCMediaListView], [media libVLCMediaDescriptor], NULL); 
     309 
     310        if( p_sub_mlv ) 
     311        { 
     312            [node setChildren:[VLCMediaListAspect mediaListAspectWithLibVLCMediaListView: p_sub_mlv]]; 
     313            libvlc_media_list_view_release(p_sub_mlv); 
     314            NSAssert(![node isLeaf], @"Not leaf"); 
     315        } 
     316 
    270317        /* Sanity check */ 
    271318        if( index && index > [cachedNode count] )