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;
|
||||
case ERR_SOCK_CREATION_FAILED:
|
||||
{ QMessageBox::warning(this, tr("Network Error"),
|
||||
tr("Could not create socket."),
|
||||
tr("Could not create a socket for TCP communication."),
|
||||
QMessageBox::Close); }
|
||||
break;
|
||||
case ERR_SOCK_SET_PORT_FAILED:
|
||||
@@ -78,7 +78,7 @@ void connectToServerDialogImpl::error(int errorID, int osErrorID) {
|
||||
break;
|
||||
case ERR_SOCK_CONNECT_FAILED:
|
||||
{ QMessageBox::warning(this, tr("Network Error"),
|
||||
tr("Could not connect to server."),
|
||||
tr("Could not connect to the server."),
|
||||
QMessageBox::Close); }
|
||||
break;
|
||||
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() {
|
||||
|
||||
// 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:
|
||||
joinNetworkGameDialogImpl(QWidget *parent = 0);
|
||||
|
||||
void setSession(Session* s);
|
||||
|
||||
public slots:
|
||||
|
||||
void startClient();
|
||||
|
||||
private:
|
||||
|
||||
Session *mySession;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -551,17 +551,25 @@ void mainWindowImpl::callAboutPokerthDialog() {
|
||||
|
||||
void mainWindowImpl::callJoinNetworkGameDialog() {
|
||||
|
||||
myJoinNetworkGameDialog->setSession(mySession);
|
||||
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
|
||||
myConnectToServerDialog->exec();
|
||||
|
||||
if (myConnectToServerDialog->result() == QDialog::Rejected ) {
|
||||
callJoinNetworkGameDialog();
|
||||
|
||||
mySession->terminateNetworkClient();
|
||||
actionJoin_network_Game->trigger(); // re-trigger
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,12 +31,34 @@
|
||||
#include <cstdlib>
|
||||
#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;
|
||||
|
||||
class GuiWrapper;
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
ENABLE_LEAK_CHECK();
|
||||
|
||||
//_CrtSetBreakAlloc(49937);
|
||||
|
||||
socket_startup();
|
||||
|
||||
srand( time(0) );
|
||||
|
||||
Reference in New Issue
Block a user