Skip to content

Commit

Permalink
Make sure we delete AirPlay device in the thread that started it.
Browse files Browse the repository at this point in the history
Fixes occasional crash at shutdown
  • Loading branch information
jyavenard committed Jun 18, 2013
1 parent e1773c2 commit eb0d243
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
13 changes: 8 additions & 5 deletions mythtv/libs/libmythtv/AirPlay/mythairplayserver.cpp
Expand Up @@ -357,6 +357,9 @@ bool MythAirplayServer::Create(void)
QObject::connect(
gMythAirplayServerThread->qthread(), SIGNAL(started()),
gMythAirplayServer, SLOT(Start()));
QObject::connect(
gMythAirplayServerThread->qthread(), SIGNAL(finished()),
gMythAirplayServer, SLOT(Stop()));
gMythAirplayServerThread->start(QThread::LowestPriority);
}

Expand All @@ -368,9 +371,6 @@ void MythAirplayServer::Cleanup(void)
{
LOG(VB_GENERAL, LOG_INFO, LOC + "Cleaning up.");

if (gMythAirplayServer)
gMythAirplayServer->Teardown();

QMutexLocker locker(gMythAirplayServerMutex);
if (gMythAirplayServerThread)
{
Expand All @@ -393,8 +393,6 @@ MythAirplayServer::MythAirplayServer()

MythAirplayServer::~MythAirplayServer()
{
Teardown();

delete m_lock;
m_lock = NULL;
}
Expand Down Expand Up @@ -482,6 +480,11 @@ void MythAirplayServer::Start(void)
return;
}

void MythAirplayServer::Stop(void)
{
Teardown();
}

void MythAirplayServer::newConnection(QTcpSocket *client)
{
QMutexLocker locker(m_lock);
Expand Down
1 change: 1 addition & 0 deletions mythtv/libs/libmythtv/AirPlay/mythairplayserver.h
Expand Up @@ -66,6 +66,7 @@ class MTV_PUBLIC MythAirplayServer : public ServerPool

private slots:
void Start();
void Stop();
void newConnection(QTcpSocket *client);
void deleteConnection();
void read(void);
Expand Down

0 comments on commit eb0d243

Please sign in to comment.