From 912596e0585dac27e0bad37d72bd204bd5feb6ca Mon Sep 17 00:00:00 2001 From: Arnold <397136899@qq.com> Date: Wed, 3 Apr 2019 10:49:00 +0800 Subject: [PATCH] revert threads --- cocos/platform/win32/CCDevice-win32.cpp | 36 +++++++++++-------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/cocos/platform/win32/CCDevice-win32.cpp b/cocos/platform/win32/CCDevice-win32.cpp index fdae86d7b2f3..47a3a5a43608 100644 --- a/cocos/platform/win32/CCDevice-win32.cpp +++ b/cocos/platform/win32/CCDevice-win32.cpp @@ -173,18 +173,16 @@ class BitmapDC if (fontPath.size() > 0) { _curFontPath = fontPath; - std::thread([fontPath, wnd = _wnd, this]() { - wchar_t * pwszBuffer = utf8ToUtf16(fontPath); - if (pwszBuffer) + wchar_t * pwszBuffer = utf8ToUtf16(fontPath); + if (pwszBuffer) + { + if (AddFontResource(pwszBuffer)) { - if (AddFontResource(pwszBuffer)) - { - PostMessage(wnd, WM_FONTCHANGE, 0, 0); - } - delete[] pwszBuffer; - pwszBuffer = nullptr; + PostMessage(_wnd, WM_FONTCHANGE, 0, 0); } - }).detach(); + delete[] pwszBuffer; + pwszBuffer = nullptr; + } } _font = nullptr; @@ -432,16 +430,14 @@ class BitmapDC // release temp font resource if (_curFontPath.size() > 0) { - std::thread([curFontPath = _curFontPath, wnd = _wnd, this]() { - wchar_t * pwszBuffer = utf8ToUtf16(curFontPath); - if (pwszBuffer) - { - RemoveFontResource(pwszBuffer); - PostMessage(wnd, WM_FONTCHANGE, 0, 0); - delete[] pwszBuffer; - pwszBuffer = nullptr; - } - }).detach(); + wchar_t * pwszBuffer = utf8ToUtf16(_curFontPath); + if (pwszBuffer) + { + RemoveFontResource(pwszBuffer); + PostMessage(_wnd, WM_FONTCHANGE, 0, 0); + delete[] pwszBuffer; + pwszBuffer = nullptr; + } _curFontPath.clear(); } }