Changeset 6fba236cbc4be069c84a70d81c0cbb8f46e9552b
- 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
| rb3372f1 |
r6fba236 |
|
| 44 | 44 | |
|---|
| 45 | 45 | @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 | |
|---|
| 46 | 62 | @synthesize media; |
|---|
| 47 | 63 | @synthesize children; |
|---|
| … | … | |
| 49 | 65 | - (BOOL)isLeaf |
|---|
| 50 | 66 | { |
|---|
| 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 | |
|---|
| 59 | 70 | @end |
|---|
| 60 | 71 | |
|---|
| … | … | |
| 114 | 125 | [super dealloc]; |
|---|
| 115 | 126 | } |
|---|
| | 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 | |
|---|
| 116 | 145 | - (NSString *)description |
|---|
| 117 | 146 | { |
|---|
| … | … | |
| 156 | 185 | VLCMediaListAspectNode * node = [[[VLCMediaListAspectNode alloc] init] autorelease]; |
|---|
| 157 | 186 | [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 | } |
|---|
| 158 | 193 | return node; |
|---|
| 159 | 194 | } |
|---|
| … | … | |
| 219 | 254 | [node setMedia:[VLCMedia mediaWithLibVLCMediaDescriptor: p_md]]; |
|---|
| 220 | 255 | [node setChildren: p_sub_mlv ? [VLCMediaListAspect mediaListAspectWithLibVLCMediaListView: p_sub_mlv] : nil]; |
|---|
| | 256 | if( p_sub_mlv ) NSAssert(![node isLeaf], @"Not leaf"); |
|---|
| | 257 | |
|---|
| 221 | 258 | [cachedNode addObject:node]; |
|---|
| 222 | 259 | libvlc_media_descriptor_release(p_md); |
|---|
| … | … | |
| 267 | 304 | VLCMediaListAspectNode * node = [[[VLCMediaListAspectNode alloc] init] autorelease]; |
|---|
| 268 | 305 | [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 | |
|---|
| 270 | 317 | /* Sanity check */ |
|---|
| 271 | 318 | if( index && index > [cachedNode count] ) |
|---|