From d96b9b054ba186881fcf855ffc6c5f0fa8c604d0 Mon Sep 17 00:00:00 2001 From: Phenom Date: Sat, 23 Feb 2019 19:28:45 +0100 Subject: [PATCH] Fix clang warnings for ../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp: 106:53: warning: unused parameter 'parent' [-Wunused-parameter] int RsGxsForumModel::columnCount(const QModelIndex &parent) const ^ ../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:245:3: warning: add explicit braces to avoid dangling else [-Wdangling-else] else ^ ../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp: 248:12: warning: comparison of integers of different signs: 'int' and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare] if(row >= mPosts[entry].mChildren.size()) ~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp: 299:67: warning: unused parameter 'orientation' [-Wunused-parameter] QVariant RsGxsForumModel::headerData(int section, Qt::Orientation orientation, int role) const ^ ../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp: 398:77: warning: unused parameter 'column' [-Wunused-parameter] QVariant RsGxsForumModel::textColorRole(const ForumModelPostEntry& fmpe,int column) const ^ ../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp: 419:74: warning: unused parameter 'column' [-Wunused-parameter] QVariant RsGxsForumModel::filterRole(const ForumModelPostEntry& fmpe,int column) const ^ ../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp: 498:75: warning: unused parameter 'column' [-Wunused-parameter] QVariant RsGxsForumModel::missingRole(const ForumModelPostEntry& fmpe,int column) const ^ ../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp: 540:74: warning: unused parameter 'column' [-Wunused-parameter] QVariant RsGxsForumModel::pinnedRole(const ForumModelPostEntry& fmpe,int column) const ^ ../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp: 548:78: warning: unused parameter 'column' [-Wunused-parameter] QVariant RsGxsForumModel::backgroundRole(const ForumModelPostEntry& fmpe,int column) const ^ ../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp: 806:111: warning: unused parameter 'useChildTS' [-Wunused-parameter] void RsGxsForumModel::convertMsgToPostEntry(const RsGxsForumGroup& mForumGroup,const RsMsgMetaData& msg, bool useChildTS, ForumModelPostEntry& fentry) ^ ../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:828:7: warning: unused variable 'redacted' [-Wunused-variable] bool redacted = false; ^ ../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:880:6: warning: unused variable 'pos' [-Wunused-variable] int pos = 0; ^ ../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:879:6: warning: unused variable 'count' [-Wunused-variable] int count = msgs.size(); ^ ../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp:882:6: warning: unused variable 'step' [-Wunused-variable] int step = 0; ^ ../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp: 949:26: warning: comparison of integers of different signs: 'int32_t' (aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign- compare] for(int32_t i=0;isecond.size();++j) ~^~~~~~~~~~~~~~~~~~~ ../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp: 991:26: warning: comparison of integers of different signs: 'int32_t' (aka 'int') and 'std::vector::size_type' (aka 'unsigned long') [-Wsign- compare] for(int32_t i=1;isecond.size();++i) ~^~~~~~~~~~~~~~~~~~ ../../../trunk/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp: 1005:22: warning: comparison of integers of different signs: 'int' and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare] for(int i=1;isecond.size();++i) ~^~~~~~~~~~~~~~~~~~ ../../../trunk/retroshare-gui/src/gui/gxsforums/ GxsForumThreadWidget.cpp:1038:13: warning: unused function 'cleanupItems' [-Wunused-function] static void cleanupItems (QList &items) ^ --- .../src/gui/gxsforums/GxsForumModel.cpp | 67 +++++++++++-------- .../gui/gxsforums/GxsForumThreadWidget.cpp | 11 --- 2 files changed, 38 insertions(+), 40 deletions(-) diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp index c9fc624c1..500d97667 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp @@ -103,7 +103,7 @@ int RsGxsForumModel::rowCount(const QModelIndex& parent) const return getChildrenCount(parent.internalPointer()); } -int RsGxsForumModel::columnCount(const QModelIndex &parent) const +int RsGxsForumModel::columnCount(const QModelIndex &/*parent*/) const { return COLUMN_THREAD_NB_COLUMNS ; } @@ -229,6 +229,9 @@ Qt::ItemFlags RsGxsForumModel::flags(const QModelIndex& index) const void *RsGxsForumModel::getChildRef(void *ref,int row) const { + if (row < 0) + return nullptr; + ForumModelIndex entry ; if(!convertRefPointerToTabEntry(ref,entry) || entry >= mPosts.size()) @@ -236,16 +239,20 @@ void *RsGxsForumModel::getChildRef(void *ref,int row) const void *new_ref; - if(mTreeMode == TREE_MODE_FLAT) - if(entry == 0) - { + if(mTreeMode == TREE_MODE_FLAT) + { + if(entry == 0) + { convertTabEntryToRefPointer(row+1,new_ref); - return new_ref; - } + return new_ref; + } else - return NULL ; + { + return NULL ; + } + } - if(row >= mPosts[entry].mChildren.size()) + if(static_cast(row) >= mPosts[entry].mChildren.size()) return NULL; convertTabEntryToRefPointer(mPosts[entry].mChildren[row],new_ref); @@ -296,7 +303,7 @@ int RsGxsForumModel::getChildrenCount(void *ref) const return mPosts[entry].mChildren.size(); } -QVariant RsGxsForumModel::headerData(int section, Qt::Orientation orientation, int role) const +QVariant RsGxsForumModel::headerData(int section, Qt::Orientation /*orientation*/, int role) const { if(role == Qt::DisplayRole) switch(section) @@ -395,7 +402,7 @@ QVariant RsGxsForumModel::data(const QModelIndex &index, int role) const } } -QVariant RsGxsForumModel::textColorRole(const ForumModelPostEntry& fmpe,int column) const +QVariant RsGxsForumModel::textColorRole(const ForumModelPostEntry& fmpe,int /*column*/) const { if( (fmpe.mPostFlags & ForumModelPostEntry::FLAG_POST_IS_MISSING)) return QVariant(mTextColorMissing); @@ -416,7 +423,7 @@ QVariant RsGxsForumModel::statusRole(const ForumModelPostEntry& fmpe,int column) return QVariant(fmpe.mMsgStatus); } -QVariant RsGxsForumModel::filterRole(const ForumModelPostEntry& fmpe,int column) const +QVariant RsGxsForumModel::filterRole(const ForumModelPostEntry& fmpe,int /*column*/) const { if(!mFilteringEnabled || (fmpe.mPostFlags & ForumModelPostEntry::FLAG_POST_CHILDREN_PASSES_FILTER)) return QVariant(FilterString); @@ -495,7 +502,7 @@ void RsGxsForumModel::setFilter(int column,const QStringList& strings,uint32_t& postMods(); } -QVariant RsGxsForumModel::missingRole(const ForumModelPostEntry& fmpe,int column) const +QVariant RsGxsForumModel::missingRole(const ForumModelPostEntry& fmpe,int /*column*/) const { if(fmpe.mPostFlags & ForumModelPostEntry::FLAG_POST_IS_MISSING) return QVariant(true); @@ -537,7 +544,7 @@ QVariant RsGxsForumModel::toolTipRole(const ForumModelPostEntry& fmpe,int column return QVariant(); } -QVariant RsGxsForumModel::pinnedRole(const ForumModelPostEntry& fmpe,int column) const +QVariant RsGxsForumModel::pinnedRole(const ForumModelPostEntry& fmpe,int /*column*/) const { if(fmpe.mPostFlags & ForumModelPostEntry::FLAG_POST_IS_PINNED) return QVariant(true); @@ -545,7 +552,7 @@ QVariant RsGxsForumModel::pinnedRole(const ForumModelPostEntry& fmpe,int column) return QVariant(false); } -QVariant RsGxsForumModel::backgroundRole(const ForumModelPostEntry& fmpe,int column) const +QVariant RsGxsForumModel::backgroundRole(const ForumModelPostEntry& fmpe,int /*column*/) const { if(fmpe.mPostFlags & ForumModelPostEntry::FLAG_POST_IS_PINNED) return QVariant(QBrush(QColor(255,200,180))); @@ -803,7 +810,7 @@ void RsGxsForumModel::generateMissingItem(const RsGxsMessageId &msgId,ForumModel entry.mReputationWarningLevel = 3; } -void RsGxsForumModel::convertMsgToPostEntry(const RsGxsForumGroup& mForumGroup,const RsMsgMetaData& msg, bool useChildTS, ForumModelPostEntry& fentry) +void RsGxsForumModel::convertMsgToPostEntry(const RsGxsForumGroup& mForumGroup,const RsMsgMetaData& msg, bool /*useChildTS*/, ForumModelPostEntry& fentry) { fentry.mTitle = msg.mMsgName; fentry.mAuthorId = msg.mAuthorId; @@ -877,10 +884,12 @@ void RsGxsForumModel::computeMessagesHierarchy(const RsGxsForumGroup& forum_grou msgs[msgs_metas_array[i].mMsgId] = msgs_metas_array[i] ; } - int count = msgs.size(); - int pos = 0; +#ifdef DEBUG_FORUMS + size_t count = msgs.size(); +#endif +// int pos = 0; // int steps = count / PROGRESSBAR_MAX; - int step = 0; +// int step = 0; initEmptyHierarchy(posts); @@ -947,8 +956,8 @@ void RsGxsForumModel::computeMessagesHierarchy(const RsGxsForumGroup& forum_grou { auto& v(it->second) ; - for(int32_t i=0;ifirst) { RsGxsMessageId sub_msg_id = v[i].second ; @@ -957,14 +966,14 @@ void RsGxsForumModel::computeMessagesHierarchy(const RsGxsForumGroup& forum_grou if(it2 != mPostVersions.end()) { - for(int32_t j=0;jsecond.size();++j) + for(size_t j=0;jsecond.size();++j) if(it2->second[j].second != sub_msg_id) // dont copy it, since it is already present at slot i v.push_back(it2->second[j]) ; mPostVersions.erase(it2) ; // it2 is never equal to it } } - } + } } @@ -989,23 +998,23 @@ void RsGxsForumModel::computeMessagesHierarchy(const RsGxsForumGroup& forum_grou #ifdef DEBUG_FORUMS std::cerr << " most recent version " << (*it)[0].first << " " << (*it)[0].second << std::endl; #endif - for(int32_t i=1;isecond.size();++i) - { + for(size_t i=1;isecond.size();++i) + { msgs.erase(it->second[i].second) ; #ifdef DEBUG_FORUMS - std::cerr << " older version " << (*it)[i].first << " " << (*it)[i].second << std::endl; + std::cerr << " older version " << (*it)[i].first << " " << (*it)[i].second << std::endl; #endif - } + } mTmp[it->second[0].second] = it->second ; // index the versions map by the ID of the most recent post. // Now make sure that message parents are consistent. Indeed, an old post may have the old version of a post as parent. So we need to change that parent // to the newest version. So we create a map of which is the most recent version of each message, so that parent messages can be searched in it. - for(int i=1;isecond.size();++i) - most_recent_versions[it->second[i].second] = it->second[0].second ; - } + for(size_t i=1;isecond.size();++i) + most_recent_versions[it->second[i].second] = it->second[0].second ; + } mPostVersions = mTmp ; // The next step is to find the top level thread messages. These are defined as the messages without diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index f01c054e8..f3340c887 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -1035,17 +1035,6 @@ void GxsForumThreadWidget::clickedThread(QModelIndex index) #endif } -static void cleanupItems (QList &items) -{ - QList::iterator item; - for (item = items.begin (); item != items.end (); ++item) { - if (*item) { - delete (*item); - } - } - items.clear(); -} - static QString getDurationString(uint32_t days) { switch(days)