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:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/sql/drivers/sqlite/qsql_sqlite.cpp

    r651 r769  
    246246                break;
    247247            default:
    248                 values[i + idx] = QString::fromUtf16(static_cast<const ushort *>(
     248                values[i + idx] = QString *>(
    249249                            sqlite3_column_text16(stmt, i)),
    250                             sqlite3_column_bytes16(stmt, i) / sizeof(ushort));
     250                            sqlite3_column_bytes16(stmt, i) / sizeof());
    251251                break;
    252252            }
     
    260260        sqlite3_reset(stmt);
    261261        return false;
     262
    262263    case SQLITE_ERROR:
    263264        // SQLITE_ERROR is a generic error code and we must call sqlite3_reset()
     
    501502}
    502503
    503 static int qGetSqliteTimeout(QString opts)
    504 {
    505     enum { DefaultTimeout = 5000 };
    506 
    507     opts.remove(QLatin1Char(' '));
    508     foreach(QString option, opts.split(QLatin1Char(';'))) {
    509         if (option.startsWith(QLatin1String("QSQLITE_BUSY_TIMEOUT="))) {
    510             bool ok;
    511             int nt = option.mid(21).toInt(&ok);
    512             if (ok)
    513                 return nt;
    514         }
    515     }
    516     return DefaultTimeout;
    517 }
    518 
    519 static int qGetSqliteOpenMode(QString opts)
    520 {
    521     opts.remove(QLatin1Char(' '));
    522     foreach(QString option, opts.split(QLatin1Char(';'))) {
    523         if (option == QLatin1String("QSQLITE_OPEN_READONLY"))
    524                 return SQLITE_OPEN_READONLY;
    525     }
    526     return SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE;
    527 }
    528 
    529504/*
    530505   SQLite dbs have no user name, passwords, hosts or ports.
     
    538513    if (db.isEmpty())
    539514        return false;
    540 
    541     if (sqlite3_open_v2(db.toUtf8().constData(), &d->access, qGetSqliteOpenMode(conOpts), NULL) == SQLITE_OK) {
    542         sqlite3_busy_timeout(d->access, qGetSqliteTimeout(conOpts));
     515    bool sharedCache = false;
     516    int openMode = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, timeOut=5000;
     517    QStringList opts=QString(conOpts).remove(QLatin1Char(' ')).split(QLatin1Char(';'));
     518    foreach(const QString &option, opts) {
     519        if (option.startsWith(QLatin1String("QSQLITE_BUSY_TIMEOUT="))) {
     520            bool ok;
     521            int nt = option.mid(21).toInt(&ok);
     522            if (ok)
     523                timeOut = nt;
     524        }
     525        if (option == QLatin1String("QSQLITE_OPEN_READONLY"))
     526            openMode = SQLITE_OPEN_READONLY;
     527        if (option == QLatin1String("QSQLITE_ENABLE_SHARED_CACHE"))
     528            sharedCache = true;
     529    }
     530
     531    sqlite3_enable_shared_cache(sharedCache);
     532
     533    if (sqlite3_open_v2(db.toUtf8().constData(), &d->access, openMode, NULL) == SQLITE_OK) {
     534        sqlite3_busy_timeout(d->access, timeOut);
    543535        setOpen(true);
    544536        setOpenError(false);
Note: See TracChangeset for help on using the changeset viewer.