Fix dangling reference (#10135)

This commit is contained in:
Dmytro 2024-01-06 10:58:56 -08:00 committed by GitHub
parent d44486ce94
commit 5d64292ed8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -35,7 +35,7 @@ int Remove::executeWithDatabase(QSharedPointer<Database> database, QSharedPointe
auto& out = parser->isSet(Command::QuietOption) ? Utils::DEVNULL : Utils::STDOUT; auto& out = parser->isSet(Command::QuietOption) ? Utils::DEVNULL : Utils::STDOUT;
auto& err = Utils::STDERR; auto& err = Utils::STDERR;
auto& entryPath = parser->positionalArguments().at(1); auto entryPath = parser->positionalArguments().at(1);
QPointer<Entry> entry = database->rootGroup()->findEntryByPath(entryPath); QPointer<Entry> entry = database->rootGroup()->findEntryByPath(entryPath);
if (!entry) { if (!entry) {
err << QObject::tr("Entry %1 not found.").arg(entryPath) << endl; err << QObject::tr("Entry %1 not found.").arg(entryPath) << endl;
@ -50,7 +50,7 @@ int Remove::executeWithDatabase(QSharedPointer<Database> database, QSharedPointe
recycled = false; recycled = false;
} else { } else {
database->recycleEntry(entry); database->recycleEntry(entry);
}; }
QString errorMessage; QString errorMessage;
if (!database->save(Database::Atomic, {}, &errorMessage)) { if (!database->save(Database::Atomic, {}, &errorMessage)) {