mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
The remote client now runs in an extra thread, fixing issue #29
This commit is contained in:
parent
542fd2c5c8
commit
4e4a7563db
26 changed files with 130 additions and 79 deletions
|
|
@ -26,6 +26,7 @@
|
|||
#include <QInputDialog>
|
||||
#include <QFile>
|
||||
#include <QFileDialog>
|
||||
#include <QThread>
|
||||
|
||||
#include "main.h"
|
||||
#include "window_main.h"
|
||||
|
|
@ -337,7 +338,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
{
|
||||
QPixmapCache::setCacheLimit(200000);
|
||||
|
||||
client = new RemoteClient(this);
|
||||
client = new RemoteClient;
|
||||
connect(client, SIGNAL(connectionClosedEventReceived(const Event_ConnectionClosed &)), this, SLOT(processConnectionClosedEvent(const Event_ConnectionClosed &)));
|
||||
connect(client, SIGNAL(serverShutdownEventReceived(const Event_ServerShutdown &)), this, SLOT(processServerShutdownEvent(const Event_ServerShutdown &)));
|
||||
connect(client, SIGNAL(serverError(Response::ResponseCode, QString)), this, SLOT(serverError(Response::ResponseCode, QString)));
|
||||
|
|
@ -346,6 +347,10 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
connect(client, SIGNAL(statusChanged(ClientStatus)), this, SLOT(statusChanged(ClientStatus)));
|
||||
connect(client, SIGNAL(protocolVersionMismatch(int, int)), this, SLOT(protocolVersionMismatch(int, int)));
|
||||
connect(client, SIGNAL(userInfoChanged(const ServerInfo_User &)), this, SLOT(userInfoReceived(const ServerInfo_User &)));
|
||||
|
||||
clientThread = new QThread(this);
|
||||
client->moveToThread(clientThread);
|
||||
clientThread->start();
|
||||
|
||||
tabSupervisor = new TabSupervisor;
|
||||
connect(tabSupervisor, SIGNAL(setMenu(QMenu *)), this, SLOT(updateTabMenu(QMenu *)));
|
||||
|
|
@ -361,6 +366,12 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
resize(900, 700);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
client->deleteLater();
|
||||
clientThread->wait();
|
||||
}
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
if (tabSupervisor->getGameCount()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue