diff --git a/ChangeLog b/ChangeLog index 69c2390c..172b07bf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20727,3 +20727,7 @@ 2021-04-06 Fred Gleason * Fixed a bug in the Cart Selector Dialog that made it impossible to enter an apostrophe character in the filter search line. +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/lib/rdcart.cpp b/lib/rdcart.cpp index d9279f23..0a0fb097 100644 --- a/lib/rdcart.cpp +++ b/lib/rdcart.cpp @@ -2,7 +2,7 @@ // // Abstract a Rivendell Cart. // -// (C) Copyright 2002-2020 Fred Gleason +// (C) Copyright 2002-2021 Fred Gleason // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License version 2 as @@ -985,8 +985,7 @@ void RDCart::setMetadata(const RDWaveData *data) if(sql.right(1)==",") { sql=sql.left(sql.length()-1); sql+=QString().sprintf(" where NUMBER=%u",cart_number); - RDSqlQuery *q=new RDSqlQuery(sql); - delete q; + RDSqlQuery::apply(sql); } setSchedCodesList(data->schedCodes()); metadata_changed=true; diff --git a/utils/rdimport/rdimport.cpp b/utils/rdimport/rdimport.cpp index b51fe0e2..e88d48b0 100644 --- a/utils/rdimport/rdimport.cpp +++ b/utils/rdimport/rdimport.cpp @@ -1039,13 +1039,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)); - } } // @@ -1080,6 +1073,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 // @@ -1243,6 +1251,7 @@ MainObject::Result MainObject::ImportFile(const QString &filename, wavedata->setStartPos(-1); wavedata->setEndPos(-1); } + if(cart_created) { cart->setMetadata(wavedata); } @@ -1252,7 +1261,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) {