From 75387491dac45c4d42e6af0b05db35a6c9d0d4f5 Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Tue, 6 Apr 2021 11:57:44 -0400 Subject: [PATCH] 2021-04-06 Fred Gleason * Fixed a bug in rdimport(1) where the title of an existing cart would be overwritten with a default title even when no title was found in the file metadata. Signed-off-by: Fred Gleason --- ChangeLog | 4 ++++ utils/rdimport/rdimport.cpp | 24 ++++++++++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6cdc1ea2..9887b1ea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21402,3 +21402,7 @@ 2021-04-06 Fred Gleason * Fixed a bug in rdairplay(1) that caused the Talk Timer to fail to be populated when adding new carts to a log. +2021-04-06 Fred Gleason + * Fixed a bug in rdimport(1) where the title of an existing cart + would be overwritten with a default title even when no title + was found in the file metadata. diff --git a/utils/rdimport/rdimport.cpp b/utils/rdimport/rdimport.cpp index b69cca5b..e4e61a67 100644 --- a/utils/rdimport/rdimport.cpp +++ b/utils/rdimport/rdimport.cpp @@ -1055,13 +1055,6 @@ MainObject::Result MainObject::ImportFile(const QString &filename, effective_group=new RDGroup(import_group->name()); } } - - // - // Ensure that we have at least a Title - // - if(wavedata->metadataFound()&&wavedata->title().isEmpty()) { - wavedata->setTitle(effective_group->generateTitle(filename)); - } } // @@ -1097,6 +1090,21 @@ MainObject::Result MainObject::ImportFile(const QString &filename, } } + // + // Ensure that we have a valid title + // + bool cart_exists=false; + if(*cartnum!=0) { + cart_exists=RDCart::exists(*cartnum); + } + // + // If the cart already exists and no title was found in metadata, + // then keep the existing title. Otherwise, generate a default title. + // + if((!cart_exists)&&wavedata->metadataFound()&&wavedata->title().isEmpty()) { + wavedata->setTitle(effective_group->generateTitle(filename)); + } + // // Attempt to find a free cart // @@ -1269,7 +1277,7 @@ MainObject::Result MainObject::ImportFile(const QString &filename, if(cut->description().isEmpty()) { // Final backstop, so we don't end up cut->setDescription(cart->title()); // with an empty description field. } - if(!import_metadata_pattern.isEmpty()) { + if((!import_metadata_pattern.isEmpty())&&(!wavedata->title().isEmpty())) { cart->setTitle(wavedata->title()); } if(import_startdate_offset!=0) {