Skip to content

Commit e4f1393

Browse files
PatriceJianghuangwei1024
authored andcommitted
revert threads (cocos2d#19572)
1 parent aa62874 commit e4f1393

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

cocos/platform/win32/CCDevice-win32.cpp

+16-20
Original file line numberDiff line numberDiff line change
@@ -173,18 +173,16 @@ class BitmapDC
173173
if (fontPath.size() > 0)
174174
{
175175
_curFontPath = fontPath;
176-
std::thread([fontPath, wnd = _wnd, this]() {
177-
wchar_t * pwszBuffer = utf8ToUtf16(fontPath);
178-
if (pwszBuffer)
176+
wchar_t * pwszBuffer = utf8ToUtf16(fontPath);
177+
if (pwszBuffer)
178+
{
179+
if (AddFontResource(pwszBuffer))
179180
{
180-
if (AddFontResource(pwszBuffer))
181-
{
182-
PostMessage(wnd, WM_FONTCHANGE, 0, 0);
183-
}
184-
delete[] pwszBuffer;
185-
pwszBuffer = nullptr;
181+
PostMessage(_wnd, WM_FONTCHANGE, 0, 0);
186182
}
187-
}).detach();
183+
delete[] pwszBuffer;
184+
pwszBuffer = nullptr;
185+
}
188186
}
189187

190188
_font = nullptr;
@@ -432,16 +430,14 @@ class BitmapDC
432430
// release temp font resource
433431
if (_curFontPath.size() > 0)
434432
{
435-
std::thread([curFontPath = _curFontPath, wnd = _wnd, this]() {
436-
wchar_t * pwszBuffer = utf8ToUtf16(curFontPath);
437-
if (pwszBuffer)
438-
{
439-
RemoveFontResource(pwszBuffer);
440-
PostMessage(wnd, WM_FONTCHANGE, 0, 0);
441-
delete[] pwszBuffer;
442-
pwszBuffer = nullptr;
443-
}
444-
}).detach();
433+
wchar_t * pwszBuffer = utf8ToUtf16(_curFontPath);
434+
if (pwszBuffer)
435+
{
436+
RemoveFontResource(pwszBuffer);
437+
PostMessage(_wnd, WM_FONTCHANGE, 0, 0);
438+
delete[] pwszBuffer;
439+
pwszBuffer = nullptr;
440+
}
445441
_curFontPath.clear();
446442
}
447443
}

0 commit comments

Comments
 (0)