@@ -31,6 +31,8 @@ THE SOFTWARE.
31
31
#include " platform/CCFileUtils.h"
32
32
#include " platform/CCStdC.h"
33
33
34
+ #include < thread>
35
+
34
36
NS_CC_BEGIN
35
37
36
38
int Device::getDPI ()
@@ -171,16 +173,18 @@ class BitmapDC
171
173
if (fontPath.size () > 0 )
172
174
{
173
175
_curFontPath = fontPath;
174
- wchar_t * pwszBuffer = utf8ToUtf16 (_curFontPath);
175
- if (pwszBuffer)
176
- {
177
- if (AddFontResource (pwszBuffer))
176
+ std::thread ([fontPath, wnd = _wnd, this ]() {
177
+ wchar_t * pwszBuffer = utf8ToUtf16 (fontPath);
178
+ if (pwszBuffer)
178
179
{
179
- SendMessage (_wnd, WM_FONTCHANGE, 0 , 0 );
180
+ if (AddFontResource (pwszBuffer))
181
+ {
182
+ PostMessage (wnd, WM_FONTCHANGE, 0 , 0 );
183
+ }
184
+ delete[] pwszBuffer;
185
+ pwszBuffer = nullptr ;
180
186
}
181
- delete[] pwszBuffer;
182
- pwszBuffer = nullptr ;
183
- }
187
+ }).detach ();
184
188
}
185
189
186
190
_font = nullptr ;
@@ -428,14 +432,16 @@ class BitmapDC
428
432
// release temp font resource
429
433
if (_curFontPath.size () > 0 )
430
434
{
431
- wchar_t * pwszBuffer = utf8ToUtf16 (_curFontPath);
432
- if (pwszBuffer)
433
- {
434
- RemoveFontResource (pwszBuffer);
435
- SendMessage (_wnd, WM_FONTCHANGE, 0 , 0 );
436
- delete[] pwszBuffer;
437
- pwszBuffer = nullptr ;
438
- }
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 ();
439
445
_curFontPath.clear ();
440
446
}
441
447
}
0 commit comments