mirror of
https://github.com/minetest/irrlicht.git
synced 2024-11-10 09:43:52 +01:00
Prevent crash in CIrrDeviceMacOSX::setWindowCaption with cyrillic strings.
Thanks @Maksym Hamarnyk for proposing a patch and testing some changes. May break OSX 10.5 and older (lack of test-system, but probably not much used anymore). git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6194 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
parent
cb2aaf8255
commit
155c7f7592
@ -1065,20 +1065,28 @@ void CIrrDeviceMacOSX::sleep(u32 timeMs, bool pauseTimer=false)
|
||||
|
||||
void CIrrDeviceMacOSX::setWindowCaption(const wchar_t* text)
|
||||
{
|
||||
size_t size;
|
||||
char title[1024];
|
||||
|
||||
if (Window != NULL)
|
||||
{
|
||||
size = wcstombs(title,text,1024);
|
||||
title[1023] = 0;
|
||||
#ifdef __MAC_10_6
|
||||
NSString* name = [NSString stringWithCString:title encoding:NSUTF8StringEncoding];
|
||||
if ( text )
|
||||
{
|
||||
size_t numBytes = wcslen(text) * sizeof(wchar_t);
|
||||
|
||||
#ifdef __BIG_ENDIAN__
|
||||
NSStringEncoding encode = sizeof(wchar_t) == 4 ? NSUTF32BigEndianStringEncoding : NSUTF16BigEndianStringEncoding;
|
||||
#else
|
||||
NSString* name = [NSString stringWithCString:title length:size];
|
||||
NSStringEncoding encode = sizeof(wchar_t) == 4 ? NSUTF32LittleEndianStringEncoding : NSUTF16LittleEndianStringEncoding;
|
||||
#endif
|
||||
[Window setTitle:name];
|
||||
[name release];
|
||||
NSString* name = [[NSString alloc] initWithBytes:text length:numBytes encoding:encode];
|
||||
if ( name )
|
||||
{
|
||||
[Window setTitle:name];
|
||||
[name release];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
[Window setTitle:@""];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user