Fixed assert (crash) when opening a stream file saved by a newer version of Ostinato containing a new/unknown protocol
This commit is contained in:
parent
f140717f81
commit
481005a994
@ -164,6 +164,11 @@ void ProtocolManager::populateNeighbourProtocols()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ProtocolManager::isRegisteredProtocol(int protoNumber)
|
||||||
|
{
|
||||||
|
return factory.contains(protoNumber);
|
||||||
|
}
|
||||||
|
|
||||||
AbstractProtocol* ProtocolManager::createProtocol(int protoNumber,
|
AbstractProtocol* ProtocolManager::createProtocol(int protoNumber,
|
||||||
StreamBase *stream, AbstractProtocol *parent)
|
StreamBase *stream, AbstractProtocol *parent)
|
||||||
{
|
{
|
||||||
|
@ -42,6 +42,7 @@ public:
|
|||||||
|
|
||||||
void registerProtocol(int protoNumber, void *protoInstanceCreator);
|
void registerProtocol(int protoNumber, void *protoInstanceCreator);
|
||||||
|
|
||||||
|
bool isRegisteredProtocol(int protoNumber);
|
||||||
AbstractProtocol* createProtocol(int protoNumber, StreamBase *stream,
|
AbstractProtocol* createProtocol(int protoNumber, StreamBase *stream,
|
||||||
AbstractProtocol *parent = 0);
|
AbstractProtocol *parent = 0);
|
||||||
AbstractProtocol* createProtocol(QString protoName, StreamBase *stream,
|
AbstractProtocol* createProtocol(QString protoName, StreamBase *stream,
|
||||||
|
@ -89,8 +89,14 @@ void StreamBase::protoDataCopyFrom(const OstProto::Stream &stream)
|
|||||||
iter = createProtocolListIterator();
|
iter = createProtocolListIterator();
|
||||||
for (int i=0; i < stream.protocol_size(); i++)
|
for (int i=0; i < stream.protocol_size(); i++)
|
||||||
{
|
{
|
||||||
proto = OstProtocolManager->createProtocol(
|
int protoId = stream.protocol(i).protocol_id().id();
|
||||||
stream.protocol(i).protocol_id().id(), this);
|
|
||||||
|
if (!OstProtocolManager->isRegisteredProtocol(protoId))
|
||||||
|
{
|
||||||
|
qWarning("Skipping unregistered protocol %d", protoId);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
proto = OstProtocolManager->createProtocol(protoId, this);
|
||||||
proto->protoDataCopyFrom(stream.protocol(i));
|
proto->protoDataCopyFrom(stream.protocol(i));
|
||||||
iter->insert(proto);
|
iter->insert(proto);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user