kio: check if the currently set URL is valid before updating in KDirLister::updateDirectory()

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-07-05 00:39:04 +03:00
parent 7762ec727b
commit db4190995a
2 changed files with 6 additions and 1 deletions

View file

@ -420,6 +420,11 @@ KUrl KDirLister::url() const
void KDirLister::updateDirectory()
{
if (!d->url.isValid()) {
// attempt to update before anything was listed or after invalid was listed
return;
}
// NOTE: no partial updates for non-local directories because the signals are bogus for
// some KIO slaves (such as trash:/, see kde-workspace/kioslave/trash/ktrash.cpp for example)
openUrl(d->url, d->recursive);

View file

@ -362,7 +362,7 @@ void KDirModelPrivate::_k_slotAddedItems(const KFileItemList& items)
KDirModelNode* result = nodeForUrl(directoryUrl); // O(depth)
// If the directory containing the items wasn't found, then we have a big problem.
// Are you calling KDirLister::openUrl(url,true,false)? Please use expandToUrl() instead.
// Are you calling KDirLister::openUrl()? Please use expandToUrl() instead.
if (!result) {
kError(7008) << "Items emitted in directory" << directoryUrl
<< "but that directory isn't in KDirModel!"