mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
MessengerWindow::insertPeers:
- memory leak - return of takeTopLevelItem and takeChild are not deleted - possible crash, when child has disappeared fixed load and save of window state, i forgot to give the name of the window to the settings class git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2916 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
93cd5e67f8
commit
48d2007f81
@ -308,7 +308,7 @@ void MessengerWindow::insertPeers()
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
peertreeWidget->takeTopLevelItem(index);
|
||||
delete (peertreeWidget->takeTopLevelItem(index));
|
||||
} else {
|
||||
index++;
|
||||
}
|
||||
@ -335,7 +335,7 @@ void MessengerWindow::insertPeers()
|
||||
if ((!rsPeers->getPeerDetails(*it, detail) || !detail.accept_connection)
|
||||
&& detail.gpg_id != rsPeers->getGPGOwnId()) {
|
||||
//don't accept anymore connection, remove from the view
|
||||
peertreeWidget->takeTopLevelItem(peertreeWidget->indexOfTopLevelItem(gpg_item));
|
||||
delete (peertreeWidget->takeTopLevelItem(peertreeWidget->indexOfTopLevelItem(gpg_item)));
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -352,7 +352,7 @@ void MessengerWindow::insertPeers()
|
||||
while (childIndex < gpg_item->childCount()) {
|
||||
std::string ssl_id = (gpg_item->child(childIndex))->text(3).toStdString();
|
||||
if (!rsPeers->isFriend(ssl_id)) {
|
||||
gpg_item->takeChild(childIndex);
|
||||
delete (gpg_item->takeChild(childIndex));
|
||||
} else {
|
||||
childIndex++;
|
||||
}
|
||||
@ -364,7 +364,7 @@ void MessengerWindow::insertPeers()
|
||||
std::list<std::string> sslContacts;
|
||||
rsPeers->getSSLChildListOfGPGId(detail.gpg_id, sslContacts);
|
||||
for(std::list<std::string>::iterator sslIt = sslContacts.begin(); sslIt != sslContacts.end(); sslIt++) {
|
||||
QTreeWidgetItem *sslItem;
|
||||
QTreeWidgetItem *sslItem = NULL;
|
||||
|
||||
//find the corresponding sslItem child item of the gpg item
|
||||
bool newChild = true;
|
||||
@ -375,16 +375,20 @@ void MessengerWindow::insertPeers()
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (newChild) {
|
||||
sslItem = new QTreeWidgetItem(1); //set type to 1 for custom popup menu
|
||||
}
|
||||
|
||||
RsPeerDetails sslDetail;
|
||||
if (!rsPeers->getPeerDetails(*sslIt, sslDetail) || !rsPeers->isFriend(*sslIt)) {
|
||||
std::cerr << "Removing widget from the view : id : " << *sslIt << std::endl;
|
||||
if (sslItem) {
|
||||
//child has disappeared, remove it from the gpg_item
|
||||
gpg_item->removeChild(sslItem);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sslItem == NULL) {
|
||||
sslItem = new QTreeWidgetItem(1); //set type to 1 for custom popup menu
|
||||
}
|
||||
|
||||
/* not displayed, used to find back the item */
|
||||
sslItem -> setText(3, QString::fromStdString(sslDetail.id));
|
||||
|
@ -97,7 +97,7 @@ RWindow::restoreWindowState()
|
||||
QVariant
|
||||
RWindow::getSetting(QString setting, QVariant defaultValue)
|
||||
{
|
||||
RshareSettings settings;
|
||||
RshareSettings settings(_name.toStdString());
|
||||
return settings.value(setting, defaultValue);
|
||||
}
|
||||
|
||||
@ -105,7 +105,7 @@ RWindow::getSetting(QString setting, QVariant defaultValue)
|
||||
void
|
||||
RWindow::saveSetting(QString prop, QVariant value)
|
||||
{
|
||||
RshareSettings settings;
|
||||
RshareSettings settings(_name.toStdString());
|
||||
settings.setValue(prop, value);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user