fixed crash in RsCollection creation

This commit is contained in:
csoler 2018-02-12 20:30:01 +01:00
parent fc3becacbf
commit 8afa127ed5
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
2 changed files with 60 additions and 20 deletions

View File

@ -1861,8 +1861,6 @@ void TransfersDialog::insertTransfers()
std::set<QString> expanded_hashes ;
std::set<QString> selected_hashes ;
std::cerr << "Updating transfers..." << std::endl;
DLListModel->update_transfers();
// Now show upload hashes. Here we use the "old" way, since the number of uploads is generally not so large.

View File

@ -1081,34 +1081,76 @@ void RsCollectionDialog::makeDir()
}
// Process all selected items
int count = ui._fileEntriesTW->selectedItems().count();
int curs = 0;
if (count == 0) curs = -1;
for (; curs < count; ++curs)
QList<QTreeWidgetItem*> selected = ui._fileEntriesTW->selectedItems();
if(selected.empty())
{
QTreeWidgetItem *item = NULL;
if (curs >= 0) {
item= ui._fileEntriesTW->selectedItems().at(curs);
} else {
item = getRootItem();
}
if (item) {
while (item->data(COLUMN_HASH, ROLE_TYPE).toUInt() != DIR_TYPE_DIR) {
QTreeWidgetItem *item = getRootItem();
ColFileInfo newChild;
newChild.name = childName;
newChild.filename_has_wrong_characters = false;
newChild.size = 0;
newChild.type = DIR_TYPE_DIR;
newChild.path = item->data(COLUMN_HASH, ROLE_PATH).toString()
+ "/" + item->data(COLUMN_HASH, ROLE_NAME).toString();
if (item == getRootItem()) newChild.path = "";
_newColFileInfos.push_back(newChild);
}
else
for(auto it(selected.begin());it!=selected.end();++it)
{
QTreeWidgetItem *item = *it;
while(item->data(COLUMN_HASH, ROLE_TYPE).toUInt() != DIR_TYPE_DIR)
item = item->parent();//Only Dir as Parent
}
ColFileInfo newChild;
newChild.name = childName;
newChild.filename_has_wrong_characters = false;
newChild.size = 0;
newChild.type = DIR_TYPE_DIR;
newChild.path = item->data(COLUMN_HASH, ROLE_PATH).toString()
+ "/" + item->data(COLUMN_HASH, ROLE_NAME).toString();
if (item == getRootItem()) newChild.path = "";
if (item == getRootItem())
newChild.path = "";
else
newChild.path = item->data(COLUMN_HASH, ROLE_PATH).toString() + "/" + item->data(COLUMN_HASH, ROLE_NAME).toString();
_newColFileInfos.push_back(newChild);
}
}
// // Process all selected items
// int count = ui._fileEntriesTW->selectedItems().count();
// int curs = 0;
// if (count == 0) curs = -1;
//
// for (; curs < count; ++curs)
// {
// QTreeWidgetItem *item = NULL;
// if (curs >= 0) {
// item= ui._fileEntriesTW->selectedItems().at(curs);
// } else {
// item = getRootItem();
// }
// if (item) {
// while (item->parent() != NULL && item->data(COLUMN_HASH, ROLE_TYPE).toUInt() != DIR_TYPE_DIR) {
// item = item->parent();//Only Dir as Parent
// }
// ColFileInfo newChild;
// newChild.name = childName;
// newChild.filename_has_wrong_characters = false;
// newChild.size = 0;
// newChild.type = DIR_TYPE_DIR;
// newChild.path = item->data(COLUMN_HASH, ROLE_PATH).toString()
// + "/" + item->data(COLUMN_HASH, ROLE_NAME).toString();
// if (item == getRootItem()) newChild.path = "";
//
// _newColFileInfos.push_back(newChild);
// }
// }
updateList();