Commit 1c2af88f authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx/playlist: add another sanity check and simplify the code a bit

parent cdd9eec9
...@@ -672,15 +672,14 @@ ...@@ -672,15 +672,14 @@
deleted. We don't do it when not required since this verification takes deleted. We don't do it when not required since this verification takes
quite a long time on big playlists (yes, pretty hacky). */ quite a long time on big playlists (yes, pretty hacky). */
- (BOOL)isItem: (playlist_item_t *)p_item - (BOOL)isItem: (playlist_item_t *)p_item inNode: (playlist_item_t *)p_node checkItemExistence:(BOOL)b_check locked:(BOOL)b_locked
inNode: (playlist_item_t *)p_node
checkItemExistence:(BOOL)b_check
locked:(BOOL)b_locked
{ {
playlist_t * p_playlist = pl_Get( VLCIntf ); playlist_t * p_playlist = pl_Get( VLCIntf );
playlist_item_t *p_temp_item = p_item; playlist_item_t *p_temp_item = p_item;
if (!p_node)
return NO;
if( p_node == p_item ) if( p_node == p_item )
return YES; return YES;
...@@ -699,7 +698,8 @@ ...@@ -699,7 +698,8 @@
in the playlist. Any cleaner solution welcomed. */ in the playlist. Any cleaner solution welcomed. */
for( i = 0; i < p_playlist->all_items.i_size; i++ ) 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 ) else if ( i == p_playlist->all_items.i_size - 1 )
{ {
if(!b_locked) PL_UNLOCK; if(!b_locked) PL_UNLOCK;
...@@ -722,13 +722,6 @@ ...@@ -722,13 +722,6 @@
return NO; 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 /* This method is useful for instance to remove the selected children of an
already selected node */ already selected node */
- (void)removeItemsFrom:(id)o_items ifChildrenOf:(id)o_nodes - (void)removeItemsFrom:(id)o_items ifChildrenOf:(id)o_nodes
...@@ -1459,8 +1452,7 @@ ...@@ -1459,8 +1452,7 @@
o_playing_item = [o_outline_dict objectForKey: [NSString stringWithFormat:@"%p", playlist_CurrentPlayingItem( p_playlist )]]; o_playing_item = [o_outline_dict objectForKey: [NSString stringWithFormat:@"%p", playlist_CurrentPlayingItem( p_playlist )]];
PL_UNLOCK; PL_UNLOCK;
if( [self isItem: [o_playing_item pointerValue] inNode: if( [self isItem: [o_playing_item pointerValue] inNode: [item pointerValue] checkItemExistence:YES locked:NO]
[item pointerValue] checkItemExistence: YES]
|| [o_playing_item isEqual: item] ) || [o_playing_item isEqual: item] )
{ {
[cell setFont: [[NSFontManager sharedFontManager] convertFont:[cell font] toHaveTrait:NSBoldFontMask]]; [cell setFont: [[NSFontManager sharedFontManager] convertFont:[cell font] toHaveTrait:NSBoldFontMask]];
...@@ -1604,8 +1596,8 @@ ...@@ -1604,8 +1596,8 @@
/* We refuse to drop an item in anything else than a child of the General /* 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 Node. We still accept items that would be root nodes of the outlineview
however, to allow drop in an empty playlist. */ however, to allow drop in an empty playlist. */
if( !( ([self isItem: [item pointerValue] inNode: p_playlist->p_local_category checkItemExistence: NO] || 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] ) ) || item == nil ) ) ( var_CreateGetBool( p_playlist, "media-library" ) && [self isItem: [item pointerValue] inNode: p_playlist->p_ml_category checkItemExistence: NO locked: NO] ) ) || item == nil ) )
{ {
return NSDragOperationNone; return NSDragOperationNone;
} }
...@@ -1617,9 +1609,7 @@ ...@@ -1617,9 +1609,7 @@
for( NSUInteger i = 0 ; i < count ; i++ ) for( NSUInteger i = 0 ; i < count ; i++ )
{ {
/* We refuse to Drop in a child of an item we are moving */ /* We refuse to Drop in a child of an item we are moving */
if( [self isItem: [item pointerValue] inNode: if( [self isItem: [item pointerValue] inNode: [[o_nodes_array objectAtIndex: i] pointerValue] checkItemExistence: NO locked:NO] )
[[o_nodes_array objectAtIndex: i] pointerValue]
checkItemExistence: NO] )
{ {
return NSDragOperationNone; return NSDragOperationNone;
} }
......
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