mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-13 21:40:00 -08:00
[Client] Fix crash when local game commands are sent after shutdown
This commit is contained in:
parent
8b0c980e85
commit
df74845721
6 changed files with 178 additions and 8 deletions
|
|
@ -33,16 +33,19 @@ LocalClient::LocalClient(LocalServerInterface *_lsi,
|
|||
sendCommand(prepareSessionCommand(joinCmd));
|
||||
}
|
||||
|
||||
LocalClient::~LocalClient()
|
||||
{
|
||||
}
|
||||
|
||||
void LocalClient::sendCommandContainer(const CommandContainer &cont)
|
||||
{
|
||||
if (LocalClientLog().isDebugEnabled()) {
|
||||
qCDebug(LocalClientLog).noquote() << userName << "OUT" << getSafeDebugString(cont);
|
||||
}
|
||||
|
||||
if (lsi.isNull()) {
|
||||
qCWarning(LocalClientLog).noquote() << userName
|
||||
<< "dropping command, local server interface no longer exists:"
|
||||
<< getSafeDebugString(cont);
|
||||
return;
|
||||
}
|
||||
|
||||
lsi->itemFromClient(cont);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#include "../abstract/abstract_client.h"
|
||||
|
||||
#include <QLoggingCategory>
|
||||
#include <QPointer>
|
||||
#include <QString>
|
||||
#include <qtmetamacros.h>
|
||||
|
||||
|
|
@ -24,14 +25,15 @@ class LocalClient : public AbstractClient
|
|||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
LocalServerInterface *lsi;
|
||||
// Guarded pointer: the LocalServer (and its interfaces) may be destroyed while this client
|
||||
// still has pending commands queued on the event loop.
|
||||
QPointer<LocalServerInterface> lsi;
|
||||
|
||||
public:
|
||||
LocalClient(LocalServerInterface *_lsi,
|
||||
const QString &_playerName,
|
||||
const QString &_clientId,
|
||||
QObject *parent = nullptr);
|
||||
~LocalClient() override;
|
||||
|
||||
void sendCommandContainer(const CommandContainer &cont) override;
|
||||
private slots:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue