[totem-pl-parser] Fix returning FALSE with no error set in _save()



commit 09b2bae800f5505b65c055ce9fd2f8b8d5daf265
Author: Bastien Nocera <hadess hadess net>
Date:   Wed May 5 12:06:55 2010 +0100

    Fix returning FALSE with no error set in _save()
    
    When the playlist is empty, set an error mentioned why it failed,
    instead of failing silently and not setting the error.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=616538

 plparse/totem-pl-parser.c |    5 +++++
 plparse/totem-pl-parser.h |    4 +++-
 2 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/plparse/totem-pl-parser.c b/plparse/totem-pl-parser.c
index c8b7cec..c3b5fcc 100644
--- a/plparse/totem-pl-parser.c
+++ b/plparse/totem-pl-parser.c
@@ -1128,6 +1128,11 @@ totem_pl_parser_save (TotemPlParser      *parser,
         g_return_val_if_fail (G_IS_FILE (dest), FALSE);
 
         if (totem_pl_playlist_size (playlist) == 0) {
+		/* FIXME add translation */
+		g_set_error (error,
+			     TOTEM_PL_PARSER_ERROR,
+			     TOTEM_PL_PARSER_ERROR_EMPTY_PLAYLIST,
+			     "Playlist selected for saving is empty");
                 return FALSE;
         }
 
diff --git a/plparse/totem-pl-parser.h b/plparse/totem-pl-parser.h
index ffac31d..d5add04 100644
--- a/plparse/totem-pl-parser.h
+++ b/plparse/totem-pl-parser.h
@@ -302,13 +302,15 @@ typedef enum {
  * TotemPlParserError:
  * @TOTEM_PL_PARSER_ERROR_NO_DISC: Error attempting to open a disc device when no disc is present
  * @TOTEM_PL_PARSER_ERROR_MOUNT_FAILED: An attempted mount operation failed
+ * @TOTEM_PL_PARSER_ERROR_EMPTY_PLAYLIST: Playlist to be saved is empty
  *
  * Allows you to differentiate between different
  * errors occurring during file operations in a #TotemPlParser.
  **/
 typedef enum {
 	TOTEM_PL_PARSER_ERROR_NO_DISC,
-	TOTEM_PL_PARSER_ERROR_MOUNT_FAILED
+	TOTEM_PL_PARSER_ERROR_MOUNT_FAILED,
+	TOTEM_PL_PARSER_ERROR_EMPTY_PLAYLIST
 } TotemPlParserError;
 
 #define TOTEM_PL_PARSER_ERROR (totem_pl_parser_error_quark ())



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]