mirror of
https://github.com/aseprite/aseprite.git
synced 2024-12-30 12:19:04 +00:00
Go to Desktop instead of showing an error if a parent folder is deleted in the middle of files navigation
This commit is contained in:
parent
c457f1680a
commit
0e9001fbd3
@ -961,7 +961,7 @@ static FileItem* get_fileitem_by_fullpidl(LPITEMIDLIST fullpidl, bool create_if_
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
// new file-item
|
// new file-item
|
||||||
FileItem* fileitem = new FileItem(nullptr);
|
auto fileitem = std::make_unique<FileItem>(nullptr);
|
||||||
fileitem->m_fullpidl = clone_pidl(fullpidl);
|
fileitem->m_fullpidl = clone_pidl(fullpidl);
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -974,25 +974,25 @@ static FileItem* get_fileitem_by_fullpidl(LPITEMIDLIST fullpidl, bool create_if_
|
|||||||
free_pidl(parent_fullpidl);
|
free_pidl(parent_fullpidl);
|
||||||
|
|
||||||
// The parent folder is sometimes deleted for some reasons. In
|
// The parent folder is sometimes deleted for some reasons. In
|
||||||
// that case, m_parent becomes nullptr, which can causes crash.
|
// that case, m_parent becomes nullptr, so we cannot use it
|
||||||
if (fileitem->m_parent == nullptr) {
|
// anymore. Here we just return nullptr to indicate that the item
|
||||||
throw std::runtime_error(
|
// doesn't exist anymore.
|
||||||
"Unexpected file system change. Please check the file.");
|
if (fileitem->m_parent == nullptr)
|
||||||
}
|
return nullptr;
|
||||||
|
|
||||||
// Get specific pidl attributes
|
// Get specific pidl attributes
|
||||||
if (fileitem->m_pidl &&
|
if (fileitem->m_pidl &&
|
||||||
fileitem->m_parent) {
|
fileitem->m_parent) {
|
||||||
attrib = get_pidl_attrib(fileitem, attrib);
|
attrib = get_pidl_attrib(fileitem.get(), attrib);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
update_by_pidl(fileitem, attrib);
|
update_by_pidl(fileitem.get(), attrib);
|
||||||
put_fileitem(fileitem);
|
put_fileitem(fileitem.get());
|
||||||
|
|
||||||
//LOG("FS: fileitem %p created %s with parent %p\n", fileitem, fileitem->keyname.c_str(), fileitem->parent);
|
//LOG("FS: fileitem %p created %s with parent %p\n", fileitem, fileitem->keyname.c_str(), fileitem->parent);
|
||||||
|
|
||||||
return fileitem;
|
return fileitem.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inserts the fileitem in the hash map of items.
|
// Inserts the fileitem in the hash map of items.
|
||||||
|
Loading…
Reference in New Issue
Block a user