Create unique database connections per thread and remove them using the database connection name from the QSqlDatabase instance being used.

This commit is contained in:
Luis Ángel San Martín
2018-04-24 20:53:24 +02:00
parent 0ff7da1d2c
commit 52c76d5482
7 changed files with 84 additions and 69 deletions

View File

@ -396,7 +396,7 @@ void ReadingListModel::addNewLabel(const QString &name, YACReader::LabelColors c
endInsertRows();
QSqlDatabase::removeDatabase(_databasePath);
QSqlDatabase::removeDatabase(db.connectionName());
}
void ReadingListModel::addReadingList(const QString &name)
@ -423,7 +423,7 @@ void ReadingListModel::addReadingList(const QString &name)
endInsertRows();
QSqlDatabase::removeDatabase(_databasePath);
QSqlDatabase::removeDatabase(db.connectionName());
}
void ReadingListModel::addReadingListAt(const QString &name, const QModelIndex &mi)
@ -452,7 +452,7 @@ void ReadingListModel::addReadingListAt(const QString &name, const QModelIndex &
endInsertRows();
QSqlDatabase::removeDatabase(_databasePath);
QSqlDatabase::removeDatabase(db.connectionName());
}
bool ReadingListModel::isEditable(const QModelIndex &mi)
@ -523,7 +523,7 @@ void ReadingListModel::rename(const QModelIndex &mi, const QString &name)
emit dataChanged(index(mi.row(), 0), index(mi.row(), 0));
}
QSqlDatabase::removeDatabase(_databasePath);
QSqlDatabase::removeDatabase(db.connectionName());
}
void ReadingListModel::deleteItem(const QModelIndex &mi)
@ -557,7 +557,7 @@ void ReadingListModel::deleteItem(const QModelIndex &mi)
DBHelper::removeLabelFromDB(item->getId(), db);
}
QSqlDatabase::removeDatabase(_databasePath);
QSqlDatabase::removeDatabase(db.connectionName());
endRemoveRows();
}
@ -746,7 +746,7 @@ void ReadingListModel::reorderingChildren(QList<ReadingListItem *> children)
QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath);
DBHelper::reasignOrderToSublists(childrenIds, db);
QSqlDatabase::removeDatabase(_databasePath);
QSqlDatabase::removeDatabase(db.connectionName());
}
bool ReadingListModel::rowIsSpecialList(int row, const QModelIndex &parent) const