Changeset 229 for trunk/src/corelib


Ignore:
Timestamp:
Oct 16, 2009, 1:19:40 AM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

corelib: QSettings [Win, OS/2]: When setting and then getting string or binary data, a destructive Latin1 -> QString -> Local8Bit -> QString -> Latin1 conversion could be performed replacing characters >0x7F with '?' in the stream. As a result, saving e.g. a QDateTime object and then reading it could construct a completely different one [nasty vendor bug].

Location:
trunk/src/corelib/io
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/corelib/io/qsettings_os2.cpp

    r63 r229  
    677677    }
    678678
     679
     680
     681
     682
     683
     684
     685
     686
    679687    switch (dataType) {
    680688        case REG_EXPAND_SZ:
     
    685693                    s = QString::fromUtf16(((const ushort*)data.constData()));
    686694                }, {
    687                     s = QString::fromLocal8Bit(data.constData());
     695                    s = QString::fromL(data.constData());
    688696                } );
    689697            }
     
    723731                    s = QString::fromUtf16((const ushort*)data.constData(), data.size()/2);
    724732                }, {
    725                     s = QString::fromLocal8Bit(data.constData(), data.size());
     733                    s = QString::fromL(data.constData(), data.size());
    726734                } );
    727735            }
     
    876884    QByteArray regValueBuff;
    877885
     886
     887
     888
     889
     890
     891
     892
     893
    878894    // Determine the type
    879895    switch (value.type()) {
     
    897913                    regValueBuff = QByteArray((const char*)s.utf16(), s.length()*2);
    898914                }, {
    899                     regValueBuff = QByteArray((const char*)s.toLocal8Bit(), s.length());
     915                    regValueBuff = QByteArray((const char*)s.toL(), s.length());
    900916                } );
    901917            } else {
     
    906922                        regValueBuff += QByteArray((const char*)s.utf16(), (s.length() + 1)*2);
    907923                    }, {
    908                         regValueBuff += QByteArray((const char*)s.toLocal8Bit(), s.length() + 1);
     924                        regValueBuff += QByteArray((const char*)s.toL(), s.length() + 1);
    909925                    } );
    910926                }
     
    926942        }
    927943
    928         case QVariant::ByteArray:
    929             // fallthrough intended
    930 
    931944        default: {
    932945            // If the string does not contain '\0', we can use REG_SZ, the native registry
     
    938951                    regValueBuff = QByteArray((const char*)s.utf16(), s.length()*2);
    939952                }, {
    940                     regValueBuff = QByteArray((const char*)s.toLocal8Bit(), s.length());
     953                    regValueBuff = QByteArray((const char*)s.toL(), s.length());
    941954                } );
    942955            } else {
     
    944957                    regValueBuff = QByteArray((const char*)s.utf16(), (s.length() + 1)*2);
    945958                }, {
    946                     regValueBuff = QByteArray((const char*)s.toLocal8Bit(), s.length() + 1);
     959                    regValueBuff = QByteArray((const char*)s.toL(), s.length() + 1);
    947960                } );
    948961            }
  • trunk/src/corelib/io/qsettings_win.cpp

    r2 r229  
    545545    }
    546546
     547
     548
     549
     550
     551
     552
     553
     554
    547555    switch (dataType) {
    548556        case REG_EXPAND_SZ: