diff --git a/3rdparty/qredisclient b/3rdparty/qredisclient index 5b7d135dc..9fe79f7c1 160000 --- a/3rdparty/qredisclient +++ b/3rdparty/qredisclient @@ -1 +1 @@ -Subproject commit 5b7d135dc522b31d34f06e8c61ae1acfeb32ef24 +Subproject commit 9fe79f7c13b9811228db33abf75a83464a7cd2e2 diff --git a/src/app/models/treeoperations.cpp b/src/app/models/treeoperations.cpp index b2f0d0776..abd8313d5 100644 --- a/src/app/models/treeoperations.cpp +++ b/src/app/models/treeoperations.cpp @@ -221,32 +221,48 @@ void TreeOperations::deleteDbKey(ConnectionsTree::KeyItem& key, [this, &key](RedisClient::Response) { key.setRemoved(); QRegExp filter(key.getFullPath(), Qt::CaseSensitive, QRegExp::Wildcard); - emit m_events->closeDbKeys(m_connection, key.getDbIndex(), filter); + if (m_events) m_events->closeDbKeys(m_connection, key.getDbIndex(), filter); }, [this, callback](const QString& err) { QString errorMsg = QCoreApplication::translate("RDM", "Delete key error: %1").arg(err); callback(errorMsg); - m_events->error(errorMsg); + if (m_events) m_events->error(errorMsg); }); } void TreeOperations::deleteDbKeys(ConnectionsTree::DatabaseItem& db) { - requestBulkOperation(db, BulkOperations::Manager::Operation::DELETE_KEYS, - [this, &db](QRegExp filter, int, const QStringList&) { - db.reload(); - emit m_events->closeDbKeys(m_connection, - db.getDbIndex(), filter); - }); + auto self = sharedFromThis().toWeakRef(); + requestBulkOperation( + db, BulkOperations::Manager::Operation::DELETE_KEYS, + [self, this, &db](QRegExp filter, int, const QStringList&) { + if (!self) { + return; + } + + db.reload(); + + if (m_events) { + emit m_events->closeDbKeys(m_connection, db.getDbIndex(), filter); + } + }); } void TreeOperations::deleteDbNamespace(ConnectionsTree::NamespaceItem& ns) { - requestBulkOperation(ns, BulkOperations::Manager::Operation::DELETE_KEYS, - [this, &ns](QRegExp filter, int, const QStringList&) { - ns.setRemoved(); - emit m_events->closeDbKeys(m_connection, - ns.getDbIndex(), filter); - }); + auto self = sharedFromThis().toWeakRef(); + requestBulkOperation( + ns, BulkOperations::Manager::Operation::DELETE_KEYS, + [this, self, &ns](QRegExp filter, int, const QStringList&) { + if (!self) { + return; + } + + ns.setRemoved(); + + if (m_events) { + emit m_events->closeDbKeys(m_connection, ns.getDbIndex(), filter); + } + }); } void TreeOperations::setTTL(ConnectionsTree::AbstractNamespaceItem& ns) { diff --git a/src/modules/bulk-operations/operations/deleteoperation.cpp b/src/modules/bulk-operations/operations/deleteoperation.cpp index bb231d15c..959f52104 100644 --- a/src/modules/bulk-operations/operations/deleteoperation.cpp +++ b/src/modules/bulk-operations/operations/deleteoperation.cpp @@ -59,13 +59,17 @@ void BulkOperations::DeleteOperation::deleteKeys( int expectedResponses = rawCmds.size(); m_connection->pipelinedCmd( - rawCmds, this, -1, + rawCmds, this, m_dbIndex, [this, expectedResponses, callback](const RedisClient::Response &r, QString err) { if (!err.isEmpty()) { return processError(err); } + if (r.isErrorMessage()) { + return processError(r.value().toByteArray()); + } + QMutexLocker l(&m_processedKeysMutex); QVariant incrResult = r.value();