Merge pull request #2350 from csoler/v0.6-BugFixing_10

Bug fixing in FriendList
This commit is contained in:
csoler 2021-02-28 19:59:57 +01:00 committed by GitHub
commit 2b9a290a85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 218 additions and 100 deletions

View File

@ -121,15 +121,20 @@ p3Peers::p3Peers(p3LinkMgr *lm, p3PeerMgr *pm, p3NetMgr *nm)
:mLinkMgr(lm), mPeerMgr(pm), mNetMgr(nm) {}
/* Updates ... */
bool p3Peers::FriendsChanged(bool add)
bool p3Peers::FriendsChanged(const RsPeerId& pid,bool add)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::FriendsChanged()" << std::endl;
std::cerr << "p3Peers::FriendsChanged()" << std::endl;
#endif
RsServer::notify()->notifyListChange(NOTIFY_LIST_FRIENDS, add? NOTIFY_TYPE_ADD : NOTIFY_TYPE_DEL);
if(rsEvents)
{
auto ev = std::make_shared<RsPeerStateChangedEvent>(pid);
rsEvents->postEvent(ev);
}
RsServer::notify()->notifyListChange(NOTIFY_LIST_FRIENDS, add? NOTIFY_TYPE_ADD : NOTIFY_TYPE_DEL); // this is meant to disappear
/* TODO */
return false;
/* TODO */
return false;
}
bool p3Peers::OthersChanged()
@ -769,7 +774,7 @@ bool p3Peers::addFriend(const RsPeerId &ssl_id, const RsPgpId &gpg_id,ServicePe
return true;
}
FriendsChanged(true);
FriendsChanged(ssl_id,true);
/* otherwise - we install as ssl_id.....
* If we are adding an SSL certificate. we flag lastcontact as now.
@ -783,7 +788,7 @@ bool p3Peers::addSslOnlyFriend( const RsPeerId& sslId, const RsPgpId& pgp_id,con
{
if( mPeerMgr->addSslOnlyFriend(sslId, pgp_id,details))
{
FriendsChanged(true);
FriendsChanged(sslId,true);
return true;
}
else
@ -802,8 +807,9 @@ bool p3Peers::removeFriendLocation(const RsPeerId &sslId)
#endif
//will remove if it's a ssl id
mPeerMgr->removeFriend(sslId, false);
return true;
FriendsChanged(sslId,false);
return true;
}
bool p3Peers::removeFriend(const RsPgpId& gpgId)
@ -1641,7 +1647,7 @@ bool p3Peers::loadCertificateFromString(
if(res)
{
mPeerMgr->notifyPgpKeyReceived(gpgid);
FriendsChanged(true);
FriendsChanged(ssl_id,true);
}
return res;

View File

@ -48,7 +48,7 @@ public:
virtual ~p3Peers() {}
/* Updates ... */
virtual bool FriendsChanged(bool add);
virtual bool FriendsChanged(const RsPeerId &pid, bool add);
virtual bool OthersChanged();
/* Peer Details (Net & Auth) */

View File

