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
This commit is contained in:
Srivats P. 2010-10-25 19:27:23 +05:30
parent 90fda499dd
commit 3aac690ed8
2 changed files with 6 additions and 4 deletions

View File

@ -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);

View File

@ -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);
//@}