summaryrefslogtreecommitdiff
path: root/protocols/Tox/src/tox_proto.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Tox/src/tox_proto.cpp')
-rw-r--r--protocols/Tox/src/tox_proto.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/protocols/Tox/src/tox_proto.cpp b/protocols/Tox/src/tox_proto.cpp
index b31d83f894..1718f9f0bc 100644
--- a/protocols/Tox/src/tox_proto.cpp
+++ b/protocols/Tox/src/tox_proto.cpp
@@ -1,10 +1,10 @@
#include "stdafx.h"
-CToxProto::CToxProto(const char* protoName, const TCHAR* userName) :
-PROTO<CToxProto>(protoName, userName),
-tox(NULL), toxAv(NULL), password(NULL),
-isTerminated(false), isConnected(false),
-hPollingThread(NULL), hOutDevice(NULL)
+CToxProto::CToxProto(const char* protoName, const TCHAR* userName)
+ : PROTO<CToxProto>(protoName, userName),
+ tox(NULL), toxAv(NULL), password(NULL),
+ isTerminated(false), isConnected(false),
+ hPollingThread(NULL), hOutDevice(NULL)
{
InitNetlib();
@@ -174,6 +174,8 @@ int CToxProto::SetStatus(int iNewStatus)
{
// logout
isTerminated = true;
+ WaitForSingleObject(hPollingThread, INFINITE);
+ hPollingThread = NULL;
if (!Miranda_Terminated())
{
@@ -192,6 +194,12 @@ int CToxProto::SetStatus(int iNewStatus)
if (old_status == ID_STATUS_OFFLINE && !IsOnline())
{
+ if (hPollingThread != NULL)
+ {
+ m_iDesiredStatus = old_status;
+ return 0;
+ }
+
// login
m_iStatus = ID_STATUS_CONNECTING;