X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcore%2Fabstractsqlstorage.cpp;h=6886c0fa89c8ba9375839d4fdfde94d22ec144cf;hb=e497bef2a6bd36874192ebef7fd1899ce28f7c9c;hp=3d339ec23beea9751c804fff3032b5912c03b612;hpb=0775b2fab5e91cbf3b40caa575d1ee44b6686350;p=quassel.git diff --git a/src/core/abstractsqlstorage.cpp b/src/core/abstractsqlstorage.cpp index 3d339ec2..6886c0fa 100644 --- a/src/core/abstractsqlstorage.cpp +++ b/src/core/abstractsqlstorage.cpp @@ -26,10 +26,10 @@ #include #include +int AbstractSqlStorage::_nextConnectionId = 0; AbstractSqlStorage::AbstractSqlStorage(QObject *parent) : Storage(parent), - _schemaVersion(0), - _nextConnectionId(0) + _schemaVersion(0) { } @@ -37,6 +37,7 @@ AbstractSqlStorage::~AbstractSqlStorage() { // disconnect the connections, so their deletion is no longer interessting for us QHash::iterator conIter; for(conIter = _connectionPool.begin(); conIter != _connectionPool.end(); conIter++) { + QSqlDatabase::removeDatabase(conIter.value()->name()); disconnect(conIter.value(), 0, this, 0); } } @@ -350,11 +351,11 @@ AbstractSqlMigrationReader::AbstractSqlMigrationReader() bool AbstractSqlMigrationReader::migrateTo(AbstractSqlMigrationWriter *writer) { if(!transaction()) { - qWarning() << "AbstractSqlMigrationReader::migrateTo(): unable to start reader stransaction!"; + qWarning() << "AbstractSqlMigrationReader::migrateTo(): unable to start reader's transaction!"; return false; } if(!writer->transaction()) { - qWarning() << "AbstractSqlMigrationReader::migrateTo(): unable to start writer stransaction!"; + qWarning() << "AbstractSqlMigrationReader::migrateTo(): unable to start writer's transaction!"; rollback(); // close the reader transaction; return false; } @@ -366,10 +367,6 @@ bool AbstractSqlMigrationReader::migrateTo(AbstractSqlMigrationWriter *writer) { if(!transferMo(QuasselUser, quasselUserMo)) return false; - SenderMO senderMo; - if(!transferMo(Sender, senderMo)) - return false; - IdentityMO identityMo; if(!transferMo(Identity, identityMo)) return false; @@ -386,6 +383,10 @@ bool AbstractSqlMigrationReader::migrateTo(AbstractSqlMigrationWriter *writer) { if(!transferMo(Buffer, bufferMo)) return false; + SenderMO senderMo; + if(!transferMo(Sender, senderMo)) + return false; + BacklogMO backlogMo; if(!transferMo(Backlog, backlogMo)) return false; @@ -398,6 +399,8 @@ bool AbstractSqlMigrationReader::migrateTo(AbstractSqlMigrationWriter *writer) { if(!transferMo(UserSetting, userSettingMo)) return false; + if(!_writer->postProcess()) + abortMigration(); return finalizeMigration(); } @@ -449,10 +452,11 @@ bool AbstractSqlMigrationReader::transferMo(MigrationObject moType, T &mo) { return false; } - qDebug() << qPrintable(QString("Transfering %1...").arg(AbstractSqlMigrator::migrationObject(moType))); + qDebug() << qPrintable(QString("Transferring %1...").arg(AbstractSqlMigrator::migrationObject(moType))); int i = 0; QFile file; file.open(stdout, QIODevice::WriteOnly); + while(readMo(mo)) { if(!_writer->writeMo(mo)) { abortMigration(QString("AbstractSqlMigrationReader::transferMo(): unable to transfer Migratable Object of type %1!").arg(AbstractSqlMigrator::migrationObject(moType))); @@ -468,6 +472,7 @@ bool AbstractSqlMigrationReader::transferMo(MigrationObject moType, T &mo) { file.write("\n"); file.flush(); } + qDebug() << "Done."; return true; }