From 74383ee0d8956039c5e75a769f72c982587b0a09 Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Mon, 3 Dec 2018 18:29:30 -0500 Subject: [PATCH] refactor HANDLE out param --- GUI/host/textthread.cpp | 7 ++----- GUI/host/textthread.h | 2 +- include/types.h | 1 + 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/GUI/host/textthread.cpp b/GUI/host/textthread.cpp index 8313186..50984a0 100644 --- a/GUI/host/textthread.cpp +++ b/GUI/host/textthread.cpp @@ -8,12 +8,9 @@ TextThread::TextThread(ThreadParam tp, HookParam hp, std::optional handle(threadCounter++), name(name.value_or(Util::StringToWideString(hp.name).value())), tp(tp), - hp(hp), - timer(NULL) + hp(hp) { - HANDLE newTimer; - CreateTimerQueueTimer(&newTimer, NULL, Flush, this, 25, 25, WT_EXECUTELONGFUNCTION); - timer = newTimer; + CreateTimerQueueTimer(timer, NULL, Flush, this, 25, 25, WT_EXECUTELONGFUNCTION); OnCreate(this); } diff --git a/GUI/host/textthread.h b/GUI/host/textthread.h index 8979dd6..db6b280 100644 --- a/GUI/host/textthread.h +++ b/GUI/host/textthread.h @@ -36,6 +36,6 @@ private: std::wstring buffer; std::unordered_set repeatingChars; std::mutex bufferMutex; - AutoHandle timer; DWORD lastPushTime; + AutoHandle timer = NULL; // this needs to be last so it's destructed first }; diff --git a/include/types.h b/include/types.h index 0f91bd6..166548c 100644 --- a/include/types.h +++ b/include/types.h @@ -31,6 +31,7 @@ class AutoHandle public: AutoHandle(HANDLE h) : h(h) {} operator HANDLE() { return h.get(); } + operator PHANDLE() { return &h._Myptr(); } operator bool() { return h.get() != NULL && h.get() != INVALID_HANDLE_VALUE; } private: