Fix error in subfolders loading

BUG: 357572
parent 8ec4653e
......@@ -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".
ProjectFolder *parentFolder = m_rootFolder;
QStringList folderIds = foldersData.keys();
for (int i = 0; i < folderIds.count(); i++) {
QString id = folderIds.at(i);
QString parentId = id.section(".", 0, 0);
if (parentId == "-1") {
QStringList secondProcess;
while(!folderIds.isEmpty()) {
//for (int i = 0; i < folderIds.count(); i++) {
QString id = folderIds.takeFirst();
QString parentId = id.section(QStringLiteral("."), 0, 0);
if (parentId == QLatin1String("-1")) {
parentFolder = m_rootFolder;
}
else {
......@@ -1026,9 +1028,17 @@ void Bin::slotLoadFolders(QMap<QString,QString> foldersData)
// parent folder not yet created, create unnamed placeholder
parentFolder = new ProjectFolder(parentId, QString(), parentFolder);
} else if (parentFolder == NULL) {
// Strange, folder without parent detected, create standard one
// folder without parent detected, create standard one
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
QString folderId = id.section(".", 1, 1);
......
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