drop an obsolete QChar::NoCategory enum value
authorRitt Konstantin <ritt.ks@gmail.com>
Fri, 8 Jul 2011 14:24:57 +0000 (18:24 +0400)
committerQt by Nokia <qt-info@nokia.com>
Wed, 13 Jul 2011 11:31:13 +0000 (13:31 +0200)
there is no such category in the Unicode specs. the QChar::NoCategory
was a subject of bugs since it was introduced. int 4.6 it's meaning was
limited to mention ucs4 > UNICODE_LAST_CODEPOINT only (which is useless anyways)
in order to preserve the old (wrong) behavior.
fix it now for qtbase

Change-Id: I630534824e071090b39772881e747c1fdb758719
Reviewed-on: http://codereview.qt.nokia.com/1584
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
dist/changes-5.0.0
examples/widgets/charactermap/characterwidget.cpp
src/3rdparty/harfbuzz/src/harfbuzz-external.h
src/corelib/tools/qchar.cpp
src/corelib/tools/qchar.h
tests/auto/qchar/tst_qchar.cpp
util/unicode/main.cpp

index 4c226aa..344edb6 100644 (file)
@@ -38,6 +38,8 @@ Third party components
 
 QtCore
 ------
+* drop a bogus QChar::NoCategory enum value; the proper QChar::Other_NotAssigned
+  value is returned for an unassigned codepoints now.
 
 QtGui
 -----
index d9a59b6..7d515f4 100644 (file)
@@ -120,7 +120,7 @@ void CharacterWidget::mousePressEvent(QMouseEvent *event)
 {
     if (event->button() == Qt::LeftButton) {
         lastKey = (event->y()/squareSize)*columns + event->x()/squareSize;
-        if (QChar(lastKey).category() != QChar::NoCategory)
+        if (QChar(lastKey).category() != QChar::Other_NotAssigned)
             emit characterSelected(QString(QChar(lastKey)));
         update();
     }
index 7644f0d..5fff35f 100644 (file)
@@ -52,8 +52,6 @@ typedef enum {
 
 typedef enum 
 {
-    HB_NoCategory,
-
     HB_Mark_NonSpacing,          /*   Mn */
     HB_Mark_SpacingCombining,    /*   Mc */
     HB_Mark_Enclosing,           /*   Me */
index 475bd55..89f19b4 100644 (file)
@@ -259,8 +259,6 @@ QT_BEGIN_NAMESPACE
 
     \value Symbol_Other  Unicode class name So
 
-    \value NoCategory  Qt cannot find an appropriate category for the character.
-
     \omitvalue Punctuation_Dask
 
     \sa category()
@@ -764,7 +762,7 @@ QChar::Category QChar::category() const
 QChar::Category QChar::category(uint ucs4)
 {
     if (ucs4 > UNICODE_LAST_CODEPOINT)
-        return QChar::NoCategory;
+        return QChar::Other_NotAssigned;
     return (QChar::Category) qGetProp(ucs4)->category;
 }
 
index d6db72d..277c298 100644 (file)
@@ -93,8 +93,6 @@ public:
 
     enum Category
     {
-        NoCategory,    // ### Qt 5: replace with Other_NotAssigned
-
         Mark_NonSpacing,          //   Mn
         Mark_SpacingCombining,    //   Mc
         Mark_Enclosing,           //   Me
index 1fdbc34..02807f3 100644 (file)
@@ -289,11 +289,10 @@ void tst_QChar::category()
     QVERIFY(QChar::category(0xdc00u) == QChar::Other_Surrogate);
     QVERIFY(QChar::category(0xdc01u) == QChar::Other_Surrogate);
 
-    QVERIFY(QChar::category((uint)0x10fffdu) == QChar::Other_PrivateUse);
-    QVERIFY(QChar::category((uint)0x110000u) == QChar::NoCategory);
-
     QVERIFY(QChar::category((uint)0x1aff) == QChar::Other_NotAssigned);
+    QVERIFY(QChar::category((uint)0x10fffdu) == QChar::Other_PrivateUse);
     QVERIFY(QChar::category((uint)0x10ffffu) == QChar::Other_NotAssigned);
+    QVERIFY(QChar::category((uint)0x110000u) == QChar::Other_NotAssigned);
 }
 
 void tst_QChar::direction()
index 4d43464..e2596c7 100644 (file)
@@ -615,7 +615,7 @@ static void initCategoryMap()
         { QChar::Symbol_Currency,          "Sc" },
         { QChar::Symbol_Modifier,          "Sk" },
         { QChar::Symbol_Other,             "So" },
-        { QChar::NoCategory, 0 }
+        { QChar::Other_NotAssigned, 0 }
     };
     Cat *c = categories;
     while (c->name) {
@@ -763,10 +763,7 @@ static void readUnicodeData()
         }
 
         UnicodeData data(codepoint);
-        data.p.category = categoryMap.value(properties[UD_Category], QChar::NoCategory);
-        if (data.p.category == QChar::NoCategory)
-            qFatal("unassigned char category: %s", properties[UD_Category].constData());
-
+        data.p.category = categoryMap.value(properties[UD_Category], QChar::Other_NotAssigned);
         data.p.combiningClass = properties[UD_CombiningClass].toInt();
         if (!combiningClassUsage.contains(data.p.combiningClass))
             combiningClassUsage[data.p.combiningClass] = 1;