Attempt to fix a crash in FolderStatusModel::slotUpdateDirectories

The backtrace looks like:

  File "atomic_base.h", line 396, in QString::~QString
  File "qlist.h", line 442, in OCC::FolderStatusModel::slotUpdateDirectories

This is the only QList operation, and it may crash if the list is empty.
It can be empty if the propfind returned empty results.
I'm not sure how this can be possible to have an empty list there since
the server is always supposed to return at least one entry, for the directory
itself. But it can happen if a directory was transformed in a file, or
if there is a bug on the server.
This commit is contained in:
Olivier Goffart 2017-03-15 17:17:33 +01:00
parent 881b32521b
commit 8e68e0321c

View file

@ -631,8 +631,8 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list)
const auto permissionMap = job->property(propertyPermissionMap).toMap();
QStringList sortedSubfolders = list;
// skip the parent item (first in the list)
sortedSubfolders.erase(sortedSubfolders.begin());
if (!sortedSubfolders.isEmpty())
sortedSubfolders.removeFirst(); // skip the parent item (first in the list)
Utility::sortFilenames(sortedSubfolders);
QVarLengthArray<int, 10> undecidedIndexes;