From fc379df197d3dac9a654d531f89c6e1c44dd8acd Mon Sep 17 00:00:00 2001 From: kevin Date: Mon, 12 Dec 2022 12:26:26 -0500 Subject: [PATCH] cwPresetSel.h/cpp: Changed name of is_fragment_loc() to is_fragment_end_loc(). Fixed delete_fragment() to update 'end_loc' of previous frag. to 'end_loc' of deleted frag. --- cwPresetSel.cpp | 11 +++++++++-- cwPresetSel.h | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cwPresetSel.cpp b/cwPresetSel.cpp index 7335b9a..7466b39 100644 --- a/cwPresetSel.cpp +++ b/cwPresetSel.cpp @@ -646,7 +646,8 @@ cw::rc_t cw::preset_sel::create_fragment( handle_t h, unsigned end_loc, time::sp // set the return value fragIdRef = f->fragId; - + + // intiialize the preset array elements for(unsigned i=0; ipresetLabelN; ++i) { f->presetA[i].preset_idx = i; @@ -719,7 +720,12 @@ cw::rc_t cw::preset_sel::delete_fragment( handle_t h, unsigned fragId ) if( f->prev == nullptr ) p->fragL = f->link; else + { + // the previous fragment's end-loc become the + // endloc of the deleted fragment + f->prev->endLoc = f->endLoc; f->prev->link = f->link; + } if( f->link != nullptr ) f->link->prev = f->prev; @@ -734,13 +740,14 @@ cw::rc_t cw::preset_sel::delete_fragment( handle_t h, unsigned fragId ) 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 ) +bool cw::preset_sel::is_fragment_end_loc( handle_t h, unsigned loc ) { preset_sel_t* p = _handleToPtr(h); return _loc_to_frag(p,loc) != nullptr; } + unsigned cw::preset_sel::ui_select_fragment_id( handle_t h ) { preset_sel_t* p = _handleToPtr(h); diff --git a/cwPresetSel.h b/cwPresetSel.h index e16d791..e2ae26a 100644 --- a/cwPresetSel.h +++ b/cwPresetSel.h @@ -88,7 +88,7 @@ namespace cw rc_t create_fragment( handle_t h, unsigned end_loc, time::spec_t endTimestamp, unsigned& fragIdRef ); rc_t delete_fragment( handle_t h, unsigned fragId ); - bool is_fragment_loc( handle_t h, unsigned loc ); + bool is_fragment_end_loc( handle_t h, unsigned loc ); // Return the fragment id of the 'selected' fragment. unsigned ui_select_fragment_id( handle_t h );