From 8e1f7af04c49d14de3af03ae5b30c73fef2e0d8e Mon Sep 17 00:00:00 2001 From: kevin Date: Sat, 22 Jan 2022 09:43:52 -0500 Subject: [PATCH] cwPresetSel.h : Updated comments. Fixed bug in delete_fragment(). --- cwPresetSel.cpp | 26 ++++++++++++-------------- cwPresetSel.h | 5 ++++- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/cwPresetSel.cpp b/cwPresetSel.cpp index bde3e41..2dd3d42 100644 --- a/cwPresetSel.cpp +++ b/cwPresetSel.cpp @@ -637,29 +637,27 @@ cw::rc_t cw::preset_sel::create_fragment( handle_t h, unsigned end_loc, time::sp cw::rc_t cw::preset_sel::delete_fragment( handle_t h, unsigned fragId ) { preset_sel_t* p = _handleToPtr(h); - frag_t* f0 = nullptr; - frag_t* f1 = p->fragL; + frag_t* f = p->fragL; - for(; f1!=nullptr; f1=f1->link) - { - if( f1->fragId == fragId ) + for(; f!=nullptr; f=f->link) + if( f->fragId == fragId ) { - if( f0 == nullptr ) - p->fragL = f1->link; + if( f->prev == nullptr ) + p->fragL = f->link; else - f0->link = f1->link; + f->prev->link = f->link; + + if( f->link != nullptr ) + f->link->prev = f->prev; // release the fragment - mem::release(f1->presetA); - mem::release(f1); + mem::release(f->presetA); + mem::release(f); return kOkRC; } - - f0 = f1; - } - return kOkRC; + return cwLogError(kInvalidArgRC,"The fragment '%i' could not be found to delete.",fragId); } bool cw::preset_sel::is_fragment_loc( handle_t h, unsigned loc ) diff --git a/cwPresetSel.h b/cwPresetSel.h index 1933a15..34f1d38 100644 --- a/cwPresetSel.h +++ b/cwPresetSel.h @@ -84,8 +84,11 @@ namespace cw rc_t delete_fragment( handle_t h, unsigned fragId ); bool is_fragment_loc( handle_t h, unsigned loc ); - + + // Return the fragment id of the 'selected' fragment. unsigned ui_select_fragment_id( handle_t h ); + + // Set the 'select_flag' on this fragment and remove it from all others. void ui_select_fragment( handle_t h, unsigned fragId, bool selectFl );