Cleanup of the joinnetworkgamedialog. Thread creation/termination is now done in main window. Added code to locate memory leaks.
This commit is contained in:
@@ -63,7 +63,7 @@ void connectToServerDialogImpl::error(int errorID, int osErrorID) {
|
|||||||
break;
|
break;
|
||||||
case ERR_SOCK_CREATION_FAILED:
|
case ERR_SOCK_CREATION_FAILED:
|
||||||
{ QMessageBox::warning(this, tr("Network Error"),
|
{ QMessageBox::warning(this, tr("Network Error"),
|
||||||
tr("Could not create socket."),
|
tr("Could not create a socket for TCP communication."),
|
||||||
QMessageBox::Close); }
|
QMessageBox::Close); }
|
||||||
break;
|
break;
|
||||||
case ERR_SOCK_SET_PORT_FAILED:
|
case ERR_SOCK_SET_PORT_FAILED:
|
||||||
@@ -78,7 +78,7 @@ void connectToServerDialogImpl::error(int errorID, int osErrorID) {
|
|||||||
break;
|
break;
|
||||||
case ERR_SOCK_CONNECT_FAILED:
|
case ERR_SOCK_CONNECT_FAILED:
|
||||||
{ QMessageBox::warning(this, tr("Network Error"),
|
{ QMessageBox::warning(this, tr("Network Error"),
|
||||||
tr("Could not connect to server."),
|
tr("Could not connect to the server."),
|
||||||
QMessageBox::Close); }
|
QMessageBox::Close); }
|
||||||
break;
|
break;
|
||||||
default: { QMessageBox::warning(this, tr("Network Error"),
|
default: { QMessageBox::warning(this, tr("Network Error"),
|
||||||
|
|||||||
@@ -31,14 +31,7 @@ joinNetworkGameDialogImpl::joinNetworkGameDialogImpl(QWidget *parent)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void joinNetworkGameDialogImpl::setSession(Session* s)
|
|
||||||
{
|
|
||||||
mySession = s;
|
|
||||||
}
|
|
||||||
|
|
||||||
void joinNetworkGameDialogImpl::startClient() {
|
void joinNetworkGameDialogImpl::startClient() {
|
||||||
|
|
||||||
// TODO: Check input values!
|
// TODO: Check input values!
|
||||||
if (mySession)
|
|
||||||
mySession->startNetworkClient(lineEdit_ipAddress->text().toUtf8().constData(), spinBox_port->value(), checkBox_ipv6->isChecked(), lineEdit_password->text().toUtf8().constData());
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,15 +33,9 @@ Q_OBJECT
|
|||||||
public:
|
public:
|
||||||
joinNetworkGameDialogImpl(QWidget *parent = 0);
|
joinNetworkGameDialogImpl(QWidget *parent = 0);
|
||||||
|
|
||||||
void setSession(Session* s);
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void startClient();
|
void startClient();
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
Session *mySession;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -551,17 +551,25 @@ void mainWindowImpl::callAboutPokerthDialog() {
|
|||||||
|
|
||||||
void mainWindowImpl::callJoinNetworkGameDialog() {
|
void mainWindowImpl::callJoinNetworkGameDialog() {
|
||||||
|
|
||||||
myJoinNetworkGameDialog->setSession(mySession);
|
|
||||||
myJoinNetworkGameDialog->exec();
|
myJoinNetworkGameDialog->exec();
|
||||||
|
|
||||||
if ( myJoinNetworkGameDialog->result() == QDialog::Accepted ) {
|
if (myJoinNetworkGameDialog->result() == QDialog::Accepted ) {
|
||||||
|
|
||||||
|
mySession->terminateNetworkClient();
|
||||||
|
|
||||||
|
// Maybe use QUrl::toPunycode.
|
||||||
|
mySession->startNetworkClient(
|
||||||
|
myJoinNetworkGameDialog->lineEdit_ipAddress->text().toUtf8().constData(),
|
||||||
|
myJoinNetworkGameDialog->spinBox_port->value(),
|
||||||
|
myJoinNetworkGameDialog->checkBox_ipv6->isChecked(),
|
||||||
|
myJoinNetworkGameDialog->lineEdit_password->text().toUtf8().constData());
|
||||||
|
|
||||||
//Dialog mit Statusbalken
|
//Dialog mit Statusbalken
|
||||||
myConnectToServerDialog->exec();
|
myConnectToServerDialog->exec();
|
||||||
|
|
||||||
if (myConnectToServerDialog->result() == QDialog::Rejected ) {
|
if (myConnectToServerDialog->result() == QDialog::Rejected ) {
|
||||||
callJoinNetworkGameDialog();
|
mySession->terminateNetworkClient();
|
||||||
|
actionJoin_network_Game->trigger(); // re-trigger
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,12 +31,34 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#ifdef _DEBUG
|
||||||
|
#define _CRTDBG_MAP_ALLOC
|
||||||
|
#include <crtdbg.h>
|
||||||
|
|
||||||
|
#define ENABLE_LEAK_CHECK() \
|
||||||
|
{ \
|
||||||
|
int tmpFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); \
|
||||||
|
tmpFlag |= _CRTDBG_LEAK_CHECK_DF; \
|
||||||
|
_CrtSetDbgFlag(tmpFlag); \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ENABLE_LEAK_CHECK
|
||||||
|
#define ENABLE_LEAK_CHECK()
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
class GuiWrapper;
|
class GuiWrapper;
|
||||||
|
|
||||||
int main( int argc, char **argv )
|
int main( int argc, char **argv )
|
||||||
{
|
{
|
||||||
|
ENABLE_LEAK_CHECK();
|
||||||
|
|
||||||
|
//_CrtSetBreakAlloc(49937);
|
||||||
|
|
||||||
socket_startup();
|
socket_startup();
|
||||||
|
|
||||||
srand( time(0) );
|
srand( time(0) );
|
||||||
|
|||||||
Reference in New Issue
Block a user