Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[windows] use PostMessage to replace SendMessage #19569

Merged
merged 4 commits into from
Apr 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cocos/base/CCConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ namespace {
if (Director::getInstance()->getOpenGLView())
{
HWND hwnd = Director::getInstance()->getOpenGLView()->getWin32Window();
SendMessage(hwnd,
PostMessage(hwnd,
WM_COPYDATA,
(WPARAM)(HWND)hwnd,
(LPARAM)(LPVOID)&myCDS);
Expand Down
38 changes: 22 additions & 16 deletions cocos/platform/win32/CCDevice-win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ THE SOFTWARE.
#include "platform/CCFileUtils.h"
#include "platform/CCStdC.h"

#include <thread>

NS_CC_BEGIN

int Device::getDPI()
Expand Down Expand Up @@ -171,16 +173,18 @@ class BitmapDC
if (fontPath.size() > 0)
{
_curFontPath = fontPath;
wchar_t * pwszBuffer = utf8ToUtf16(_curFontPath);
if (pwszBuffer)
{
if (AddFontResource(pwszBuffer))
std::thread([fontPath, wnd = _wnd, this]() {
wchar_t * pwszBuffer = utf8ToUtf16(fontPath);
if (pwszBuffer)
{
SendMessage(_wnd, WM_FONTCHANGE, 0, 0);
if (AddFontResource(pwszBuffer))
{
PostMessage(wnd, WM_FONTCHANGE, 0, 0);
}
delete[] pwszBuffer;
pwszBuffer = nullptr;
}
delete[] pwszBuffer;
pwszBuffer = nullptr;
}
}).detach();
}

_font = nullptr;
Expand Down Expand Up @@ -428,14 +432,16 @@ class BitmapDC
// release temp font resource
if (_curFontPath.size() > 0)
{
wchar_t * pwszBuffer = utf8ToUtf16(_curFontPath);
if (pwszBuffer)
{
RemoveFontResource(pwszBuffer);
SendMessage(_wnd, WM_FONTCHANGE, 0, 0);
delete[] pwszBuffer;
pwszBuffer = nullptr;
}
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();
_curFontPath.clear();
}
}
Expand Down