On 11.04.2011 17:01, MacArthur, Ian (SELEX GALILEO, UK) wrote:
>
>> All the observations in this thread may be very right and
>> point to some problematic areas,
>
> Yup - thread drift, and probably my fault.
> I've been assuming that Manolo or Matt will fix this, as they are much
> better on the OSX stuff...
And so did I. Manolo, did you follow this thread ?
>> And according to it, it *must* happen in line 2083 of
>> Fl_mac.cxx (current svn):
>>
>> SetWindowTitleWithCFString(xid, utf8_title).
>>
>> Cleary utf8_title is NULL because of the conversion in the
>> previous line.
>
> That's this bit:
>
> #if 1
> CFStringRef utf8_title = CFStringCreateWithCString(NULL, (name ?
> name : ""), kCFStringEncodingUTF8);
> SetWindowTitleWithCFString(xid, utf8_title);
> CFRelease(utf8_title);
> #else // old non-utf8 code to remove after new utf8 code approval :
> Str255 pTitle;
> if (name) {
> if (strlen(name)> 255) pTitle[0] = 255;
> else pTitle[0] = strlen(name);
> memcpy(pTitle+1, name, pTitle[0]);
> }
> else
> pTitle[0] = 0;
> SetWTitle(xid, pTitle);
> #endif
>
> So we have a number of options:
>
> 1: change the "#if 1" to "#if 0" to revert the old behaviour.
>
> 2: Test for utf8_title being NULL;
>
> CFStringRef utf8_title = CFStringCreateWithCString(NULL, (name ?
> name : ""), kCFStringEncodingUTF8);
> if (utf8_title) {
> SetWindowTitleWithCFString(xid, utf8_title);
> CFRelease(utf8_title);
> }
>
> This seems better -
> But what happens if we don't set a window title?
> And should we CFRelease(utf8_title) even if it is NULL?
Good questions.
> I don't know enough OSX API to know...
Neither do I.
And there is also option #3:
Convert the title string to UTF-16 to "clean" it as a side effect and
to be consistent on different platforms, and use a corresponding call.
"kCFStringEncodingUTF8" makes me suspect that there would also be
"kCFStringEncodingUTF16"...
Of course, this is only fixing symptoms that /should/ not appear, because
all input strings *should* be (correctly) UTF-8-encoded. ;-)
Albrecht
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk