From a20b7f2437ba584fbe9d5eb4233cc121708681a7 Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Tue, 26 Jul 2016 11:55:43 -0400 Subject: [PATCH] 2016-07-26 Fred Gleason * Added a sanity check in the 'RDCut::setMetadata()' method in 'lib/rdcut.cpp' to ensure that the cut 'Description' field is always populated. --- ChangeLog | 4 ++++ lib/rdcut.cpp | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/ChangeLog b/ChangeLog index 39ddd031..acdba143 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15416,3 +15416,7 @@ 'SERVICE_CLOCKS' table. * Modified 'rdlogmanager/list_clocks.cpp' to use the new 'SERVICE_CLOCKS' table. +2016-07-26 Fred Gleason + * Added a sanity check in the 'RDCut::setMetadata()' method in + 'lib/rdcut.cpp' to ensure that the cut 'Description' field is always + populated. diff --git a/lib/rdcut.cpp b/lib/rdcut.cpp index 794c679f..85bd772a 100644 --- a/lib/rdcut.cpp +++ b/lib/rdcut.cpp @@ -1135,6 +1135,24 @@ void RDCut::setMetadata(RDWaveData *data) const sprintf(" where CUT_NAME=\"%s\"",(const char *)cut_name.utf8()); RDSqlQuery *q=new RDSqlQuery(sql); delete q; + + // + // Sanity Check: NEVER permit the 'description' field to be empty. + // + sql=QString("select DESCRIPTION from CUTS where ")+ + "CUT_NAME=\""+RDEscapeString(cut_name)+"\""; + q=new RDSqlQuery(sql); + if(q->first()) { + if(q->value(0).toString().isEmpty()) { + sql=QString("update CUTS set ")+ + QString().sprintf("DESCRIPTION=\"Cut %03d\"", + RDCut::cutNumber(cut_name))+ + " where CUT_NAME=\""+RDEscapeString(cut_name)+"\""; + delete q; + q=new RDSqlQuery(sql); + } + } + delete q; }