[FS9] Fix double deletion of CFs9Host

CFs9Host was guarded by a QSharedPointer plus it had a QObject parent.
This commit is contained in:
Roland Rossgotterer
2020-02-03 15:13:32 +01:00
committed by Mat Sutcliffe
parent 23c41a408b
commit f60a44ea1e
6 changed files with 25 additions and 26 deletions

View File

@@ -30,7 +30,7 @@ namespace BlackSimPlugin
return cats; return cats;
} }
CDirectPlayPeer::CDirectPlayPeer(QObject *parent, const CCallsign &callsign) CDirectPlayPeer::CDirectPlayPeer(const CCallsign &callsign, QObject *parent)
: QObject(parent), : QObject(parent),
m_callsign(callsign), m_callsign(callsign),
m_callbackWrapper(this, &CDirectPlayPeer::directPlayMessageHandler) m_callbackWrapper(this, &CDirectPlayPeer::directPlayMessageHandler)
@@ -151,17 +151,17 @@ namespace BlackSimPlugin
break; break;
} }
case DPN_MSGID_CONNECT_COMPLETE: case DPN_MSGID_CONNECT_COMPLETE:
{
const PDPNMSG_CONNECT_COMPLETE connectCompleteMsg = static_cast<PDPNMSG_CONNECT_COMPLETE>(msgBuffer);
if (connectCompleteMsg->hResultCode == DPN_OK)
{ {
emit connectionComplete(); const PDPNMSG_CONNECT_COMPLETE connectCompleteMsg = static_cast<PDPNMSG_CONNECT_COMPLETE>(msgBuffer);
if (connectCompleteMsg->hResultCode == DPN_OK)
{
emit connectionComplete();
}
else
{
CLogMessage(this).warning(u"DirectPlay connection returned: %1") << connectCompleteMsg->hResultCode;
}
} }
else
{
CLogMessage(this).warning(u"DirectPlay connection returned: %1") << connectCompleteMsg->hResultCode;
}
}
} }
// Directx9 SDK: Unless otherwise noted, this function should return S_OK. // Directx9 SDK: Unless otherwise noted, this function should return S_OK.

View File

@@ -13,7 +13,6 @@
#include "hostnode.h" #include "hostnode.h"
#include "callbackwrapper.h" #include "callbackwrapper.h"
#include "blackmisc/aviation/callsign.h" #include "blackmisc/aviation/callsign.h"
#include "blackmisc/worker.h"
#include "blackmisc/logcategorylist.h" #include "blackmisc/logcategorylist.h"
#include <QObject> #include <QObject>
#include <QList> #include <QList>
@@ -38,7 +37,7 @@ namespace BlackSimPlugin
public: public:
//! Constructor //! Constructor
CDirectPlayPeer(QObject *parent, const BlackMisc::Aviation::CCallsign &callsign); CDirectPlayPeer(const BlackMisc::Aviation::CCallsign &callsign, QObject *parent = nullptr);
//! Destructor //! Destructor
virtual ~CDirectPlayPeer() override; virtual ~CDirectPlayPeer() override;

View File

@@ -35,7 +35,7 @@ namespace BlackSimPlugin
CFs9Client::CFs9Client(const CSimulatedAircraft &remoteAircraft, CFs9Client::CFs9Client(const CSimulatedAircraft &remoteAircraft,
const CTime &updateInterval, const CTime &updateInterval,
CInterpolationLogger *logger, ISimulator *simulator) : CInterpolationLogger *logger, ISimulator *simulator) :
CDirectPlayPeer(simulator, remoteAircraft.getCallsign()), CDirectPlayPeer(remoteAircraft.getCallsign(), simulator),
m_remoteAircraft(remoteAircraft), m_remoteAircraft(remoteAircraft),
m_updateInterval(updateInterval), m_updateInterval(updateInterval),
m_interpolator(remoteAircraft.getCallsign(), simulator, simulator, simulator->getRemoteAircraftProvider(), logger), m_interpolator(remoteAircraft.getCallsign(), simulator, simulator, simulator->getRemoteAircraftProvider(), logger),
@@ -296,15 +296,15 @@ namespace BlackSimPlugin
DPNHANDLE asyncOpHandle; DPNHANDLE asyncOpHandle;
hr = m_directPlayPeer->Connect(&dpAppDesc, hr = m_directPlayPeer->Connect(&dpAppDesc,
m_hostAddress, m_hostAddress,
m_deviceAddress, m_deviceAddress,
nullptr, nullptr,
nullptr, nullptr,
nullptr, 0, nullptr, 0,
nullptr, nullptr,
nullptr, nullptr,
&asyncOpHandle, &asyncOpHandle,
0); 0);
if (!isPending(hr) && isFailure(hr)) { return logDirectPlayError(hr); } if (!isPending(hr) && isFailure(hr)) { return logDirectPlayError(hr); }
return hr; return hr;
} }

View File

@@ -24,8 +24,8 @@ namespace BlackSimPlugin
{ {
namespace Fs9 namespace Fs9
{ {
CFs9Host::CFs9Host(QObject *owner) : CFs9Host::CFs9Host(QObject *parent) :
CDirectPlayPeer(owner, sApp->swiftVersionString()) CDirectPlayPeer(sApp->swiftVersionString(), parent)
{ {
initDirectPlay(); initDirectPlay();
createHostAddress(); createHostAddress();

View File

@@ -31,7 +31,7 @@ namespace BlackSimPlugin
}; };
//! Constructor //! Constructor
CFs9Host(QObject *owner); CFs9Host(QObject *parent = nullptr);
//! Destructor //! Destructor
virtual ~CFs9Host() override; virtual ~CFs9Host() override;

View File

@@ -553,7 +553,7 @@ namespace BlackSimPlugin
CSimulatorFs9Factory::CSimulatorFs9Factory(QObject *parent) : CSimulatorFs9Factory::CSimulatorFs9Factory(QObject *parent) :
QObject(parent), QObject(parent),
m_fs9Host(new CFs9Host(this), cleanupFs9Host), m_fs9Host(new CFs9Host, cleanupFs9Host),
m_lobbyClient(new CLobbyClient, cleanupLobbyClient) m_lobbyClient(new CLobbyClient, cleanupLobbyClient)
{ {
registerMetadata(); registerMetadata();