@ -192,7 +192,8 @@ GxsGroupDialog *PostedDialog::createGroupDialog(GxsGroupDialog::Mode mode, RsGxs
int PostedDialog::shareKeyType()
{
return POSTED_KEY_SHARE;
//return POSTED_KEY_SHARE;
return GroupShareKey::NO_KEY_SHARE; // Boards are public. By the time we offer the possibility to make them restricted, we need to not show the 'share publish permission' entry in the drop menu.
}
GxsMessageFrameWidget *PostedDialog::createMessageFrameWidget(const RsGxsGroupId &groupId)

View File

@ -54,7 +54,7 @@ static const uint16_t UNDEFINED_PROFILE_INDEX_VALUE = (sizeof(uintptr_t)==4)?0xf
const QString RsFriendListModel::FilterString("filtered");
const uint32_t MAX_INTERNAL_DATA_UPDATE_DELAY = 300 ; // re-update the internal data every 5 mins. Should properly cover sleep/wake-up changes.
const uint32_t MAX_NODE_UPDATE_DELAY = 1 ; // re-update the internal data every 5 mins. Should properly cover sleep/wake-up changes.
const uint32_t MAX_NODE_UPDATE_DELAY = 10 ; // re-update the internal data every 5 mins. Should properly cover sleep/wake-up changes.
static const uint32_t NODE_DETAILS_UPDATE_DELAY = 5; // update each node every 5 secs.
@ -771,24 +771,29 @@ void RsFriendListModel::checkInternalData(bool force)
{
rstime_t now = time(NULL);
if(mLastInternalDataUpdate + MAX_INTERNAL_DATA_UPDATE_DELAY < now || force)
if( (mLastInternalDataUpdate + MAX_INTERNAL_DATA_UPDATE_DELAY < now) || force)
updateInternalData();
if(mLastNodeUpdate + MAX_NODE_UPDATE_DELAY < now)
{
for(uint32_t i=0;i<mLocations.size();++i)
if(mLocations[i].last_update_ts + NODE_DETAILS_UPDATE_DELAY < now)
{
#ifdef DEBUG_MODEL
std::cerr << "Updating ID " << mLocations[i].node_info.id << std::endl;
#endif
RsPeerId id(mLocations[i].node_info.id); // this avoids zeroing the id field when writing the node data
rsPeers->getPeerDetails(id,mLocations[i].node_info);
mLocations[i].last_update_ts = now;
}
mLastNodeUpdate = now;
}
// else
// {
// preMods();
//
// if(mLastNodeUpdate + MAX_NODE_UPDATE_DELAY < now)
// {
// for(uint32_t i=0;i<mLocations.size();++i)
// if(mLocations[i].last_update_ts + NODE_DETAILS_UPDATE_DELAY < now)
// {
//#ifdef DEBUG_MODEL
// std::cerr << "Updating ID " << mLocations[i].node_info.id << std::endl;
//#endif
// RsPeerId id(mLocations[i].node_info.id); // this avoids zeroing the id field when writing the node data
// rsPeers->getPeerDetails(id,mLocations[i].node_info);
// mLocations[i].last_update_ts = now;
// }
//
// mLastNodeUpdate = now;
// }
// postMods();
// }
}
const RsFriendListModel::HierarchicalGroupInformation *RsFriendListModel::getGroupInfo(const EntryIndex& e) const

View File

@ -40,7 +40,6 @@
#include "gui/connect/ConnectFriendWizard.h"
#include "gui/groups/CreateGroup.h"
#include "gui/msgs/MessageComposer.h"
#include "gui/notifyqt.h"
#include "gui/RetroShareLink.h"
#include "retroshare-gui/RsAutoUpdatePage.h"
#ifdef UNFINISHED_FD
@ -100,6 +99,7 @@
/******
* #define FRIENDS_DEBUG 1
* #define DEBUG_NEW_FRIEND_LIST 1
*****/
Q_DECLARE_METATYPE(ElidedLabel*)
@ -179,7 +179,9 @@ NewFriendList::NewFriendList(QWidget */*parent*/) : /* RsAutoUpdatePage(5000,par
mEventHandlerId_peer=0; // forces initialization
mEventHandlerId_gssp=0; // forces initialization
mEventHandlerId_pssc=0; // forces initialization
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> e) { handleEvent(e); }, mEventHandlerId_pssc, RsEventType::PEER_STATE_CHANGED );
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> e) { handleEvent(e); }, mEventHandlerId_peer, RsEventType::PEER_CONNECTION );
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> e) { handleEvent(e); }, mEventHandlerId_gssp, RsEventType::GOSSIP_DISCOVERY );
@ -240,11 +242,6 @@ NewFriendList::NewFriendList(QWidget */*parent*/) : /* RsAutoUpdatePage(5000,par
connect(mActionSortByState, SIGNAL(toggled(bool)), this, SLOT(toggleSortByState(bool)));
connect(ui->peerTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(peerTreeWidgetCustomPopupMenu()));
// Using Queued connections here is pretty important since the notifications may come from a different thread.
connect(NotifyQt::getInstance(), SIGNAL(friendsChanged()) , this, SLOT(forceUpdateDisplay()),Qt::QueuedConnection);
connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)) , this, SLOT(forceUpdateDisplay()),Qt::QueuedConnection);
connect(ui->actionShowOfflineFriends, SIGNAL(triggered(bool)), this, SLOT(setShowUnconnected(bool)));
connect(ui->actionShowState, SIGNAL(triggered(bool)), this, SLOT(setShowState(bool)) );
connect(ui->actionShowGroups, SIGNAL(triggered(bool)), this, SLOT(setShowGroups(bool)) );
@ -272,6 +269,7 @@ NewFriendList::~NewFriendList()
{
rsEvents->unregisterEventsHandler(mEventHandlerId_peer);
rsEvents->unregisterEventsHandler(mEventHandlerId_gssp);
rsEvents->unregisterEventsHandler(mEventHandlerId_pssc);
delete mModel;
delete mProxyModel;
@ -287,21 +285,6 @@ void NewFriendList::itemCollapsed(const QModelIndex& index)
mModel->collapseItem(mProxyModel->mapToSource(index));
}
void NewFriendList::sortColumn(int col,Qt::SortOrder so)
{
std::set<QString> expanded_indexes;
std::set<QString> selected_indexes;
saveExpandedPathsAndSelection(expanded_indexes, selected_indexes);
mProxyModel->setSortingEnabled(true);
mProxyModel->sort(col,so);
mProxyModel->setSortingEnabled(false);
restoreExpandedPathsAndSelection(expanded_indexes, selected_indexes);
mLastSortColumn = col;
mLastSortOrder = so;
}
void NewFriendList::headerContextMenuRequested(QPoint /*p*/)
{
QMenu displayMenu(tr("Show Items"), this);
@ -384,75 +367,109 @@ void NewFriendList::addToolButton(QToolButton *toolButton)
ui->titleBarFrame->layout()->addWidget(toolButton);
}
void NewFriendList::saveExpandedPathsAndSelection(std::set<QString>& expanded_indexes, std::set<QString>& selected_indexes)
void NewFriendList::saveExpandedPathsAndSelection(std::set<QString>& expanded_indexes, QString& sel)
{
QModelIndexList selectedIndexes = ui->peerTreeWidget->selectionModel()->selectedIndexes();
QModelIndex current_index = selectedIndexes.empty()?QModelIndex():(*selectedIndexes.begin());
#ifdef DEBUG_NEW_FRIEND_LIST
std::cerr << "Saving expended paths and selection..." << std::endl;
#endif
for(int row = 0; row < mProxyModel->rowCount(); ++row)
recursSaveExpandedItems(mProxyModel->index(row,0),QString(),expanded_indexes,selected_indexes);
recursSaveExpandedItems(mProxyModel->index(row,0),current_index,QString(),expanded_indexes,sel);
#ifdef DEBUG_NEW_FRIEND_LIST
std::cerr << " selected index: \"" << sel.toStdString() << "\"" << std::endl;
#endif
}
void NewFriendList::restoreExpandedPathsAndSelection(const std::set<QString>& expanded_indexes, const std::set<QString>& selected_indexes)
void NewFriendList::restoreExpandedPathsAndSelection(const std::set<QString>& expanded_indexes,const QString& index_to_select,QModelIndex& selected_index)
{
#ifdef DEBUG_NEW_FRIEND_LIST
std::cerr << "Restoring expended paths and selection..." << std::endl;
std::cerr << " index to select: \"" << index_to_select.toStdString() << "\"" << std::endl;
#endif
ui->peerTreeWidget->blockSignals(true) ;
for(int row = 0; row < mProxyModel->rowCount(); ++row)
recursRestoreExpandedItems(mProxyModel->index(row,0),QString(),expanded_indexes,selected_indexes);
recursRestoreExpandedItems(mProxyModel->index(row,0),QString(),expanded_indexes,index_to_select,selected_index);
ui->peerTreeWidget->blockSignals(false) ;
}
void NewFriendList::recursSaveExpandedItems(const QModelIndex& index,const QString& parent_path,std::set<QString>& exp, std::set<QString>& sel)
void NewFriendList::recursSaveExpandedItems(const QModelIndex& index,const QModelIndex& current_index,const QString& parent_path,std::set<QString>& exp, QString& sel)
{
QString local_path = parent_path + index.sibling(index.row(),RsFriendListModel::COLUMN_THREAD_ID).data(Qt::DisplayRole).toString() + " ";
if(ui->peerTreeWidget->selectionModel()->selection().contains(index))
sel.insert(local_path) ;
#ifdef DEBUG_NEW_FRIEND_LIST
std::cerr << " At index " << index.row() << ". data[1]=" << local_path.toStdString() ;
#endif
if(ui->peerTreeWidget->isExpanded(index))
{
#ifdef DEBUG_NEW_FRIEND_LIST
std::cerr << "Index " << local_path.toStdString() << " is expanded." << std::endl;
std::cerr << " Index is expanded." ;
#endif
if(index.isValid())
exp.insert(local_path) ;
for(int row=0;row<mProxyModel->rowCount(index);++row)
recursSaveExpandedItems(index.child(row,0),local_path,exp,sel) ;
recursSaveExpandedItems(index.child(row,0),current_index,local_path,exp,sel) ;
}
#ifdef DEBUG_NEW_FRIEND_LIST
else
std::cerr << "Index " << local_path.toStdString() << " is not expanded." << std::endl;
std::cerr << " not expanded." ;
#endif
if(index == current_index)
{
#ifdef DEBUG_NEW_FRIEND_LIST
std::cerr << " adding to selection!" << std::endl;
#endif
sel = local_path ;
}
#ifdef DEBUG_NEW_FRIEND_LIST
else
std::cerr << std::endl;
#endif
}
void NewFriendList::recursRestoreExpandedItems(const QModelIndex& index, const QString& parent_path, const std::set<QString>& exp, const std::set<QString> &sel)
void NewFriendList::recursRestoreExpandedItems(const QModelIndex& index, const QString& parent_path, const std::set<QString>& exp, const QString& sel,QModelIndex& selected_index)
{
QString local_path = parent_path + index.sibling(index.row(),RsFriendListModel::COLUMN_THREAD_ID).data(Qt::DisplayRole).toString() + " ";
#ifdef DEBUG_NEW_FRIEND_LIST
std::cerr << "at index " << index.row() << ". data[1]=" << local_path.toStdString() << std::endl;
std::cerr << " At index " << index.row() << ". data[1]=" << local_path.toStdString() ;
#endif
if(sel.find(local_path) != sel.end())
ui->peerTreeWidget->selectionModel()->select(index, QItemSelectionModel::Select | QItemSelectionModel::Rows);
if(exp.find(local_path) != exp.end())
{
#ifdef DEBUG_NEW_FRIEND_LIST
std::cerr << "re expanding index " << local_path.toStdString() << std::endl;
std::cerr << " re expanding " << std::endl;
#endif
ui->peerTreeWidget->setExpanded(index,true) ;
for(int row=0;row<mProxyModel->rowCount(index);++row)
recursRestoreExpandedItems(index.child(row,0),local_path,exp,sel) ;
recursRestoreExpandedItems(index.child(row,0),local_path,exp,sel,selected_index) ;
}
if(sel == local_path)
{
#ifdef DEBUG_NEW_FRIEND_LIST
std::cerr << " selecting index \"" << local_path.toStdString() << "\"" << std::endl;
#endif
ui->peerTreeWidget->selectionModel()->select(index, QItemSelectionModel::Select | QItemSelectionModel::Rows);
selected_index = index;
}
#ifdef DEBUG_NEW_FRIEND_LIST
else
std::cerr << std::endl;
#endif
}
@ -1031,11 +1048,6 @@ void NewFriendList::forceUpdateDisplay()
checkInternalData(true);
}
// void NewFriendList::updateDisplay()
// {
// checkInternalData(false);
// }
void NewFriendList::moveToGroup()
{
RsFriendListModel::RsProfileDetails pinfo;
@ -1109,9 +1121,14 @@ void NewFriendList::removeGroup()
void NewFriendList::applyWhileKeepingTree(std::function<void()> predicate)
{
std::set<QString> expanded_indexes;
std::set<QString> selected_indexes;
QString selected;
saveExpandedPathsAndSelection(expanded_indexes, selected_indexes);
saveExpandedPathsAndSelection(expanded_indexes, selected);
#ifdef DEBUG_NEW_FRIEND_LIST
std::cerr << "After collecting selection, selected paths is: \"" << selected.toStdString() << "\"" << std::endl;
#endif
whileBlocking(ui->peerTreeWidget)->clearSelection();
// This is a hack to avoid crashes on windows while calling endInsertRows(). I'm not sure wether these crashes are
// due to a Qt bug, or a misuse of the proxy model on my side. Anyway, this solves them for good.
@ -1132,8 +1149,9 @@ void NewFriendList::applyWhileKeepingTree(std::function<void()> predicate)
predicate();
QModelIndex selected_index;
mProxyModel->setSourceModel(mModel);
restoreExpandedPathsAndSelection(expanded_indexes, selected_indexes);
restoreExpandedPathsAndSelection(expanded_indexes,selected,selected_index);
// restore hidden columns
for(uint32_t i=0;i<RsFriendListModel::COLUMN_THREAD_NB_COLUMNS;++i)
@ -1143,9 +1161,36 @@ void NewFriendList::applyWhileKeepingTree(std::function<void()> predicate)
}
// restore sorting
sortColumn(mLastSortColumn,mLastSortOrder);
// sortColumn(mLastSortColumn,mLastSortOrder);
mProxyModel->sort(mLastSortColumn,mLastSortOrder);
if(selected_index.isValid())
ui->peerTreeWidget->scrollTo(selected_index);
}
void NewFriendList::sortColumn(int col,Qt::SortOrder so)
{
std::set<QString> expanded_indexes;
QString selected;
QModelIndex selected_index;
saveExpandedPathsAndSelection(expanded_indexes, selected);
whileBlocking(ui->peerTreeWidget)->clearSelection();
mProxyModel->setSortingEnabled(true);
mProxyModel->sort(col,so);
mProxyModel->setSortingEnabled(false);
restoreExpandedPathsAndSelection(expanded_indexes,selected,selected_index);
if(selected_index.isValid())
ui->peerTreeWidget->scrollTo(selected_index);
mLastSortColumn = col;
mLastSortOrder = so;
}
void NewFriendList::checkInternalData(bool force)
{
applyWhileKeepingTree([force,this]() { mModel->checkInternalData(force) ; });

View File

@ -106,10 +106,10 @@ private:
void applyWhileKeepingTree(std::function<void()> predicate);
void expandGroup(const RsNodeGroupId& gid);
void recursRestoreExpandedItems(const QModelIndex& index, const QString& parent_path, const std::set<QString>& exp, const std::set<QString> &sel);
void recursSaveExpandedItems(const QModelIndex& index,const QString& parent_path,std::set<QString>& exp, std::set<QString>& sel);
void saveExpandedPathsAndSelection(std::set<QString>& expanded_indexes, std::set<QString>& selected_indexes);
void restoreExpandedPathsAndSelection(const std::set<QString>& expanded_indexes, const std::set<QString>& selected_indexes);
void recursRestoreExpandedItems(const QModelIndex& index, const QString& parent_path, const std::set<QString>& exp, const QString &sel, QModelIndex &selected_index);
void recursSaveExpandedItems(const QModelIndex& index, const QModelIndex& current_index, const QString& parent_path, std::set<QString>& exp, QString &sel);
void saveExpandedPathsAndSelection(std::set<QString>& expanded_indexes, QString& sel);
void restoreExpandedPathsAndSelection(const std::set<QString>& expanded_indexes, const QString &index_to_select, QModelIndex &selected_index);
void checkInternalData(bool force);
@ -123,6 +123,7 @@ private:
bool mShowState;
RsEventsHandlerId_t mEventHandlerId_peer;
RsEventsHandlerId_t mEventHandlerId_gssp;
RsEventsHandlerId_t mEventHandlerId_pssc;
std::set<RsNodeGroupId> openGroups;
std::set<RsPgpId> openPeers;

View File

@ -25,9 +25,6 @@
#include "ui_GxsGroupShareKey.h"
#define CHANNEL_KEY_SHARE 0x00000001
#define FORUM_KEY_SHARE 0x00000002
#define POSTED_KEY_SHARE 0x00000003
class GroupShareKey : public QDialog
{
@ -40,6 +37,13 @@ public:
GroupShareKey(QWidget *parent = 0, const RsGxsGroupId& grpId = RsGxsGroupId(), int grpType = 0);
~GroupShareKey();
enum KeyShareType: uint8_t {
NO_KEY_SHARE = 0x00000000,
CHANNEL_KEY_SHARE = 0x00000001,
FORUM_KEY_SHARE = 0x00000002,
POSTED_KEY_SHARE = 0x00000003,
};
protected:
void changeEvent(QEvent *e);

View File

@ -61,6 +61,8 @@
#define MAX_ATTEMPTS 10
#define MAX_PROCESS_COUNT_PER_TIMER 50
// #define DEBUG_GXSIDDETAILS 1
//const int kRecognTagClass_DEVELOPMENT = 1;
//
//const int kRecognTagType_Dev_Ambassador = 1;
@ -405,6 +407,9 @@ const QPixmap GxsIdDetails::makeDefaultIcon(const RsGxsId& id, AvatarSize size)
// now look for the icon
if(id.isNull())
std::cerr << "Weird: null ID" << std::endl;
QMutexLocker lock(&mIconCacheMutex);
auto& it = mDefaultIconCache[id];
@ -432,6 +437,31 @@ const QPixmap GxsIdDetails::makeDefaultIcon(const RsGxsId& id, AvatarSize size)
return image;
}
void GxsIdDetails::debug_dumpImagesCache()
{
QMutexLocker lock(&mIconCacheMutex);
std::cerr << "Current icon cache:" << std::endl;
for(const auto& it:mDefaultIconCache) // the & is important here, otherwise pairs are copied and isDetached() is always false!
{
std::cerr << " Identity " << it.first << ":" << std::endl;
for(uint32_t i=0;i<4;++i)
{
std::cerr << " Size #" << i << ": " ;
if(it.second[i].first>0)
{
int s = it.second[i].second.width()*it.second[i].second.height()*4;
std::cerr << " Present. Size=" << s << " bytes. Age: " << time(nullptr)-it.second[i].first << " secs. ago. Used: " << !it.second[i].second.isDetached() << std::endl;
}
else
std::cerr << " None." << std::endl;
}
}
}
void GxsIdDetails::checkCleanImagesCache()
{
time_t now = time(NULL);
@ -440,7 +470,9 @@ void GxsIdDetails::checkCleanImagesCache()
if(mLastIconCacheCleaning + DELAY_BETWEEN_ICON_CACHE_CLEANING < now)
{
#ifdef DEBUG_GXSIDDETAILS
std::cerr << "(II) Cleaning the icons cache." << std::endl;
#endif
int nb_deleted = 0;
uint32_t size_deleted = 0;
uint32_t total_size = 0;
@ -450,26 +482,43 @@ void GxsIdDetails::checkCleanImagesCache()
for(auto it(mDefaultIconCache.begin());it!=mDefaultIconCache.end();)
{
bool all_empty = true ;
#ifdef DEBUG_GXSIDDETAILS
std::cerr << " Examining pixmaps sizes for " << it->first << "." << std::endl;
#endif
for(int i=0;i<4;++i)
if(it->second[i].first + ICON_CACHE_STORAGE_TIME < now && it->second[i].second.isDetached())
{
int s = it->second[i].second.width()*it->second[i].second.height()*4;
std::cerr << "Deleting pixmap " << it->first << " size " << i << " " << s << " bytes." << std::endl;
it->second[i].second = QPixmap();
++nb_deleted;
size_deleted += s;
}
else
if(it->second[i].first>0)
{
all_empty = false;
total_size += it->second[i].second.width()*it->second[i].second.height()*4;
if(it->second[i].first + ICON_CACHE_STORAGE_TIME < now && it->second[i].second.isDetached())
{
int s = it->second[i].second.width()*it->second[i].second.height()*4;
#ifdef DEBUG_GXSIDDETAILS
std::cerr << " Deleting pixmap " << it->first << " size " << i << " " << s << " bytes." << std::endl;
#endif
it->second[i].second = QPixmap();
it->second[i].first = 0;
++nb_deleted;
size_deleted += s;
}
else
{
all_empty = false;
total_size += it->second[i].second.width()*it->second[i].second.height()*4;
#ifdef DEBUG_GXSIDDETAILS
std::cerr << " Keeking " << it->first << " size " << i << std::endl;
#endif
}
}
if(all_empty)
it = mDefaultIconCache.erase(it);
{
#ifdef DEBUG_GXSIDDETAILS
std::cerr << " Deleting entry " << it->first << " because no pixmaps are stored here. " << std::endl;
#endif
it = mDefaultIconCache.erase(it);
}
else
++it;
}
@ -490,10 +539,16 @@ bool GxsIdDetails::loadPixmapFromData(const unsigned char *data,size_t data_len,
Sha1CheckSum chksum = RsDirUtil::sha1sum(data,data_len);
RsGxsId id(chksum.toByteArray());
if(id.isNull())
std::cerr << "Weird: null ID" << std::endl;
// We use a cache for images. QImage has its own smart pointer system, but it does not prevent
// the same image to be allocated many times. We do this using a cache. The cache is also cleaned-up
// on a regular time basis so as to get rid of unused images.
#ifdef DEBUG_GXSIDDETAILS
debug_dumpImagesCache();
#endif
checkCleanImagesCache();
// now look for the icon

View File

@ -113,7 +113,8 @@ public:
static const QPixmap makeDefaultIcon(const RsGxsId& id, AvatarSize size = MEDIUM);
static bool loadPixmapFromData(const unsigned char *data, size_t data_len, QPixmap& pix, AvatarSize size = MEDIUM);
static void checkCleanImagesCache();
static void checkCleanImagesCache();
static void debug_dumpImagesCache();
/* Processing */
static void enableProcess(bool enable);

View File

@ -207,7 +207,7 @@ GxsGroupDialog *GxsChannelDialog::createGroupDialog(GxsGroupDialog::Mode mode, R
int GxsChannelDialog::shareKeyType()
{
return CHANNEL_KEY_SHARE;
return GroupShareKey::CHANNEL_KEY_SHARE;
}
GxsMessageFrameWidget *GxsChannelDialog::createMessageFrameWidget(const RsGxsGroupId &groupId)