[rhythmbox] rhythmdb: allow mountpoint property to be set to NULL



commit d09c18c4c7b40120f384ec8de9d6732aeb123579
Author: Jonathan Matthew <jonathan d14n org>
Date:   Sun Nov 26 19:46:52 2017 +1000

    rhythmdb: allow mountpoint property to be set to NULL

 rhythmdb/rhythmdb.c |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)
---
diff --git a/rhythmdb/rhythmdb.c b/rhythmdb/rhythmdb.c
index 03bd2a0..c007983 100644
--- a/rhythmdb/rhythmdb.c
+++ b/rhythmdb/rhythmdb.c
@@ -3495,11 +3495,15 @@ rhythmdb_entry_set_internal (RhythmDB *db,
        rhythmdb_entry_get (db, entry, propid, &old_value);
        switch (G_VALUE_TYPE (value)) {
        case G_TYPE_STRING:
-#ifndef G_DISABLE_ASSERT
-               /* the playback error is allowed to be NULL */
-               if (propid != RHYTHMDB_PROP_PLAYBACK_ERROR || g_value_get_string (value))
+               /* some properties are allowed to be NULL */
+               switch (propid) {
+               case RHYTHMDB_PROP_PLAYBACK_ERROR:
+               case RHYTHMDB_PROP_MOUNTPOINT:
+                       break;
+               default:
                        g_assert (g_utf8_validate (g_value_get_string (value), -1, NULL));
-#endif
+                       break;
+               }
                if (g_value_get_string (value) && g_value_get_string (&old_value)) {
                        nop = (strcmp (g_value_get_string (value), g_value_get_string (&old_value)) == 0);
                } else {
@@ -3635,8 +3639,11 @@ rhythmdb_entry_set_internal (RhythmDB *db,
                case RHYTHMDB_PROP_MOUNTPOINT:
                        if (entry->mountpoint != NULL) {
                                rb_refstring_unref (entry->mountpoint);
+                               entry->mountpoint = NULL;
+                       }
+                       if (g_value_get_string (value) != NULL) {
+                               entry->mountpoint = rb_refstring_new (g_value_get_string (value));
                        }
-                       entry->mountpoint = rb_refstring_new (g_value_get_string (value));
                        break;
                case RHYTHMDB_PROP_FILE_SIZE:
                        entry->file_size = g_value_get_uint64 (value);


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