From 8afa127ed55f4198a56ef6702655b55cee22e987 Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 12 Feb 2018 20:30:01 +0100 Subject: [PATCH 1/2] fixed crash in RsCollection creation --- .../src/gui/FileTransfer/TransfersDialog.cpp | 2 - .../src/gui/common/RsCollectionDialog.cpp | 78 ++++++++++++++----- 2 files changed, 60 insertions(+), 20 deletions(-) diff --git a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp index bde8c8c80..dfe8bae9c 100644 --- a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp @@ -1861,8 +1861,6 @@ void TransfersDialog::insertTransfers() std::set expanded_hashes ; std::set 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. diff --git a/retroshare-gui/src/gui/common/RsCollectionDialog.cpp b/retroshare-gui/src/gui/common/RsCollectionDialog.cpp index 3f0d1383d..8f7cb20be 100644 --- a/retroshare-gui/src/gui/common/RsCollectionDialog.cpp +++ b/retroshare-gui/src/gui/common/RsCollectionDialog.cpp @@ -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 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(); From 01cc2322e8e7f849ddc805e3aaba42d44c08dcd6 Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 12 Feb 2018 22:39:11 +0100 Subject: [PATCH 2/2] fixed appearing false line in Transfers --- retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp index dfe8bae9c..fad3b382c 100644 --- a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp @@ -154,7 +154,7 @@ public: if(!ref) // top level. The entry is that of a transfer { - if(!convertTabEntryToRefPointer(row,-1,subref)) + if(row >= mDownloads.size() || !convertTabEntryToRefPointer(row,-1,subref)) return QModelIndex() ; return createIndex(row,column,subref) ;