Filesystem: avoid crashes on exit in case the locale codec is null
On exit, QLocale::codecForLocale() can return null as the codec may have
already been destroyed. In that case, pretend that Latin1 was the
locale, so any file name is acceptable. This matches QString:
QTextCodec *codec = QTextCodec::codecForLocale();
if (codec)
return codec->toUnicode(str, size);
#endif // textcodec
return fromLatin1(str, size);
Note that if we're wrong and the locale was *not* Latin1, files that you
had a name to may not be encoded or decoded the same way.
Fixes: QTBUG-78446
Change-Id: Iece6e011237e4ab284ecfffd15c54077728a17ca
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
bb10
parent
06cc5d3071
commit
70e6e9fe59
|
|
@ -69,7 +69,9 @@ static bool checkNameDecodable(const char *d_name, qsizetype len)
|
|||
# ifdef QT_LOCALE_IS_UTF8
|
||||
int mibEnum = 106;
|
||||
# else
|
||||
int mibEnum = codec->mibEnum();
|
||||
int mibEnum = 4; // Latin 1
|
||||
if (codec)
|
||||
mibEnum = codec->mibEnum();
|
||||
# endif
|
||||
if (Q_LIKELY(mibEnum == 106)) // UTF-8
|
||||
return QUtf8::isValidUtf8(d_name, len).isValidUtf8;
|
||||
|
|
|
|||
Loading…
Reference in New Issue