]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiSymbols.cpp
Avoid extra space in tooltips
[lyx.git] / src / frontends / qt4 / GuiSymbols.cpp
index 9f7dd6105bda22b5e7c570572a700d7ec430e5b3..d08689cd3cc85fcddfce113ae913bf8ee138fe6b 100644 (file)
@@ -152,6 +152,7 @@ const int no_blocks = sizeof(unicode_blocks) / sizeof(UnicodeBlocks);
 QString getBlock(char_type c)
 {
        // store an educated guess for the next search
+       // 0 <= lastBlock < no_blocks
        // FIXME THREAD
        static int lastBlock = 0;
 
@@ -159,10 +160,6 @@ QString getBlock(char_type c)
        if (c < 0x7f)
                lastBlock = 0;
 
-       // off the end already
-       if (lastBlock == no_blocks)
-               return QString();
-
        // c falls into a covered area, and we can guess which
        if (c >= unicode_blocks[lastBlock].start
            && c <= unicode_blocks[lastBlock].end)
@@ -177,15 +174,25 @@ QString getBlock(char_type c)
        int i = 0;
        while (i < no_blocks && c > unicode_blocks[i].end)
                ++i;
-       if (i == no_blocks || c < unicode_blocks[i].start)
+
+       if (i == no_blocks)
                return QString();
+
+       if (c < unicode_blocks[i].start) {
+               // 0 < i < no_blocks
+               // cache the previous block for guessing next time
+               lastBlock = i - 1;
+               return QString();
+       }
+
+       // 0 <= i < no_blocks
        // cache the last block for guessing next time
        lastBlock = i;
        return unicode_blocks[lastBlock].qname;
 }
 
 
-} // namespace anon
+} // namespace
 
 
 /////////////////////////////////////////////////////////////////////
@@ -198,7 +205,7 @@ class GuiSymbols::Model : public QAbstractListModel
 {
 public:
        Model(GuiSymbols * parent)
-               : QAbstractListModel(parent)
+               : QAbstractListModel(parent), encoding_(0)
        {}
 
        QModelIndex index(int row, int column, QModelIndex const &) const