FolderStatusModel: Check for null argument at start.
authorKlaas Freitag <freitag@owncloud.com>
Wed, 7 Oct 2015 15:59:33 +0000 (17:59 +0200)
committerKlaas Freitag <freitag@owncloud.com>
Tue, 27 Oct 2015 16:37:12 +0000 (17:37 +0100)
src/gui/folderstatusmodel.cpp

index 0f2c96c0b225db16f341e592cb7ff02a53abbd0b..8730ab8131af5f59aa164a16b14bbb4a80ddbb45 100644 (file)
@@ -349,13 +349,21 @@ FolderStatusModel::SubFolderInfo* FolderStatusModel::infoForIndex(const QModelIn
 
 QModelIndex FolderStatusModel::indexForPath(Folder *f, const QString& path) const
 {
+    if( !f ) {
+        return QModelIndex();
+    }
+
     int slashPos = path.lastIndexOf('/');
     if (slashPos == -1) {
         // first level folder
         for (int i = 0; i < _folders.size(); ++i) {
             if (_folders.at(i)._folder == f) {
+                if( path.isEmpty() ) { // the folder object
+                    return index(i, 0);
+                }
                 for (int j = 0; j < _folders.at(i)._subs.size(); ++j) {
-                    if (_folders.at(i)._subs.at(j)._name == path) {
+                    const QString subName = _folders.at(i)._subs.at(j)._name;
+                    if (subName == path) {
                         return index(j, 0, index(i));
                     }
                 }
@@ -499,6 +507,7 @@ void FolderStatusModel::fetchMore(const QModelIndex& parent)
     connect(job, SIGNAL(finishedWithError(QNetworkReply*)),
             this, SLOT(slotLscolFinishedWithError(QNetworkReply*)));
     job->start();
+
     QPersistentModelIndex persistentIndex(parent);
     job->setProperty(propertyParentIndexC , QVariant::fromValue(persistentIndex));