From 510f938a5c6f0ee95ac0b36e56aced065228298e Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Thu, 10 Sep 2015 11:58:58 +0000 Subject: Tox: tox pointers should store in PollingThread to avoid cross thread using git-svn-id: http://svn.miranda-ng.org/main/trunk@15316 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Tox/src/tox_proto.h | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'protocols/Tox/src/tox_proto.h') diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h index cb33550aa0..9b8b2e171c 100644 --- a/protocols/Tox/src/tox_proto.h +++ b/protocols/Tox/src/tox_proto.h @@ -1,6 +1,19 @@ #ifndef _TOX_PROTO_H_ #define _TOX_PROTO_H_ +struct ToxThreadData +{ + Tox *tox; + ToxAv *toxAv; + bool isConnected; + bool isTerminated; + + mir_cs toxLock; + + ToxThreadData() : tox(NULL), toxAv(NULL), + isConnected(false), isTerminated(false) { } +}; + struct CToxProto : public PROTO { friend CToxPasswordEditor; @@ -69,14 +82,10 @@ public: static int OnModulesLoaded(WPARAM, LPARAM); private: - Tox *tox; - ToxAv *toxAv; - char *password; - mir_cs toxLock; + ToxThreadData *toxThread; mir_cs profileLock; TCHAR *accountName; HANDLE hNetlib, hPollingThread; - bool isTerminated, isConnected; CTransferList transfers; static HANDLE hProfileFolderPath; @@ -91,8 +100,9 @@ private: INT_PTR __cdecl OnCopyToxID(WPARAM, LPARAM); // tox core - bool InitToxCore(); - void UninitToxCore(); + Tox_Options* GetToxOptions(); + bool InitToxCore(ToxThreadData *toxThread); + void UninitToxCore(ToxThreadData *toxThread); // tox network bool IsOnline(); @@ -103,7 +113,6 @@ private: void BootstrapNodes(); void TryConnect(); void CheckConnection(int &retriesCount); - void DoTox(); void __cdecl PollingThread(void*); @@ -224,7 +233,6 @@ private: int __cdecl OnPreCreateMessage(WPARAM wParam, LPARAM lParam); // transfer - HANDLE OnFileAllow(MCONTACT hContact, HANDLE hTransfer, const TCHAR *tszPath); int OnFileResume(HANDLE hTransfer, int *action, const TCHAR **szFilename); int OnFileCancel(MCONTACT hContact, HANDLE hTransfer); -- cgit v1.2.3