1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-07-31 11:20:22 +02:00

* Don't crash in StreamConnection without m_iodev.

This commit is contained in:
Christian Muehlhaeuser
2013-01-17 07:47:17 +01:00
parent e20d8c955e
commit 09a177ec51

View File

@@ -215,7 +215,7 @@ StreamConnection::handleMsg( msg_ptr msg )
else if ( msg->payload().startsWith( "doneblock" ) ) else if ( msg->payload().startsWith( "doneblock" ) )
{ {
int block = QString( msg->payload() ).mid( 9 ).toInt(); int block = QString( msg->payload() ).mid( 9 ).toInt();
((BufferIODevice*)m_iodev.data())->seeked( block ); ( (BufferIODevice*)m_iodev.data() )->seeked( block );
m_curBlock = block; m_curBlock = block;
qDebug() << "Next block is now:" << block; qDebug() << "Next block is now:" << block;
@@ -223,18 +223,21 @@ StreamConnection::handleMsg( msg_ptr msg )
else if ( msg->payload().startsWith( "data" ) ) else if ( msg->payload().startsWith( "data" ) )
{ {
m_badded += msg->payload().length() - 4; m_badded += msg->payload().length() - 4;
((BufferIODevice*)m_iodev.data())->addData( m_curBlock++, msg->payload().mid( 4 ) ); ( (BufferIODevice*)m_iodev.data() )->addData( m_curBlock++, msg->payload().mid( 4 ) );
} }
//qDebug() << Q_FUNC_INFO << "flags" << (int) msg->flags() //qDebug() << Q_FUNC_INFO << "flags" << (int) msg->flags()
// << "payload len" << msg->payload().length() // << "payload len" << msg->payload().length()
// << "written to device so far: " << m_badded; // << "written to device so far: " << m_badded;
if ( ((BufferIODevice*)m_iodev.data())->nextEmptyBlock() < 0 ) if ( !m_iodev || ( (BufferIODevice*)m_iodev.data() )->nextEmptyBlock() < 0 )
{ {
m_allok = true; m_allok = true;
// tell our iodev there is no more data to read, no args meaning a success: // tell our iodev there is no more data to read, no args meaning a success:
((BufferIODevice*)m_iodev.data())->inputComplete(); if ( m_iodev )
( (BufferIODevice*)m_iodev.data() )->inputComplete();
shutdown(); shutdown();
} }
} }