From b14d706a72c706c9c59dbdf64a9e41f32465e060 Mon Sep 17 00:00:00 2001 From: jhurst Date: Tue, 13 Apr 2021 15:50:50 -0700 Subject: o Added a Clone() method to InterchangeObject and derivatives that allows making a descriptor copy that is not owned by any other strucure. The caller must arrange to delete the object pointer returned. o While implementing the above it became obvious that the reference-to-a-pointer-to-the-dictionary idiom that is used throughout the lower levels of the MXF library was the cause of much more grief than it was originally designed to prevent. This was made even more obvious when I replaced all of it with simple pointers, which revealed several shadow instances of m_Dict that were only reliable while the object that held them was valid. --- src/Index.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src/Index.cpp') diff --git a/src/Index.cpp b/src/Index.cpp index 6406e0f..0815f25 100755 --- a/src/Index.cpp +++ b/src/Index.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2005-2012, John Hurst +Copyright (c) 2005-2021, John Hurst All rights reserved. Redistribution and use in source and binary forms, with or without @@ -34,8 +34,8 @@ const ui32_t kl_length = ASDCP::SMPTE_UL_LENGTH + ASDCP::MXF_BER_LENGTH; // -ASDCP::MXF::IndexTableSegment::IndexTableSegment(const Dictionary*& d) : - InterchangeObject(d), m_Dict(d), RtFileOffset(0), RtEntryOffset(0), +ASDCP::MXF::IndexTableSegment::IndexTableSegment(const Dictionary* d) : + InterchangeObject(d), RtFileOffset(0), RtEntryOffset(0), IndexStartPosition(0), IndexDuration(0), EditUnitByteCount(0), IndexSID(129), BodySID(1), SliceCount(0), PosTableCount(0) { @@ -48,6 +48,13 @@ ASDCP::MXF::IndexTableSegment::~IndexTableSegment() { } +ASDCP::MXF::IndexTableSegment::IndexTableSegment(const IndexTableSegment& rhs) : InterchangeObject(rhs.m_Dict) +{ + assert(m_Dict); + m_UL = m_Dict->ul(MDD_IndexTableSegment); + Copy(rhs); +} + // void ASDCP::MXF::IndexTableSegment::Copy(const IndexTableSegment& rhs) @@ -65,6 +72,13 @@ ASDCP::MXF::IndexTableSegment::Copy(const IndexTableSegment& rhs) IndexEntryArray = rhs.IndexEntryArray; } +// +ASDCP::MXF::InterchangeObject* +ASDCP::MXF::IndexTableSegment::Clone() const +{ + return new IndexTableSegment(*this); +} + // ASDCP::Result_t ASDCP::MXF::IndexTableSegment::InitFromTLVSet(TLVReader& TLVSet) -- cgit v1.2.3