Merge pull request #2182 from csoler/v0.6-MemLeaks

Fixing mem leaks
This commit is contained in:
csoler 2020-12-30 20:58:32 +01:00 committed by GitHub
commit 159a2061f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 132 additions and 119 deletions

View file

@ -258,8 +258,7 @@ int p3discovery2::handleIncoming()
++nhandled; ++nhandled;
Dbg4() << __PRETTY_FUNCTION__ << " Received item: " << std::endl Dbg4() << __PRETTY_FUNCTION__ << " Received item: " << *item << std::endl;
<< *item << std::endl;
if((contact = dynamic_cast<RsDiscContactItem *>(item)) != nullptr) if((contact = dynamic_cast<RsDiscContactItem *>(item)) != nullptr)
{ {
@ -269,29 +268,25 @@ int p3discovery2::handleIncoming()
processContactInfo(item->PeerId(), contact); processContactInfo(item->PeerId(), contact);
} }
else if( (gxsidlst = dynamic_cast<RsDiscIdentityListItem *>(item)) != nullptr ) else if( (gxsidlst = dynamic_cast<RsDiscIdentityListItem *>(item)) != nullptr )
{
recvIdentityList(item->PeerId(),gxsidlst->ownIdentityList); recvIdentityList(item->PeerId(),gxsidlst->ownIdentityList);
delete item;
}
else if((pgpkey = dynamic_cast<RsDiscPgpKeyItem *>(item)) != nullptr) else if((pgpkey = dynamic_cast<RsDiscPgpKeyItem *>(item)) != nullptr)
recvPGPCertificate(item->PeerId(), pgpkey); recvPGPCertificate(item->PeerId(), pgpkey);
else if((pgpcert = dynamic_cast<RsDiscPgpCertItem *>(item)) != nullptr) else if((pgpcert = dynamic_cast<RsDiscPgpCertItem *>(item)) != nullptr)
// sink RsWarn() << "Received a deprecated RsDiscPgpCertItem. Will not be handled." << std::endl; // nothing to do.
delete pgpcert;
else if((pgplist = dynamic_cast<RsDiscPgpListItem *>(item)) != nullptr) else if((pgplist = dynamic_cast<RsDiscPgpListItem *>(item)) != nullptr)
{ {
if (pgplist->mode == RsGossipDiscoveryPgpListMode::FRIENDS) if (pgplist->mode == RsGossipDiscoveryPgpListMode::FRIENDS)
processPGPList(pgplist->PeerId(), pgplist); processPGPList(pgplist->PeerId(), pgplist);
else if (pgplist->mode == RsGossipDiscoveryPgpListMode::GETCERT) else if (pgplist->mode == RsGossipDiscoveryPgpListMode::GETCERT)
recvPGPCertificateRequest(pgplist->PeerId(), pgplist); recvPGPCertificateRequest(pgplist->PeerId(), pgplist);
else delete item;
} }
else else
{ {
RsWarn() << __PRETTY_FUNCTION__ << " Received unknown item type " << (int)item->PacketSubType() << "! " << std::endl ; RsWarn() << __PRETTY_FUNCTION__ << " Received unknown item type " << (int)item->PacketSubType() << "! " << std::endl ;
RsWarn() << item << std::endl; RsWarn() << item << std::endl;
delete item;
} }
delete item;
} }
return nhandled; return nhandled;
@ -350,8 +345,6 @@ void p3discovery2::sendOwnContactInfo(const RsPeerId &sslid)
void p3discovery2::recvOwnContactInfo(const RsPeerId &fromId, const RsDiscContactItem *item) void p3discovery2::recvOwnContactInfo(const RsPeerId &fromId, const RsDiscContactItem *item)
{ {
std::unique_ptr<const RsDiscContactItem> pitem(item); // ensures that item will be destroyed whichever door we leave through
#ifdef P3DISC_DEBUG #ifdef P3DISC_DEBUG
std::cerr << "p3discovery2::recvOwnContactInfo()"; std::cerr << "p3discovery2::recvOwnContactInfo()";
std::cerr << std::endl; std::cerr << std::endl;
@ -678,7 +671,6 @@ void p3discovery2::processPGPList(const RsPeerId &fromId, const RsDiscPgpListIte
#endif #endif
// cleanup. // cleanup.
delete item;
return; return;
} }
@ -716,9 +708,6 @@ void p3discovery2::processPGPList(const RsPeerId &fromId, const RsDiscPgpListIte
it->second.mergeFriendList(item->pgpIdSet.ids); it->second.mergeFriendList(item->pgpIdSet.ids);
updatePeers_locked(fromId); updatePeers_locked(fromId);
// cleanup.
delete item;
} }
@ -913,7 +902,6 @@ void p3discovery2::processContactInfo(const RsPeerId &fromId, const RsDiscContac
if(sockaddr_storage_isExternalNet(item->currentConnectAddress.addr)) if(sockaddr_storage_isExternalNet(item->currentConnectAddress.addr))
mPeerMgr->addCandidateForOwnExternalAddress(item->PeerId(), item->currentConnectAddress.addr); mPeerMgr->addCandidateForOwnExternalAddress(item->PeerId(), item->currentConnectAddress.addr);
delete item;
return; return;
} }
@ -942,7 +930,6 @@ void p3discovery2::processContactInfo(const RsPeerId &fromId, const RsDiscContac
/* inform NetMgr that we know this peer */ /* inform NetMgr that we know this peer */
mNetMgr->netAssistKnownPeer(item->sslId, item->extAddrV4.addr, NETASSIST_KNOWN_PEER_FOF | NETASSIST_KNOWN_PEER_OFFLINE); mNetMgr->netAssistKnownPeer(item->sslId, item->extAddrV4.addr, NETASSIST_KNOWN_PEER_FOF | NETASSIST_KNOWN_PEER_OFFLINE);
} }
delete item;
return; return;
} }
@ -991,8 +978,6 @@ void p3discovery2::processContactInfo(const RsPeerId &fromId, const RsDiscContac
if(should_notify_discovery) if(should_notify_discovery)
RsServer::notify()->notifyDiscInfoChanged(); RsServer::notify()->notifyDiscInfoChanged();
delete item;
} }
/* we explictly request certificates, instead of getting them all the time /* we explictly request certificates, instead of getting them all the time
@ -1041,8 +1026,6 @@ void p3discovery2::recvPGPCertificateRequest( const RsPeerId& fromId, const RsDi
sendPGPCertificate(pgpId, fromId); sendPGPCertificate(pgpId, fromId);
else else
std::cerr << "(WW) not sending certificate " << pgpId << " asked by friend " << fromId << " because this either this cert is not a friend, or discovery is off" << std::endl; std::cerr << "(WW) not sending certificate " << pgpId << " asked by friend " << fromId << " because this either this cert is not a friend, or discovery is off" << std::endl;
delete item;
} }
@ -1119,7 +1102,6 @@ void p3discovery2::recvPGPCertificate(const RsPeerId& fromId, RsDiscPgpKeyItem*
#endif #endif
// now that will add the key *and* set the skip_signature_validation flag at once // now that will add the key *and* set the skip_signature_validation flag at once
rsPeers->loadPgpKeyFromBinaryData((unsigned char*)item->bin_data,item->bin_len, tmp_pgp_id,error_string); // no error should occur at this point because we called loadDetailsFromStringCert() already rsPeers->loadPgpKeyFromBinaryData((unsigned char*)item->bin_data,item->bin_len, tmp_pgp_id,error_string); // no error should occur at this point because we called loadDetailsFromStringCert() already
delete item;
// Make sure we allow connections after the key is added. This is not the case otherwise. We only do that if the peer is non validated peer, since // Make sure we allow connections after the key is added. This is not the case otherwise. We only do that if the peer is non validated peer, since
// otherwise the connection should already be accepted. This only happens when the short invite peer sends its own PGP key. // otherwise the connection should already be accepted. This only happens when the short invite peer sends its own PGP key.

View file

@ -1238,14 +1238,6 @@ int AuthSSLimpl::VerifyX509Callback(int /*preverify_ok*/, X509_STORE_CTX* ctx)
RsErr() << __PRETTY_FUNCTION__ << " " << errMsg << std::endl; RsErr() << __PRETTY_FUNCTION__ << " " << errMsg << std::endl;
// if(rsEvents)
// {
// ev->mErrorMsg = errMsg;
// ev->mErrorCode = RsAuthSslConnectionAutenticationEvent::NO_CERTIFICATE_SUPPLIED;
//
// rsEvents->postEvent(std::move(ev));
// }
return verificationFailed; return verificationFailed;
} }
@ -1400,7 +1392,6 @@ int AuthSSLimpl::VerifyX509Callback(int /*preverify_ok*/, X509_STORE_CTX* ctx)
return verificationFailed; return verificationFailed;
} }
//setCurrentConnectionAttemptInfo(pgpId, sslId, sslCn);
LocalStoreCert(x509Cert); LocalStoreCert(x509Cert);
RsInfo() << __PRETTY_FUNCTION__ << " authentication successfull for " RsInfo() << __PRETTY_FUNCTION__ << " authentication successfull for "
@ -1410,9 +1401,7 @@ int AuthSSLimpl::VerifyX509Callback(int /*preverify_ok*/, X509_STORE_CTX* ctx)
return verificationSuccess; return verificationSuccess;
} }
bool AuthSSLimpl::parseX509DetailsFromFile( bool AuthSSLimpl::parseX509DetailsFromFile( const std::string& certFilePath, RsPeerId& certId, RsPgpId& issuer, std::string& location )
const std::string& certFilePath, RsPeerId& certId,
RsPgpId& issuer, std::string& location )
{ {
FILE* tmpfp = RsDirUtil::rs_fopen(certFilePath.c_str(), "r"); FILE* tmpfp = RsDirUtil::rs_fopen(certFilePath.c_str(), "r");
if(!tmpfp) if(!tmpfp)
@ -1433,10 +1422,13 @@ bool AuthSSLimpl::parseX509DetailsFromFile(
} }
uint32_t diagnostic = 0; uint32_t diagnostic = 0;
if(!AuthX509WithGPG(x509,false, diagnostic)) if(!AuthX509WithGPG(x509,false, diagnostic))
{ {
RsErr() << __PRETTY_FUNCTION__ << " AuthX509WithGPG failed with " RsErr() << __PRETTY_FUNCTION__ << " AuthX509WithGPG failed with "
<< "diagnostic: " << diagnostic << std::endl; << "diagnostic: " << diagnostic << std::endl;
X509_free(x509);
return false; return false;
} }
@ -1805,15 +1797,17 @@ bool AuthSSLimpl::loadList(std::list<RsItem*>& load)
for(it = load.begin(); it != load.end(); ++it) { for(it = load.begin(); it != load.end(); ++it) {
RsConfigKeyValueSet *vitem = dynamic_cast<RsConfigKeyValueSet *>(*it); RsConfigKeyValueSet *vitem = dynamic_cast<RsConfigKeyValueSet *>(*it);
if(vitem) { if(vitem)
#ifdef AUTHSSL_DEBUG {
#ifdef AUTHSSL_DEBUG
std::cerr << "AuthSSLimpl::loadList() General Variable Config Item:" << std::endl; std::cerr << "AuthSSLimpl::loadList() General Variable Config Item:" << std::endl;
vitem->print(std::cerr, 10); vitem->print(std::cerr, 10);
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
std::list<RsTlvKeyValue>::iterator kit; std::list<RsTlvKeyValue>::iterator kit;
for(kit = vitem->tlvkvs.pairs.begin(); kit != vitem->tlvkvs.pairs.end(); ++kit) { for(kit = vitem->tlvkvs.pairs.begin(); kit != vitem->tlvkvs.pairs.end(); ++kit)
{
if (RsPeerId(kit->key) == mOwnId) { if (RsPeerId(kit->key) == mOwnId) {
continue; continue;
} }
@ -1821,10 +1815,10 @@ bool AuthSSLimpl::loadList(std::list<RsItem*>& load)
X509 *peer = loadX509FromPEM(kit->value); X509 *peer = loadX509FromPEM(kit->value);
/* authenticate it */ /* authenticate it */
uint32_t diagnos ; uint32_t diagnos ;
if (AuthX509WithGPG(peer,false,diagnos)) if (peer && AuthX509WithGPG(peer,false,diagnos))
{
LocalStoreCert(peer); LocalStoreCert(peer);
}
X509_free(peer);
} }
} }
delete (*it); delete (*it);

View file

@ -32,6 +32,7 @@
#include "gui/common/AvatarDefs.h" #include "gui/common/AvatarDefs.h"
#include "gui/common/FilesDefs.h" #include "gui/common/FilesDefs.h"
#include "util/qtthreadsutils.h" #include "util/qtthreadsutils.h"
#include "util/misc.h"
#include "gui/Circles/CreateCircleDialog.h" #include "gui/Circles/CreateCircleDialog.h"
#include "gui/gxs/GxsIdDetails.h" #include "gui/gxs/GxsIdDetails.h"
#include "gui/Identity/IdDialog.h" #include "gui/Identity/IdDialog.h"
@ -53,24 +54,11 @@ CreateCircleDialog::CreateCircleDialog()
/* Invoke the Qt Designer generated object setup routine */ /* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this); ui.setupUi(this);
setAttribute(Qt::WA_DeleteOnClose, false);
/* Setup Queue */ /* Setup Queue */
ui.headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/circles.png")); ui.headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/circles.png"));
// connect up the buttons.
connect(ui.addButton, SIGNAL(clicked()), this, SLOT(addMember()));
connect(ui.removeButton, SIGNAL(clicked()), this, SLOT(removeMember()));
connect(ui.createButton, SIGNAL(clicked()), this, SLOT(createCircle()));
connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(close()));
connect(ui.treeWidget_membership, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(selectedMember(QTreeWidgetItem*, QTreeWidgetItem*)));
connect(ui.treeWidget_IdList, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(selectedId(QTreeWidgetItem*, QTreeWidgetItem*)));
connect(ui.treeWidget_IdList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(IdListCustomPopupMenu(QPoint)));
connect(ui.treeWidget_membership, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(MembershipListCustomPopupMenu(QPoint)));
connect(ui.IdFilter, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));
//connect(ui.toolButton_NewId, SIGNAL(clicked()), this, SLOT(createNewGxsId())); //connect(ui.toolButton_NewId, SIGNAL(clicked()), this, SLOT(createNewGxsId()));
/* Add filter actions */ /* Add filter actions */
@ -88,15 +76,6 @@ CreateCircleDialog::CreateCircleDialog()
ui.removeButton->setEnabled(false); ui.removeButton->setEnabled(false);
ui.addButton->setEnabled(false); ui.addButton->setEnabled(false);
ui.radioButton_ListAll->setChecked(true); ui.radioButton_ListAll->setChecked(true);
QObject::connect(ui.radioButton_ListAll, SIGNAL(toggled(bool)), this, SLOT(idTypeChanged())) ;
QObject::connect(ui.radioButton_ListAllPGP, SIGNAL(toggled(bool)), this, SLOT(idTypeChanged())) ;
QObject::connect(ui.radioButton_ListFriendPGP, SIGNAL(toggled(bool)), this, SLOT(idTypeChanged())) ;
QObject::connect(ui.radioButton_Public, SIGNAL(toggled(bool)), this, SLOT(updateCircleType(bool))) ;
QObject::connect(ui.radioButton_Self, SIGNAL(toggled(bool)), this, SLOT(updateCircleType(bool))) ;
QObject::connect(ui.radioButton_Restricted, SIGNAL(toggled(bool)), this, SLOT(updateCircleType(bool))) ;
ui.radioButton_Public->setChecked(true) ; ui.radioButton_Public->setChecked(true) ;
mIsExistingCircle = false; mIsExistingCircle = false;
@ -107,9 +86,32 @@ CreateCircleDialog::CreateCircleDialog()
#endif #endif
ui.treeWidget_IdList->setColumnHidden(RSCIRCLEID_COL_KEYID,true); // no need to show this. the tooltip will do it. ui.treeWidget_IdList->setColumnHidden(RSCIRCLEID_COL_KEYID,true); // no need to show this. the tooltip will do it.
//ui.idChooser->loadIds(0,RsGxsId());
ui.circleComboBox->loadCircles(RsGxsCircleId()); ui.circleComboBox->loadCircles(RsGxsCircleId());
ui.circleComboBox->hide();
// connect up the buttons.
connect(ui.addButton, SIGNAL(clicked()), this, SLOT(addMember()));
connect(ui.removeButton, SIGNAL(clicked()), this, SLOT(removeMember()));
connect(ui.createButton, SIGNAL(clicked()), this, SLOT(createCircle()));
connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(close()));
connect(ui.treeWidget_membership, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(selectedMember(QTreeWidgetItem*, QTreeWidgetItem*)));
connect(ui.treeWidget_IdList, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(selectedId(QTreeWidgetItem*, QTreeWidgetItem*)));
connect(ui.treeWidget_IdList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(IdListCustomPopupMenu(QPoint)));
connect(ui.treeWidget_membership, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(MembershipListCustomPopupMenu(QPoint)));
connect(ui.IdFilter, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));
QObject::connect(ui.radioButton_ListAll, SIGNAL(toggled(bool)), this, SLOT(idTypeChanged())) ;
QObject::connect(ui.radioButton_ListAllPGP, SIGNAL(toggled(bool)), this, SLOT(idTypeChanged())) ;
QObject::connect(ui.radioButton_ListFriendPGP, SIGNAL(toggled(bool)), this, SLOT(idTypeChanged())) ;
QObject::connect(ui.radioButton_Public, SIGNAL(toggled(bool)), this, SLOT(updateCircleType(bool))) ;
QObject::connect(ui.radioButton_Self, SIGNAL(toggled(bool)), this, SLOT(updateCircleType(bool))) ;
QObject::connect(ui.radioButton_Restricted, SIGNAL(toggled(bool)), this, SLOT(updateCircleType(bool))) ;
} }
CreateCircleDialog::~CreateCircleDialog() CreateCircleDialog::~CreateCircleDialog()
@ -575,7 +577,7 @@ void CreateCircleDialog::updateCircleGUI()
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
ui.circleName->setText(QString::fromUtf8(mCircleGroup.mMeta.mGroupName.c_str())); whileBlocking(ui.circleName)->setText(QString::fromUtf8(mCircleGroup.mMeta.mGroupName.c_str()));
bool isExternal = true; bool isExternal = true;
#ifdef DEBUG_CREATE_CIRCLE_DIALOG #ifdef DEBUG_CREATE_CIRCLE_DIALOG
@ -583,9 +585,9 @@ void CreateCircleDialog::updateCircleGUI()
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
ui.radioButton_Public->setChecked(false); whileBlocking(ui.radioButton_Public)->setChecked(false);
ui.radioButton_Self->setChecked(false); whileBlocking(ui.radioButton_Self)->setChecked(false);
ui.radioButton_Restricted->setChecked(false); whileBlocking(ui.radioButton_Restricted)->setChecked(false);
switch(mCircleGroup.mMeta.mCircleType) switch(mCircleGroup.mMeta.mCircleType)
{ {
@ -604,7 +606,7 @@ void CreateCircleDialog::updateCircleGUI()
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
ui.radioButton_Public->setChecked(true); whileBlocking(ui.radioButton_Public)->setChecked(true);
break; break;
case GXS_CIRCLE_TYPE_EXT_SELF: case GXS_CIRCLE_TYPE_EXT_SELF:
@ -618,11 +620,11 @@ void CreateCircleDialog::updateCircleGUI()
#endif #endif
if (RsGxsGroupId(mCircleGroup.mMeta.mCircleId) == mCircleGroup.mMeta.mGroupId) if (RsGxsGroupId(mCircleGroup.mMeta.mCircleId) == mCircleGroup.mMeta.mGroupId)
ui.radioButton_Self->setChecked(true); whileBlocking(ui.radioButton_Self)->setChecked(true);
else else
ui.radioButton_Restricted->setChecked(true); whileBlocking(ui.radioButton_Restricted)->setChecked(true);
ui.circleComboBox->loadCircles(mCircleGroup.mMeta.mCircleId); whileBlocking(ui.circleComboBox)->loadCircles(mCircleGroup.mMeta.mCircleId);
break; break;
@ -696,6 +698,8 @@ void CreateCircleDialog::loadCircle(const RsGxsGroupId& groupId)
void CreateCircleDialog::loadIdentities() void CreateCircleDialog::loadIdentities()
{ {
std::cerr << "Loading identities..." << std::endl;
RsThread::async([this]() RsThread::async([this]()
{ {
std::list<RsGroupMetaData> ids_meta; std::list<RsGroupMetaData> ids_meta;
@ -707,23 +711,30 @@ void CreateCircleDialog::loadIdentities()
} }
std::set<RsGxsId> ids; std::set<RsGxsId> ids;
for(auto& meta:ids_meta) ids.insert(RsGxsId(meta.mGroupId)); for(auto& meta:ids_meta)
ids.insert(RsGxsId(meta.mGroupId));
// Needs a pointer on the heap, to pass to postToObject, otherwise it will get deleted before
// the posted method will actually run. Memory ownership is left to the posted method.
auto id_groups = new std::vector<RsGxsIdGroup>();
auto id_groups = std::make_unique<std::vector<RsGxsIdGroup>>();
if(!rsIdentity->getIdentitiesInfo(ids, *id_groups)) if(!rsIdentity->getIdentitiesInfo(ids, *id_groups))
{ {
RS_ERR("failed to retrieve identities group info for all identities"); RS_ERR("failed to retrieve identities group info for all identities");
delete id_groups;
return; return;
} }
RsQThreadUtils::postToObject( RsQThreadUtils::postToObject( [id_groups, this]()
[id_groups = std::move(id_groups), this]()
{ {
/* Here it goes any code you want to be executed on the Qt Gui /* Here it goes any code you want to be executed on the Qt Gui
* thread, for example to update the data model with new information * thread, for example to update the data model with new information
* after a blocking call to RetroShare API complete */ * after a blocking call to RetroShare API complete */
fillIdentitiesList(*id_groups); fillIdentitiesList(*id_groups);
delete id_groups;
}, this ); }, this );
}); });

View file

@ -154,8 +154,8 @@ SearchDialog::SearchDialog(QWidget *parent)
// To allow a proper sorting, be careful to pad at right with spaces. This // To allow a proper sorting, be careful to pad at right with spaces. This
// is achieved by using QString("%1").arg(number,15,10). // is achieved by using QString("%1").arg(number,15,10).
// //
ui.searchResultWidget->setItemDelegateForColumn(SR_SIZE_COL, new RSHumanReadableSizeDelegate()) ; ui.searchResultWidget->setItemDelegateForColumn(SR_SIZE_COL, mSizeColumnDelegate=new RSHumanReadableSizeDelegate()) ;
ui.searchResultWidget->setItemDelegateForColumn(SR_AGE_COL, new RSHumanReadableAgeDelegate()) ; ui.searchResultWidget->setItemDelegateForColumn(SR_AGE_COL, mAgeColumnDelegate=new RSHumanReadableAgeDelegate()) ;
/* make it extended selection */ /* make it extended selection */
ui.searchResultWidget -> setSelectionMode(QAbstractItemView::ExtendedSelection); ui.searchResultWidget -> setSelectionMode(QAbstractItemView::ExtendedSelection);
@ -225,12 +225,17 @@ SearchDialog::~SearchDialog()
// save settings // save settings
processSettings(false); processSettings(false);
if (compareSummaryRole) { if (compareSummaryRole)
delete(compareSummaryRole); delete(compareSummaryRole);
}
if (compareResultRole) { if (compareResultRole)
delete(compareResultRole); delete(compareResultRole);
}
delete mSizeColumnDelegate;
delete mAgeColumnDelegate;
ui.searchResultWidget->setItemDelegateForColumn(SR_SIZE_COL, nullptr);
ui.searchResultWidget->setItemDelegateForColumn(SR_AGE_COL, nullptr);
} }
void SearchDialog::processSettings(bool bLoad) void SearchDialog::processSettings(bool bLoad)

