Fix error in subfolders loading

BUG: 357572
parent 8ec4653e
...@@ -1013,10 +1013,12 @@ void Bin::slotLoadFolders(QMap<QString,QString> foldersData) ...@@ -1013,10 +1013,12 @@ void Bin::slotLoadFolders(QMap<QString,QString> foldersData)
// Folder parent is saved in folderId, separated by a dot. for example "1.3" means parent folder id is "1" and new folder id is "3". // Folder parent is saved in folderId, separated by a dot. for example "1.3" means parent folder id is "1" and new folder id is "3".
ProjectFolder *parentFolder = m_rootFolder; ProjectFolder *parentFolder = m_rootFolder;
QStringList folderIds = foldersData.keys(); QStringList folderIds = foldersData.keys();
for (int i = 0; i < folderIds.count(); i++) { QStringList secondProcess;
QString id = folderIds.at(i); while(!folderIds.isEmpty()) {
QString parentId = id.section(".", 0, 0); //for (int i = 0; i < folderIds.count(); i++) {
if (parentId == "-1") { QString id = folderIds.takeFirst();
QString parentId = id.section(QStringLiteral("."), 0, 0);
if (parentId == QLatin1String("-1")) {
parentFolder = m_rootFolder; parentFolder = m_rootFolder;
} }
else { else {
...@@ -1026,8 +1028,16 @@ void Bin::slotLoadFolders(QMap<QString,QString> foldersData) ...@@ -1026,8 +1028,16 @@ void Bin::slotLoadFolders(QMap<QString,QString> foldersData)
// parent folder not yet created, create unnamed placeholder // parent folder not yet created, create unnamed placeholder
parentFolder = new ProjectFolder(parentId, QString(), parentFolder); parentFolder = new ProjectFolder(parentId, QString(), parentFolder);
} else if (parentFolder == NULL) { } else if (parentFolder == NULL) {
// Strange, folder without parent detected, create standard one // folder without parent detected, create standard one
parentFolder = new ProjectFolder(parentId, i18n("Folder"), m_rootFolder); if (secondProcess.contains(id)) {
// Orphaned folder
parentFolder = new ProjectFolder(parentId, i18n("Folder"), m_rootFolder);
}
else {
folderIds.append(id);
secondProcess << id;
continue;
}
} }
} }
// parent was found, create our folder // parent was found, create our folder
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment