From 753944998dbc00ef6c9fdbf63345e5aa6c3f9f38 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 29 Oct 2021 12:36:19 +0200 Subject: Correct qcollator_posix.cpp's check against system locale The check was made against the default locale but the code calls the system functions (wcscoll, wcsxfrm, wcscmp) for locale-specific collation, so should be comparing to the system locale's collation locale (i.e. LC_COLLATE). Also correct the Android-only check in tst_QCollator::compare() which duplicated the check but neglected the C locale, which is also supported (via QString::compare). Change-Id: I48c3237dd6825e2070272ab88d95bdb8cbb9fc37 Reviewed-by: Aleix Pol Gonzalez Reviewed-by: Thiago Macieira (cherry picked from commit 25d807f6292e9918ccdbe06cf7f590f60ecae457) Reviewed-by: Lars Knoll --- src/corelib/text/qcollator_posix.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/corelib/text/qcollator_posix.cpp b/src/corelib/text/qcollator_posix.cpp index 92148fa315..7f04847434 100644 --- a/src/corelib/text/qcollator_posix.cpp +++ b/src/corelib/text/qcollator_posix.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2020 Aleix Pol Gonzalez +** Copyright (C) 2021 The Qt Company Ltd. +** Copyright (C) 2013 Aleix Pol Gonzalez ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -49,8 +50,10 @@ QT_BEGIN_NAMESPACE void QCollatorPrivate::init() { if (!isC()) { - if (locale != QLocale()) - qWarning("Only C and default locale supported with the posix collation implementation"); + if (locale != QLocale::system().collation()) { + qWarning("Only the C and system collation locales are supported " + "with the POSIX collation implementation"); + } if (caseSensitivity != Qt::CaseSensitive) qWarning("Case insensitive sorting unsupported in the posix collation implementation"); } -- cgit v1.2.3