From 3aac690ed869e564f3be1106d2bf4e0152da22a1 Mon Sep 17 00:00:00 2001 From: "Srivats P." Date: Mon, 25 Oct 2010 19:27:23 +0530 Subject: [PATCH] While appending streams, the streamId and ordinalId were getting overwritten. Port::newStreamAt() now takes an additional parameter - pointer to stream (default NULL) which is used when appending streams Fixes Issue 21 --- client/port.cpp | 8 +++++--- client/port.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/client/port.cpp b/client/port.cpp index 6b5e13e..289e44a 100644 --- a/client/port.cpp +++ b/client/port.cpp @@ -65,13 +65,16 @@ void Port::reorderStreamsByOrdinals() qSort(mStreams.begin(), mStreams.end(), StreamBase::StreamLessThan); } -bool Port::newStreamAt(int index) +bool Port::newStreamAt(int index, OstProto::Stream const *stream) { Stream *s = new Stream; if (index > mStreams.size()) return false; + if (stream) + s->protoDataCopyFrom(*stream); + s->setId(newStreamId()); mStreams.insert(index, s); updateStreamOrdinalsFromIndex(); @@ -235,8 +238,7 @@ bool Port::openStreams(QString fileName, bool append, QString &error) for (int i = 0; i < streams.stream_size(); i++) { - newStreamAt(mStreams.size()); - streamByIndex(mStreams.size()-1)->protoDataCopyFrom(streams.stream(i)); + newStreamAt(mStreams.size(), &streams.stream(i)); } emit streamListChanged(mPortGroupId, mPortId); diff --git a/client/port.h b/client/port.h index e4bb9c9..2fbb9a0 100644 --- a/client/port.h +++ b/client/port.h @@ -99,7 +99,7 @@ public: //! Used by StreamModel //@{ - bool newStreamAt(int index); + bool newStreamAt(int index, OstProto::Stream const *stream = NULL); bool deleteStreamAt(int index); //@}