Changeset 769 for trunk/src/corelib/io


Ignore:
Timestamp:
Aug 2, 2010, 9:27:30 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.3 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/corelib/io/qdatastream.cpp

    r651 r769  
    157157    the data (apart from the length quint32) must be done by you.
    158158
     159
     160
     161
     162
     163
     164
    159165    \target Serializing Qt Classes
    160166    \section1 Reading and writing other Qt classes.
  • trunk/src/corelib/io/qdir.cpp

    r651 r769  
    10501050/*!
    10511051    \obsolete
     1052
     1053
     1054
    10521055    Adds \a path to the search paths searched in to find resources
    10531056    that are not specified with an absolute path. The default search
    10541057    path is to search only in the root (\c{:/}).
    10551058
    1056     Use QDir::addSearchPath() with a prefix instead.
    1057 
    1058     \sa {The Qt Resource System}, QResource::addSearchPath()
    1059 */
    1060 
     1059    \sa {The Qt Resource System}
     1060*/
    10611061void QDir::addResourceSearchPath(const QString &path)
    10621062{
  • trunk/src/corelib/io/qfile.cpp

    r651 r769  
    6363static QByteArray locale_encode(const QString &f)
    6464{
    65 #ifndef Q_OS_DARWIN
    66     return f.toLocal8Bit();
    67 #else
     65#if defined(Q_OS_DARWIN)
    6866    // Mac always expects UTF-8... and decomposed...
    6967    return f.normalized(QString::NormalizationForm_D).toUtf8();
     68
     69
     70
     71
    7072#endif
    7173}
     
    7375static QString locale_decode(const QByteArray &f)
    7476{
    75 #ifndef Q_OS_DARWIN
    76     return QString::fromLocal8Bit(f);
    77 #else
     77#if defined(Q_OS_DARWIN)
    7878    // Mac always gives us UTF-8 and decomposed, we want that composed...
    7979    return QString::fromUtf8(f).normalized(QString::NormalizationForm_C);
     80
     81
     82
     83
    8084#endif
    8185}
     
    8791QFilePrivate::QFilePrivate()
    8892    : fileEngine(0), lastWasWrite(false),
    89       writeBuffer(QFILE_WRITEBUFFER_SIZE), error(QFile::NoError)
     93      writeBuffer(QFILE_WRITEBUFFER_SIZE), error(QFile::NoError),
     94      cachedSize(0)
    9095{
    9196}
     
    12571262    if(d->fileEngine->setSize(sz)) {
    12581263        unsetError();
     1264
    12591265        return true;
    12601266    }
     1267
    12611268    d->setError(QFile::ResizeError, d->fileEngine->errorString());
    12621269    return false;
     
    14201427    if (!d->ensureFlushed())
    14211428        return 0;
    1422     return fileEngine()->size();
     1429    d->cachedSize = fileEngine()->size();
     1430    return d->cachedSize;
    14231431}
    14241432
     
    14461454    Q_D(const QFile);
    14471455
     1456
     1457
     1458
     1459
    14481460    if (!isOpen())
    14491461        return true;
    14501462
    14511463    if (!d->ensureFlushed())
    1452         return false;
    1453 
    1454     // If there's buffered data left, we're not at the end.
    1455     if (!d->buffer.isEmpty())
    14561464        return false;
    14571465
     
    14631471    }
    14641472
     1473
     1474
     1475
     1476
     1477
    14651478    // Fall back to checking how much is available (will stat files).
    14661479    return bytesAvailable() == 0;
     
    15021515        return -1;
    15031516
    1504     if (d->fileEngine->supportsExtension(QAbstractFileEngine::FastReadLineExtension))
    1505         return d->fileEngine->readLine(data, maxlen);
    1506 
    1507     // Fall back to QIODevice's readLine implementation if the engine
    1508     // cannot do it faster.
    1509     return QIODevice::readLineData(data, maxlen);
     1517    qint64 read;
     1518    if (d->fileEngine->supportsExtension(QAbstractFileEngine::FastReadLineExtension)) {
     1519        read = d->fileEngine->readLine(data, maxlen);
     1520    } else {
     1521        // Fall back to QIODevice's readLine implementation if the engine
     1522        // cannot do it faster.
     1523        read = QIODevice::readLineData(data, maxlen);
     1524    }
     1525
     1526    if (read < maxlen) {
     1527        // failed to read all requested, may be at the end of file, stop caching size so that it's rechecked
     1528        d->cachedSize = 0;
     1529    }
     1530
     1531    return read;
    15101532}
    15111533
     
    15281550        d->setError(err, d->fileEngine->errorString());
    15291551    }
     1552
     1553
     1554
     1555
     1556
     1557
    15301558    return read;
    15311559}
  • trunk/src/corelib/io/qfile_p.h

    r651 r769  
    8585    void setError(QFile::FileError err, int errNum);
    8686
     87
     88
    8789private:
    8890    static QFile::EncoderFn encoder;
  • trunk/src/corelib/io/qfilesystemwatcher_kqueue.cpp

    r651 r769  
    261261            DEBUG() << "QKqueueFileSystemWatcherEngine: processing kevent" << kev.ident << kev.filter;
    262262            if (fd == kqpipe[0]) {
    263                 char c;
    264                 if (read(kqpipe[0], &c, 1) != 1) {
     263                // read all pending data from the pipe
     264                QByteArray ba;
     265                ba.resize(kev.data);
     266                if (read(kqpipe[0], ba.data(), ba.size()) != ba.size()) {
    265267                    perror("QKqueueFileSystemWatcherEngine: error reading from pipe");
    266268                    return;
    267269                }
    268                 switch (c) {
     270                // read the command from the buffer (but break and return on 'q')
     271                char cmd = 0;
     272                for (int i = 0; i < ba.size(); ++i) {
     273                    cmd = ba.constData()[i];
     274                    if (cmd == 'q')
     275                        break;
     276                }
     277                // handle the command
     278                switch (cmd) {
    269279                case 'q':
    270280                    DEBUG() << "QKqueueFileSystemWatcherEngine: thread received 'q', exiting...";
     
    274284                    break;
    275285                default:
    276                     DEBUG() << "QKqueueFileSystemWatcherEngine: thread received unknow message" << c;
     286                    DEBUG() << "QKqueueFileSystemWatcherEngine: thread received unknow message" << c;
    277287                    break;
    278288                }
  • trunk/src/corelib/io/qfsfileengine.cpp

    r690 r769  
    146146    // Mac OS X 10.5.x doesn't support the realpath(X,0) extenstion we use here.
    147147#if defined(Q_OS_LINUX) || defined(Q_OS_SYMBIAN)
     148
     149
    148150    char *ret = realpath(path.toLocal8Bit().constData(), (char*)0);
    149151    if (ret) {
     
    152154        return canonicalPath;
    153155    }
     156
    154157#endif
    155158
  • trunk/src/corelib/io/qfsfileengine_p.h

    r651 r769  
    152152#endif
    153153
     154
     155
     156
     157
    154158protected:
    155159    QFSFileEnginePrivate();
  • trunk/src/corelib/io/qfsfileengine_unix.cpp

    r651 r769  
    8282             || (fileName.at(0) == QLatin1Char('/') && fileName.at(1) == QLatin1Char('/')))));
    8383}
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
     100
     101
     102
     103
     104
     105
     106
     107
     108
     109
     110
     111
     112
     113
     114
     115
     116
     117
    84118#endif
    85119
     
    99133                && QT_STAT(QFile::encodeName(fileName), &statBuf) == 0
    100134                && (statBuf.st_mode & S_IFMT) == S_IFREG) {
    101                 mode += "+";
     135                mode += ;
    102136            } else {
    103137                mode = "wb+";
     
    428462    ) // End TRAP
    429463    delete fm;
    430     // ### Add error reporting on failure
    431     return (err == KErrNone);
     464    if (err == KErrNone)
     465        return true;
     466    d->setSymbianError(err, QFile::CopyError, QLatin1String("copy error"));
     467    return false;
    432468#else
    433469    Q_UNUSED(newName);
     
    669705        } else if (fd == -1) {
    670706            // ### actually covers two cases: d->fh and when the file is not open
     707
     708
     709
     710
     711
     712
     713
     714
     715
     716
    671717            could_stat = (QT_STAT(nativeFilePath.constData(), &st) == 0);
    672718        } else {
     
    12711317    int extra = offset % pageSize;
    12721318
    1273     if (size + extra > (size_t)-1) {
     1319    if () {
    12741320        q->setError(QFile::UnspecifiedError, qt_error_string(int(EINVAL)));
    12751321        return 0;
  • trunk/src/corelib/io/qfsfileengine_win.cpp

    r651 r769  
    14851485        //### what to do with permissions if we don't use NTFS
    14861486        // for now just add all permissions and what about exe missions ??
    1487         // also qt_ntfs_permission_lookup is now not set by defualt ... should it ?
     1487        // also qt_ntfs_permission_lookup is now not set by deflt ... should it ?
    14881488        ret |= QAbstractFileEngine::ReadOtherPerm | QAbstractFileEngine::ReadGroupPerm
    14891489            | QAbstractFileEngine::ReadOwnerPerm | QAbstractFileEngine::ReadUserPerm
  • trunk/src/corelib/io/qiodevice.cpp

    r651 r769  
    8585#endif
    8686
    87 #ifndef QIODEVICE_BUFFERSIZE
    88 #define QIODEVICE_BUFFERSIZE Q_INT64_C(16384)
    89 #endif
    90 
    9187#define Q_VOID
    9288
     
    124120    : openMode(QIODevice::NotOpen), buffer(QIODEVICE_BUFFERSIZE),
    125121      pos(0), devicePos(0)
     122
    126123       , baseReadLineDataCalled(false)
     124
    127125       , accessMode(Unset)
    128126#ifdef QT_NO_QOBJECT
     
    283281    meaningless when used with some subclasses. Some of these
    284282    restrictions are implied by the type of device that is represented
    285     by a subclass; for example, access to a QBuffer is always
    286     unbuffered. In other cases, the restriction may be due to the
     283    by a subclass. In other cases, the restriction may be due to the
    287284    implementation, or may be imposed by the underlying platform; for
    288285    example, QTcpSocket does not support \c Unbuffered mode, and
     
    451448void QIODevice::setOpenMode(OpenMode openMode)
    452449{
     450
    453451#if defined QIODEVICE_DEBUG
    454452    printf("%p QIODevice::setOpenMode(0x%x)\n", this, int(openMode));
    455453#endif
    456     d_func()->openMode = openMode;
    457     d_func()->accessMode = QIODevicePrivate::Unset;
     454    d->openMode = openMode;
     455    d->accessMode = QIODevicePrivate::Unset;
     456    d->firstRead = true;
     457    if (!isReadable())
     458        d->buffer.clear();
    458459}
    459460
     
    539540    d->buffer.clear();
    540541    d->accessMode = QIODevicePrivate::Unset;
     542
    541543#if defined QIODEVICE_DEBUG
    542544    printf("%p QIODevice::open(0x%x)\n", this, quint32(mode));
     
    568570    d->pos = 0;
    569571    d->buffer.clear();
     572
    570573}
    571574
     
    731734}
    732735
     736
     737
     738
     739
     740
     741
    733742/*!
    734743    Reads at most \a maxSize bytes from the device into \a data, and
     
    747756{
    748757    Q_D(QIODevice);
    749     CHECK_READABLE(read, qint64(-1));
    750     CHECK_MAXLEN(read, qint64(-1));
    751758
    752759#if defined QIODEVICE_DEBUG
     
    754761           this, data, int(maxSize), int(d->pos), int(d->buffer.size()));
    755762#endif
    756     const bool sequential = d->isSequential();
    757763
    758764    // Short circuit for getChar()
     
    760766        int chint;
    761767        while ((chint = d->buffer.getChar()) != -1) {
    762             if (!sequential)
    763                 ++d->pos;
     768            ++(*d->pPos);
    764769
    765770            char c = char(uchar(chint));
     
    775780    }
    776781
     782
    777783    qint64 readSoFar = 0;
    778784    bool moreToRead = true;
    779785    do {
    780         int lastReadChunkSize = 0;
    781 
    782786        // Try reading from the buffer.
    783         if (!d->buffer.isEmpty()) {
    784             lastReadChunkSize = d->buffer.read(data + readSoFar, maxSize - readSoFar);
     787        int lastReadChunkSize = d->buffer.read(data, maxSize);
     788        if (lastReadChunkSize > 0) {
     789            *d->pPos += lastReadChunkSize;
    785790            readSoFar += lastReadChunkSize;
    786             if (!sequential)
    787                 d->pos += lastReadChunkSize;
     791            // fast exit when satisfied by buffer
     792            if (lastReadChunkSize == maxSize && !(d->openMode & Text))
     793                return readSoFar;
     794
     795            data += lastReadChunkSize;
     796            maxSize -= lastReadChunkSize;
    788797#if defined QIODEVICE_DEBUG
    789798            printf("%p \treading %d bytes from buffer into position %d\n", this, lastReadChunkSize,
    790799                   int(readSoFar) - lastReadChunkSize);
    791800#endif
    792         } else if ((d->openMode & Unbuffered) == 0 && maxSize < QIODEVICE_BUFFERSIZE) {
    793             // In buffered mode, we try to fill up the QIODevice buffer before
    794             // we do anything else.
    795             int bytesToBuffer = qMax(maxSize - readSoFar, QIODEVICE_BUFFERSIZE);
    796             char *writePointer = d->buffer.reserve(bytesToBuffer);
    797 
    798             // Make sure the device is positioned correctly.
    799             if (d->pos != d->devicePos && !sequential && !seek(d->pos))
    800                 return qint64(-1);
    801             qint64 readFromDevice = readData(writePointer, bytesToBuffer);
    802             d->buffer.chop(bytesToBuffer - (readFromDevice < 0 ? 0 : int(readFromDevice)));
    803 
    804             if (readFromDevice > 0) {
    805                 if (!sequential)
    806                     d->devicePos += readFromDevice;
    807 #if defined QIODEVICE_DEBUG
    808                 printf("%p \treading %d from device into buffer\n", this, int(readFromDevice));
    809 #endif
    810 
    811                 if (readFromDevice < bytesToBuffer)
    812                     d->buffer.truncate(int(readFromDevice));
    813                 if (!d->buffer.isEmpty()) {
    814                     lastReadChunkSize = d->buffer.read(data + readSoFar, maxSize - readSoFar);
    815                     readSoFar += lastReadChunkSize;
    816                     if (!sequential)
    817                         d->pos += lastReadChunkSize;
    818 #if defined QIODEVICE_DEBUG
    819                     printf("%p \treading %d bytes from buffer at position %d\n", this,
    820                            lastReadChunkSize, int(readSoFar));
    821 #endif
     801        } else {
     802            if (d->firstRead) {
     803                // this is the first time the file has been read, check it's valid and set up pos pointers
     804                // for fast pos updates.
     805                CHECK_READABLE(read, qint64(-1));
     806                d->firstRead = false;
     807                if (d->isSequential()) {
     808                    d->pPos = &d->seqDumpPos;
     809                    d->pDevicePos = &d->seqDumpPos;
     810                }
     811            }
     812
     813            if (!maxSize)
     814                return readSoFar;
     815
     816            if ((d->openMode & Unbuffered) == 0 && maxSize < QIODEVICE_BUFFERSIZE) {
     817                // In buffered mode, we try to fill up the QIODevice buffer before
     818                // we do anything else.
     819                // buffer is empty at this point, try to fill it
     820                int bytesToBuffer = QIODEVICE_BUFFERSIZE;
     821                char *writePointer = d->buffer.reserve(bytesToBuffer);
     822
     823                // Make sure the device is positioned correctly.
     824                if (d->pos != d->devicePos && !d->isSequential() && !seek(d->pos))
     825                    return readSoFar ? readSoFar : qint64(-1);
     826                qint64 readFromDevice = readData(writePointer, bytesToBuffer);
     827                d->buffer.chop(bytesToBuffer - (readFromDevice < 0 ? 0 : int(readFromDevice)));
     828
     829                if (readFromDevice > 0) {
     830                    *d->pDevicePos += readFromDevice;
     831#if defined QIODEVICE_DEBUG
     832                    printf("%p \treading %d from device into buffer\n", this, int(readFromDevice));
     833#endif
     834
     835                    if (!d->buffer.isEmpty()) {
     836                        lastReadChunkSize = d->buffer.read(data, maxSize);
     837                        readSoFar += lastReadChunkSize;
     838                        data += lastReadChunkSize;
     839                        maxSize -= lastReadChunkSize;
     840                        *d->pPos += lastReadChunkSize;
     841#if defined QIODEVICE_DEBUG
     842                        printf("%p \treading %d bytes from buffer at position %d\n", this,
     843                               lastReadChunkSize, int(readSoFar));
     844#endif
     845                    }
    822846                }
    823847            }
     
    825849
    826850        // If we need more, try reading from the device.
    827         if (readSoFar < maxSize) {
     851        if () {
    828852            // Make sure the device is positioned correctly.
    829             if (d->pos != d->devicePos && !sequential && !seek(d->pos))
    830                 return qint64(-1);
    831             qint64 readFromDevice = readData(data + readSoFar, maxSize - readSoFar);
     853            if (d->pos != d->devicePos && ! && !seek(d->pos))
     854                return qint64(-1);
     855            qint64 readFromDevice = readData(data);
    832856#if defined QIODEVICE_DEBUG
    833857            printf("%p \treading %d bytes from device (total %d)\n", this, int(readFromDevice), int(readSoFar));
     
    837861                return -1;
    838862            }
    839             if (readFromDevice <= 0) {
    840                 moreToRead = false;
    841             } else {
    842                 // see if we read as much data as we asked for
    843                 if (readFromDevice < maxSize - readSoFar)
    844                     moreToRead = false;
    845 
     863            if (readFromDevice > 0) {
    846864                lastReadChunkSize += int(readFromDevice);
    847865                readSoFar += readFromDevice;
    848                 if (!sequential) {
    849                     d->pos += readFromDevice;
    850                     d->devicePos += readFromDevice;
    851                 }
     866               
     867                = readFromDevice;
     868                Pos += readFromDevice;
     869               
    852870            }
    853         } else {
    854             moreToRead = false;
    855871        }
     872
     873
    856874
    857875        if (readSoFar && d->openMode & Text) {
    858             char *readPtr = data + readSoFar - lastReadChunkSize;
    859             const char *endPtr = data + readSoFar;
     876            char *readPtr = data - lastReadChunkSize;
     877            const char *endPtr = data;
    860878
    861879            if (readPtr < endPtr) {
     
    872890                    if (ch != '\r')
    873891                        *writePtr++ = ch;
    874                     else
     892                    else
    875893                        --readSoFar;
     894
     895
     896
    876897                }
    877898
     
    887908    printf("%p \treturning %d, d->pos == %d, d->buffer.size() == %d\n", this,
    888909           int(readSoFar), int(d->pos), d->buffer.size());
    889     debugBinaryString(data, readSoFar);
     910    debugBinaryString(data, readSoFar);
    890911#endif
    891912    return readSoFar;
    892913}
     914
     915
     916
     917
    893918
    894919/*!
     
    9991024}
    10001025
     1026
     1027
     1028
     1029
     1030
     1031
    10011032/*!
    10021033    This function reads a line of ASCII characters from the device, up
     
    10041035    data, and returns the number of bytes read. If a line could not be
    10051036    read but no error ocurred, this function returns 0. If an error
    1006     occurs, this function returns what it could the length of what
    1007     could be read, or -1 if nothing was read.
     1037    occurs, this function returns
     1038    -1 if nothing was read.
    10081039
    10091040    A terminating '\0' byte is always appended to \a data, so \a
     
    12301261    return readSoFar;
    12311262}
     1263
     1264
     1265
     1266
    12321267
    12331268/*!
     
    14181453bool QIODevice::getChar(char *c)
    14191454{
    1420     Q_D(QIODevice);
    1421     CHECK_READABLE(getChar, false);
    1422 
     1455    // readability checked in read()
    14231456    char ch;
    14241457    return (1 == read(c ? c : &ch, 1));
  • trunk/src/corelib/io/qiodevice_p.h

    r651 r769  
    6565QT_BEGIN_NAMESPACE
    6666
     67
     68
     69
     70
     71
     72
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
     100
     101
     102
     103
     104
     105
     106
     107
     108
     109
     110
     111
     112
     113
     114
     115
     116
     117
     118
     119
     120
     121
     122
     123
     124
     125
     126
     127
     128
     129
     130
     131
     132
     133
     134
     135
     136
     137
     138
     139
     140
     141
     142
     143
     144
     145
     146
     147
     148
     149
     150
     151
     152
     153
     154
     155
     156
     157
     158
     159
     160
     161
     162
     163
     164
     165
     166
     167
     168
     169
     170
     171
     172
     173
     174
     175
     176
     177
     178
     179
     180
     181
     182
     183
     184
     185
     186
    67187class Q_CORE_EXPORT QIODevicePrivate
    68188#ifndef QT_NO_QOBJECT
     
    79199    QString errorString;
    80200
    81     QRingBuffer buffer;
     201    QBuffer buffer;
    82202    qint64 pos;
    83203    qint64 devicePos;
     204
     205
     206
     207
    84208    bool baseReadLineDataCalled;
     209
    85210
    86211    virtual bool putCharHelper(char c);
  • trunk/src/corelib/io/qprocess.cpp

    r651 r769  
    552552    the interpreter to execute the desired command.
    553553
     554
     555
     556
     557
     558
     559
     560
     561
     562
     563
    554564    \sa QBuffer, QFile, QTcpSocket
    555565*/
     
    20302040    calling kill().
    20312041
     2042
     2043
     2044
    20322045    \note Terminating running processes from other processes will typically
    20332046    cause a panic in Symbian due to platform security.
    20342047
     2048
    20352049    \sa kill()
    20362050*/
     
    20472061    SIGKILL signal is sent to the process.
    20482062
     2063
     2064
     2065
     2066
    20492067    \sa terminate()
    20502068*/
  • trunk/src/corelib/io/qprocess_symbian.cpp

    r651 r769  
    238238                endQuote += QLatin1String("\\");
    239239            }
    240             commandLine += QLatin1String(" \"") + tmp.left(i) + endQuote;
     240            commandLine += QLatin1String(";
    241241        } else {
    242             commandLine += QLatin1Char(' ') + tmp;
     242            commandLine += ;
    243243        }
    244244    }
     245
     246
     247
     248
    245249}
    246250
     
    372376QProcessActive::~QProcessActive()
    373377{
     378
    374379    process = NULL;
    375380    pproc = NULL;
     
    478483QProcessManagerMediator::~QProcessManagerMediator()
    479484{
     485
    480486    processManagerThread.Close();
    481487    currentCommand = ENoCommand;
  • trunk/src/corelib/io/qprocess_unix.cpp

    r651 r769  
    784784    // did we read an error message?
    785785    if (i > 0)
    786         q_func()->setErrorString(QString::fromUtf16(buf, i / sizeof(QChar)));
     786        q_func()->setErrorString(QStringbuf, i / sizeof(QChar)));
    787787
    788788    return i <= 0;
  • trunk/src/corelib/io/qresource.cpp

    r651 r769  
    556556  \obsolete
    557557
     558
     559
    558560  Adds \a path to the search paths searched in to find resources that are
    559561  not specified with an absolute path. The \a path must be an absolute
     
    562564  The default search path is to search only in the root (\c{:/}). The last
    563565  path added will be consulted first upon next QResource creation.
    564 
    565   Use QDir::addSearchPath() with a prefix instead.
    566 */
    567 
     566*/
    568567void
    569568QResource::addSearchPath(const QString &path)
     
    579578
    580579/*!
     580
     581
     582
     583
    581584  Returns the current search path list. This list is consulted when
    582585  creating a relative resource.
  • trunk/src/corelib/io/qsettings.cpp

    r651 r769  
    10921092}
    10931093
    1094 static QString getPath(QSettings::Format format, QSettings::Scope scope)
    1095 {
    1096     Q_ASSERT((int)QSettings::NativeFormat == 0);
    1097     Q_ASSERT((int)QSettings::IniFormat == 1);
    1098 
     1094static void initDefaultPaths(QMutexLocker *locker)
     1095{
     1096    PathHash *pathHash = pathHashFunc();
    10991097    QString homePath = QDir::homePath();
    11001098    QString systemPath;
    11011099
    1102     QMutexLocker locker(globalMutex());
    1103     PathHash *pathHash = pathHashFunc();
    1104     bool loadSystemPath = pathHash->isEmpty();
    1105     locker.unlock();
    1106 
    1107     if (loadSystemPath) {
    1108         /*
    1109            QLibraryInfo::location() uses QSettings, so in order to
    1110            avoid a dead-lock, we can't hold the global mutex while
    1111            calling it.
    1112        */
    1113         systemPath = QLibraryInfo::location(QLibraryInfo::SettingsPath);
    1114         systemPath += QLatin1Char('/');
    1115     }
    1116 
    1117     locker.relock();
     1100    locker->unlock();
     1101       
     1102    /*
     1103       QLibraryInfo::location() uses QSettings, so in order to
     1104       avoid a dead-lock, we can't hold the global mutex while
     1105       calling it.
     1106    */
     1107    systemPath = QLibraryInfo::location(QLibraryInfo::SettingsPath);
     1108    systemPath += QLatin1Char('/');
     1109
     1110    locker->relock();
    11181111    if (pathHash->isEmpty()) {
    11191112        /*
     
    11731166#endif
    11741167    }
     1168
     1169
     1170
     1171
     1172
     1173
     1174
     1175
     1176
     1177
     1178
    11751179
    11761180    QString result = pathHash->value(pathHashKey(format, scope));
     
    34833487    QMutexLocker locker(globalMutex());
    34843488    PathHash *pathHash = pathHashFunc();
     3489
     3490
    34853491    pathHash->insert(pathHashKey(format, scope), path + QDir::separator());
    34863492}
  • trunk/src/corelib/io/qurl.cpp

    r651 r769  
    339339    bool hasFragment;
    340340    bool isValid;
     341
    341342
    342343    char valueDelimiter;
     
    438439
    439440// scheme      = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
    440 static void QT_FASTCALL _scheme(const char **ptr, QUrlParseData *parseData)
     441static QT_FASTCALL _scheme(const char **ptr, QUrlParseData *parseData)
    441442{
    442443    bool first = true;
     444
    443445
    444446    parseData->scheme = *ptr;
     
    447449        if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) {
    448450            ;
    449         } else if (!first && ((ch >= '0' && ch <= '9') || ch == '+' || ch == '-' || ch == '.')) {
    450             ;
     451        } else if ((ch >= '0' && ch <= '9') || ch == '+' || ch == '-' || ch == '.') {
     452            if (first)
     453                isSchemeValid = false;
    451454        } else {
    452455            break;
     
    458461
    459462    if (**ptr != ':') {
     463
    460464        *ptr = parseData->scheme;
    461465    } else {
     
    463467        ++(*ptr); // skip ':'
    464468    }
     469
     470
    465471}
    466472
     
    29862992        if (c == '-' || (c >= '0' && c <= '9')
    29872993            || (c >= 'A' && c <= 'Z')
    2988             || (c >= 'a' && c <= 'z'))
     2994            || (c >= 'a' && c <= 'z')
     2995            //underscore is not supposed to be allowed, but other browser accept it (QTBUG-7434)
     2996            || c == '_')
    29892997            continue;
    29902998
     
    31253133
    31263134static const char * const idn_whitelist[] = {
    3127     "ac", "at",
    3128     "br",
     3135    "ac", "at",
     3136    "br",
    31293137    "cat", "ch", "cl", "cn",
    31303138    "de", "dk",
     3139
    31313140    "fi",
    31323141    "gr",
     
    31423151    "th", "tm", "tw",
    31433152    "vn",
     3153
     3154
     3155
    31443156};
    31453157
     
    32423254        int idx = nextDotDelimiter(domain, lastIdx);
    32433255        int labelLength = idx - lastIdx;
    3244         if (labelLength == 0)
     3256        if (labelLength == 0) {
     3257            if (idx == domain.length())
     3258                break;
    32453259            return QString(); // two delimiters in a row -- empty label not allowed
     3260
    32463261
    32473262        // RFC 3490 says, about the ToASCII operation:
     
    32973312            labelLength = result.length() - prevLen;
    32983313            register int toReserve = labelLength + 4 + 6; // "xn--" plus some extra bytes
     3314
    32993315            if (toReserve > aceForm.capacity())
    33003316                aceForm.reserve(toReserve);
     
    33333349    port = -1;
    33343350    isValid = false;
     3351
    33353352    parsingMode = QUrl::TolerantMode;
    33363353    valueDelimiter = '=';
     
    33593376      hasFragment(copy.hasFragment),
    33603377      isValid(copy.isValid),
     3378
    33613379      valueDelimiter(copy.valueDelimiter),
    33623380      pairDelimiter(copy.pairDelimiter),
     
    33893407    } else {
    33903408        that->host = qt_ACE_do(host, NormalizeAce);
     3409
     3410
    33913411    }
    33923412    return that->host;
     
    34653485void QUrlPrivate::setAuthority(const QString &auth)
    34663486{
     3487
    34673488    if (auth.isEmpty())
    34683489        return;
     
    37413762
    37423763    // optional scheme
    3743     _scheme(ptr, &parseData);
     3764    bool isSchemeValid = _scheme(ptr, &parseData);
     3765
     3766    if (isSchemeValid == false) {
     3767        that->isValid = false;
     3768        char ch = *((*ptr)++);
     3769        that->errorInfo.setParams(*ptr, QT_TRANSLATE_NOOP(QUrl, "unexpected URL scheme"),
     3770                                  0, ch);
     3771        QURL_SETFLAG(that->stateFlags, Validated | Parsed);
     3772#if defined (QURL_DEBUG)
     3773        qDebug("QUrlPrivate::parse(), unrecognized: %c%s", ch, *ptr);
     3774#endif
     3775        return;
     3776    }
    37443777
    37453778    // hierpart
     
    41434176    if (!QURL_HASFLAG(d->stateFlags, QUrlPrivate::Validated)) d->validate();
    41444177
    4145     return d->isValid;
     4178    return d->isValid;
    41464179}
    41474180
     
    43954428    detach();
    43964429    QURL_UNSETFLAG(d->stateFlags, QUrlPrivate::Validated | QUrlPrivate::Normalized);
    4397 
    43984430    d->setAuthority(authority);
    43994431}
     
    46164648    if (!QURL_HASFLAG(d->stateFlags, QUrlPrivate::Parsed)) d->parse();
    46174649    detach();
     4650
    46184651    QURL_UNSETFLAG(d->stateFlags, QUrlPrivate::Validated | QUrlPrivate::Normalized | QUrlPrivate::HostCanonicalized);
    46194652
Note: See TracChangeset for help on using the changeset viewer.