View file

@ -156,6 +156,9 @@ private:
RSTreeWidgetItemCompareRole *compareSummaryRole; RSTreeWidgetItemCompareRole *compareSummaryRole;
RSTreeWidgetItemCompareRole *compareResultRole; RSTreeWidgetItemCompareRole *compareResultRole;
QAbstractItemDelegate *mAgeColumnDelegate;
QAbstractItemDelegate *mSizeColumnDelegate;
/* Color definitions (for standard see qss.default) */ /* Color definitions (for standard see qss.default) */
QColor mTextColorLocal; QColor mTextColorLocal;
QColor mTextColorDownloading; QColor mTextColorDownloading;

View file

@ -1128,6 +1128,12 @@ TransfersDialog::~TransfersDialog()
// save settings // save settings
processSettings(false); processSettings(false);
ui.uploadsList->setItemDelegate(nullptr);
ui.downloadList->setItemDelegate(nullptr);
delete ULDelegate;
delete DLDelegate;
} }
void TransfersDialog::activatePage(TransfersDialog::Page page) void TransfersDialog::activatePage(TransfersDialog::Page page)

View file

@ -505,16 +505,16 @@ void IdDialog::updateCircles()
/* This can be big so use a smart pointer to just copy the pointer /* This can be big so use a smart pointer to just copy the pointer
* instead of copying the whole list accross the lambdas */ * instead of copying the whole list accross the lambdas */
auto circle_metas = std::make_unique<std::list<RsGroupMetaData>>(); auto circle_metas = new std::list<RsGroupMetaData>();
if(!rsGxsCircles->getCirclesSummaries(*circle_metas)) if(!rsGxsCircles->getCirclesSummaries(*circle_metas))
{ {
RS_ERR("failed to retrieve circles group info list"); RS_ERR("failed to retrieve circles group info list");
delete circle_metas;
return; return;
} }
RsQThreadUtils::postToObject( RsQThreadUtils::postToObject( [circle_metas, this]()
[circle_metas = std::move(circle_metas), this]()
{ {
/* Here it goes any code you want to be executed on the Qt Gui /* Here it goes any code you want to be executed on the Qt Gui
* thread, for example to update the data model with new information * thread, for example to update the data model with new information
@ -522,6 +522,7 @@ void IdDialog::updateCircles()
loadCircles(*circle_metas); loadCircles(*circle_metas);
delete circle_metas;
}, this ); }, this );
}); });
@ -1316,17 +1317,19 @@ void IdDialog::updateIdList()
return; return;
} }
auto ids_set = std::make_unique<std::map<RsGxsGroupId,RsGxsIdGroup>>(); auto ids_set = new std::map<RsGxsGroupId,RsGxsIdGroup>();
for(auto it(groups.begin()); it!=groups.end(); ++it) for(auto it(groups.begin()); it!=groups.end(); ++it)
(*ids_set)[(*it).mMeta.mGroupId] = *it; (*ids_set)[(*it).mMeta.mGroupId] = *it;
RsQThreadUtils::postToObject( RsQThreadUtils::postToObject( [ids_set, this] ()
[ids_set = std::move(ids_set), this] ()
{ {
/* Here it goes any code you want to be executed on the Qt Gui /* Here it goes any code you want to be executed on the Qt Gui
* thread, for example to update the data model with new information * thread, for example to update the data model with new information
* after a blocking call to RetroShare API complete */ * after a blocking call to RetroShare API complete */
loadIdentities(*ids_set); loadIdentities(*ids_set);
delete ids_set;
}, this ); }, this );
}); });

