From 33c4d25f190d4ac0ffa079dfa3620fc4e5d3b54e Mon Sep 17 00:00:00 2001 From: Jordan Lee Date: Sun, 23 Sep 2012 15:38:07 +0000 Subject: [PATCH] fix a handful of console warnings that were generated by trying to trash a NULL .torrent file b/c the torrent had been added from a URL --- gtk/tr-core.c | 11 +++++++---- gtk/util.c | 6 +++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/gtk/tr-core.c b/gtk/tr-core.c index 3319c2f93..f30ce95f3 100644 --- a/gtk/tr-core.c +++ b/gtk/tr-core.c @@ -984,11 +984,14 @@ core_create_new_torrent( TrCore * core, tr_ctor * ctor ) { const char * config = tr_sessionGetConfigDir( session ); const char * source = tr_ctorGetSourceFile( ctor ); - const int is_internal = source && ( strstr( source, config ) == source ); - /* #1294: don't delete the .torrent file if it's our internal copy */ - if( !is_internal ) - gtr_file_trash_or_remove( source ); + if( source != NULL ) + { + /* #1294: don't delete the .torrent file if it's our internal copy */ + const int is_internal = ( strstr( source, config ) == source ); + if( !is_internal ) + gtr_file_trash_or_remove( source ); + } } return tor; diff --git a/gtk/util.c b/gtk/util.c index 142781104..8e669ba72 100644 --- a/gtk/util.c +++ b/gtk/util.c @@ -299,8 +299,12 @@ on_tree_view_button_released( GtkWidget * view, int gtr_file_trash_or_remove( const char * filename ) { + GFile * file; gboolean trashed = FALSE; - GFile * file = g_file_new_for_path( filename ); + + g_return_val_if_fail (filename && *filename, 0); + + file = g_file_new_for_path( filename ); if( gtr_pref_flag_get( PREF_KEY_TRASH_CAN_ENABLED ) ) { GError * err = NULL; -- 2.40.0