From: Olivier Goffart Date: Wed, 15 Mar 2017 16:17:33 +0000 (+0100) Subject: Attempt to fix a crash in FolderStatusModel::slotUpdateDirectories X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~790^2~3 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=8e68e0321c8fabd6e5aafed1020823a29fee30d8;p=nextcloud-desktop.git 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. --- diff --git a/src/gui/folderstatusmodel.cpp b/src/gui/folderstatusmodel.cpp index 65ff918d5..a4079ff07 100644 --- a/src/gui/folderstatusmodel.cpp +++ b/src/gui/folderstatusmodel.cpp @@ -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 undecidedIndexes;