View file

@ -375,6 +375,9 @@ MainWindow::~MainWindow()
delete soundStatus; delete soundStatus;
delete toasterDisable; delete toasterDisable;
delete sysTrayStatus; delete sysTrayStatus;
delete trayIcon;
delete trayMenu;
delete notifyMenu;
#ifdef MESSENGER_WINDOW #ifdef MESSENGER_WINDOW
MessengerWindow::releaseInstance(); MessengerWindow::releaseInstance();
#endif #endif
@ -602,7 +605,7 @@ void MainWindow::displayDiskSpaceWarning(int loc,int size_limit_mb)
void MainWindow::createTrayIcon() void MainWindow::createTrayIcon()
{ {
/** Tray icon Menu **/ /** Tray icon Menu **/
QMenu *trayMenu = new QMenu(this); trayMenu = new QMenu(this);
if (sysTrayStatus) sysTrayStatus->trayMenu = trayMenu; if (sysTrayStatus) sysTrayStatus->trayMenu = trayMenu;
QObject::connect(trayMenu, SIGNAL(aboutToShow()), this, SLOT(updateMenu())); QObject::connect(trayMenu, SIGNAL(aboutToShow()), this, SLOT(updateMenu()));
toggleVisibilityAction = trayMenu->addAction(QIcon(IMAGE_RETROSHARE), tr("Show/Hide"), this, SLOT(toggleVisibilitycontextmenu())); toggleVisibilityAction = trayMenu->addAction(QIcon(IMAGE_RETROSHARE), tr("Show/Hide"), this, SLOT(toggleVisibilitycontextmenu()));

View file

@ -284,6 +284,7 @@ private:
QSystemTrayIcon *trayIcon; QSystemTrayIcon *trayIcon;
QMenu *notifyMenu; QMenu *notifyMenu;
QMenu *trayMenu;
QString notifyToolTip; QString notifyToolTip;
QAction *toggleVisibilityAction, *toolAct; QAction *toggleVisibilityAction, *toolAct;
QList<UserNotify*> userNotifyList; QList<UserNotify*> userNotifyList;

View file

@ -256,17 +256,20 @@ void FriendSelectionWidget::loadIdentities()
return; return;
} }
auto ids = std::make_unique<std::vector<RsGxsGroupId>>(); auto ids = new std::vector<RsGxsGroupId>();
for(auto& meta: ids_meta) ids->push_back(meta.mGroupId);
RsQThreadUtils::postToObject( for(auto& meta: ids_meta)
[ids = std::move(ids), this]() ids->push_back(meta.mGroupId);
RsQThreadUtils::postToObject( [ids, this]()
{ {
// We do that is the GUI thread. Dont try it on another thread! // We do that is the GUI thread. Dont try it on another thread!
gxsIds = *ids; gxsIds = *ids;
/* TODO: To furter optimize away a copy gxsIds could be a unique_ptr /* TODO: To furter optimize away a copy gxsIds could be a unique_ptr
* too */ * too */
fillList(); fillList();
delete ids;
}, this ); }, this );
}); });
} }

