[vlc-commits] macosx/playlist: add another sanity check and simplify the code a bit
Felix Paul Kühne
git at videolan.org
Wed Aug 22 18:18:01 CEST 2012
vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Wed Aug 22 18:07:21 2012 +0200| [1c2af88fd9d41ffb379ff4de6f59565f16d1df0e] | committer: Felix Paul Kühne
macosx/playlist: add another sanity check and simplify the code a bit
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1c2af88fd9d41ffb379ff4de6f59565f16d1df0e
---
modules/gui/macosx/playlist.m | 30 ++++++++++--------------------
1 file changed, 10 insertions(+), 20 deletions(-)
diff --git a/modules/gui/macosx/playlist.m b/modules/gui/macosx/playlist.m
index d0f5466..a5214da 100644
--- a/modules/gui/macosx/playlist.m
+++ b/modules/gui/macosx/playlist.m
@@ -672,15 +672,14 @@
deleted. We don't do it when not required since this verification takes
quite a long time on big playlists (yes, pretty hacky). */
-- (BOOL)isItem: (playlist_item_t *)p_item
- inNode: (playlist_item_t *)p_node
- checkItemExistence:(BOOL)b_check
- locked:(BOOL)b_locked
-
+- (BOOL)isItem: (playlist_item_t *)p_item inNode: (playlist_item_t *)p_node checkItemExistence:(BOOL)b_check locked:(BOOL)b_locked
{
playlist_t * p_playlist = pl_Get( VLCIntf );
playlist_item_t *p_temp_item = p_item;
+ if (!p_node)
+ return NO;
+
if( p_node == p_item )
return YES;
@@ -699,7 +698,8 @@
in the playlist. Any cleaner solution welcomed. */
for( i = 0; i < p_playlist->all_items.i_size; i++ )
{
- if( ARRAY_VAL( p_playlist->all_items, i) == p_item ) break;
+ if( ARRAY_VAL( p_playlist->all_items, i) == p_item )
+ break;
else if ( i == p_playlist->all_items.i_size - 1 )
{
if(!b_locked) PL_UNLOCK;
@@ -722,13 +722,6 @@
return NO;
}
-- (BOOL)isItem: (playlist_item_t *)p_item
- inNode: (playlist_item_t *)p_node
- checkItemExistence:(BOOL)b_check
-{
- return [self isItem:p_item inNode:p_node checkItemExistence:b_check locked:NO];
-}
-
/* This method is useful for instance to remove the selected children of an
already selected node */
- (void)removeItemsFrom:(id)o_items ifChildrenOf:(id)o_nodes
@@ -1459,8 +1452,7 @@
o_playing_item = [o_outline_dict objectForKey: [NSString stringWithFormat:@"%p", playlist_CurrentPlayingItem( p_playlist )]];
PL_UNLOCK;
- if( [self isItem: [o_playing_item pointerValue] inNode:
- [item pointerValue] checkItemExistence: YES]
+ if( [self isItem: [o_playing_item pointerValue] inNode: [item pointerValue] checkItemExistence:YES locked:NO]
|| [o_playing_item isEqual: item] )
{
[cell setFont: [[NSFontManager sharedFontManager] convertFont:[cell font] toHaveTrait:NSBoldFontMask]];
@@ -1604,8 +1596,8 @@
/* We refuse to drop an item in anything else than a child of the General
Node. We still accept items that would be root nodes of the outlineview
however, to allow drop in an empty playlist. */
- if( !( ([self isItem: [item pointerValue] inNode: p_playlist->p_local_category checkItemExistence: NO] ||
- ( var_CreateGetBool( p_playlist, "media-library" ) && [self isItem: [item pointerValue] inNode: p_playlist->p_ml_category checkItemExistence: NO] ) ) || item == nil ) )
+ if( !( ([self isItem: [item pointerValue] inNode: p_playlist->p_local_category checkItemExistence: NO locked: NO] ||
+ ( var_CreateGetBool( p_playlist, "media-library" ) && [self isItem: [item pointerValue] inNode: p_playlist->p_ml_category checkItemExistence: NO locked: NO] ) ) || item == nil ) )
{
return NSDragOperationNone;
}
@@ -1617,9 +1609,7 @@
for( NSUInteger i = 0 ; i < count ; i++ )
{
/* We refuse to Drop in a child of an item we are moving */
- if( [self isItem: [item pointerValue] inNode:
- [[o_nodes_array objectAtIndex: i] pointerValue]
- checkItemExistence: NO] )
+ if( [self isItem: [item pointerValue] inNode: [[o_nodes_array objectAtIndex: i] pointerValue] checkItemExistence: NO locked:NO] )
{
return NSDragOperationNone;
}
More information about the vlc-commits
mailing list