Prevent RSS folder from being moved into itself

PR #18619.
Closes #18446.
This commit is contained in:
Vladimir Golovnev 2023-02-27 09:08:18 +03:00 committed by GitHub
parent 2f9b313287
commit 8df68ac878
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View file

@ -185,8 +185,11 @@ nonstd::expected<void, QString> Session::moveItem(Item *item, const QString &des
if (!result)
return result.get_unexpected();
auto srcFolder = static_cast<Folder *>(m_itemsByPath.value(Item::parentPath(item->path())));
const auto destFolder = result.value();
if (static_cast<Item *>(destFolder) == item)
return nonstd::make_unexpected(tr("Couldn't move folder into itself."));
auto srcFolder = static_cast<Folder *>(m_itemsByPath.value(Item::parentPath(item->path())));
if (srcFolder != destFolder)
{
srcFolder->removeItem(item);