View file

@ -264,6 +264,8 @@ void NewFriendList::handleEvent(std::shared_ptr<const RsEvent> /*e*/)
NewFriendList::~NewFriendList() NewFriendList::~NewFriendList()
{ {
rsEvents->unregisterEventsHandler(mEventHandlerId); rsEvents->unregisterEventsHandler(mEventHandlerId);
delete mModel;
delete mProxyModel;
delete ui; delete ui;
} }

View file

@ -464,17 +464,16 @@ void GxsTransportStatistics::loadGroups()
#ifdef DEBUG_FORUMS #ifdef DEBUG_FORUMS
std::cerr << "Retrieving post data for post " << mThreadId << std::endl; std::cerr << "Retrieving post data for post " << mThreadId << std::endl;
#endif #endif
auto stats = std::make_unique< auto stats = new std::map<RsGxsGroupId,RsGxsTransGroupStatistics>();
std::map<RsGxsGroupId,RsGxsTransGroupStatistics> >();
if(!rsGxsTrans->getGroupStatistics(*stats)) if(!rsGxsTrans->getGroupStatistics(*stats))
{ {
RS_ERR("Cannot retrieve group statistics in GxsTransportStatistics"); RS_ERR("Cannot retrieve group statistics in GxsTransportStatistics");
delete stats;
return; return;
} }
RsQThreadUtils::postToObject( RsQThreadUtils::postToObject( [stats, this]()
[stats = std::move(stats), this]()
{ {
/* Here it goes any code you want to be executed on the Qt Gui /* Here it goes any code you want to be executed on the Qt Gui
* thread, for example to update the data model with new information * thread, for example to update the data model with new information
@ -485,6 +484,7 @@ void GxsTransportStatistics::loadGroups()
updateContent(); updateContent();
mStateHelper->setLoading(GXSTRANS_GROUP_META, false); mStateHelper->setLoading(GXSTRANS_GROUP_META, false);
delete stats;
}, this ); }, this );
}); });