Merge pull request #1922 from PhenomRetroShare/Fix_SomeWarnings

Fix some warnings
This commit is contained in:
csoler 2020-05-12 23:05:34 +02:00 committed by GitHub
commit e6edae27be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 72 additions and 68 deletions

View File

@ -83,19 +83,19 @@ void RsMsgTagType::serial_process(RsGenericSerializer::SerializeJob j,RsGenericS
void RsMsgTags::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) void RsMsgTags::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
{ {
RsTypeSerializer::serial_process<uint32_t>(j,ctx,msgId,"msgId") ; RsTypeSerializer::serial_process<uint32_t>(j,ctx,msgId,"msgId") ;
#warning this is not the correct way to serialise here. We should directly call serial_process<std::vector<uint32_t> >() but for backward compatibility, we cannot #warning this is not the correct way to serialise here. We should directly call serial_process<std::vector<uint32_t> >() but for backward compatibility, we cannot
if(j == RsGenericSerializer::DESERIALIZE) if(j == RsGenericSerializer::DESERIALIZE)
while(ctx.mOffset < ctx.mSize) while(ctx.mOffset < ctx.mSize)
{ {
uint32_t n ; uint32_t n = 0;// No real need to initialize but otherwise the compiler complains.
RsTypeSerializer::serial_process<uint32_t>(j,ctx,n,"tagIds element") ; RsTypeSerializer::serial_process<uint32_t>(j,ctx,n,"tagIds element") ;
tagIds.push_back(n) ; tagIds.push_back(n) ;
} }
else else
for(std::list<uint32_t>::iterator it(tagIds.begin());it!=tagIds.end();++it) for(std::list<uint32_t>::iterator it(tagIds.begin());it!=tagIds.end();++it)
RsTypeSerializer::serial_process<uint32_t>(j,ctx,*it,"tagIds element") ; RsTypeSerializer::serial_process<uint32_t>(j,ctx,*it,"tagIds element") ;
} }

View File

@ -322,13 +322,13 @@ void IdDetailsDialog::modifyReputation()
case 2: op = RsOpinion::POSITIVE; break; case 2: op = RsOpinion::POSITIVE; break;
default: default:
std::cerr << "Wrong value from opinion combobox. Bug??" << std::endl; std::cerr << "Wrong value from opinion combobox. Bug??" << std::endl;
break; return;
} }
rsReputations->setOwnOpinion(id,op); rsReputations->setOwnOpinion(id,op);
// trigger refresh when finished. // trigger refresh when finished.
// basic / anstype are not needed. // basic / anstype are not needed.
loadIdentity(); loadIdentity();
return; return;
} }

View File

@ -617,100 +617,104 @@ public:
QVariant RsFriendListModel::displayRole(const EntryIndex& e, int col) const QVariant RsFriendListModel::displayRole(const EntryIndex& e, int col) const
{ {
#ifdef DEBUG_MODEL_INDEX #ifdef DEBUG_MODEL_INDEX
std::cerr << " Display role " << e.type << ", (" << (int)e.group_index << ","<< (int)e.profile_index << ","<< (int)e.node_index << ") col="<< col<<": "; std::cerr << " Display role " << e.type << ", (" << (int)e.group_index << ","<< (int)e.profile_index << ","<< (int)e.node_index << ") col="<< col<<": ";
AutoEndel x; AutoEndel x;
#endif #endif
switch(e.type) switch(e.type)
{ {
case ENTRY_TYPE_GROUP: case ENTRY_TYPE_GROUP:
{ {
const HierarchicalGroupInformation *group = getGroupInfo(e); const HierarchicalGroupInformation *group = getGroupInfo(e);
if(!group) if(!group)
return QVariant(); return QVariant();
uint32_t nb_online = 0; uint32_t nb_online = 0;
for(uint32_t i=0;i<group->child_profile_indices.size();++i) for(uint32_t i=0;i<group->child_profile_indices.size();++i)
for(uint32_t j=0;j<mProfiles[group->child_profile_indices[i]].child_node_indices.size();++j) for(uint32_t j=0;j<mProfiles[group->child_profile_indices[i]].child_node_indices.size();++j)
if(mLocations[mProfiles[group->child_profile_indices[i]].child_node_indices[j]].node_info.state & RS_PEER_STATE_CONNECTED) if(mLocations[mProfiles[group->child_profile_indices[i]].child_node_indices[j]].node_info.state & RS_PEER_STATE_CONNECTED)
{ {
nb_online++; nb_online++;
break;// only breaks the inner loop, on purpose. break;// only breaks the inner loop, on purpose.
} }
switch(col) switch(col)
{ {
case COLUMN_THREAD_NAME: case COLUMN_THREAD_NAME:
#ifdef DEBUG_MODEL_INDEX #ifdef DEBUG_MODEL_INDEX
std::cerr << group->group_info.name.c_str() ; std::cerr << group->group_info.name.c_str() ;
#endif #endif
if(!group->child_profile_indices.empty()) if(!group->child_profile_indices.empty())
return QVariant(QString::fromUtf8(group->group_info.name.c_str())+" (" + QString::number(nb_online) + "/" + QString::number(group->child_profile_indices.size()) + ")"); return QVariant(QString::fromUtf8(group->group_info.name.c_str())+" (" + QString::number(nb_online) + "/" + QString::number(group->child_profile_indices.size()) + ")");
else else
return QVariant(QString::fromUtf8(group->group_info.name.c_str())); return QVariant(QString::fromUtf8(group->group_info.name.c_str()));
case COLUMN_THREAD_ID: return QVariant(QString::fromStdString(group->group_info.id.toStdString())); case COLUMN_THREAD_ID: return QVariant(QString::fromStdString(group->group_info.id.toStdString()));
default: default:
return QVariant(); return QVariant();
} }
} }
break; break;
case ENTRY_TYPE_PROFILE: case ENTRY_TYPE_PROFILE:
{ {
const HierarchicalProfileInformation *profile = getProfileInfo(e); const HierarchicalProfileInformation *profile = getProfileInfo(e);
if(!profile) if(!profile)
return QVariant(); return QVariant();
#ifdef DEBUG_MODEL_INDEX #ifdef DEBUG_MODEL_INDEX
std::cerr << profile->profile_info.name.c_str() ; std::cerr << profile->profile_info.name.c_str() ;
#endif #endif
switch(col) switch(col)
{ {
case COLUMN_THREAD_NAME: return QVariant(QString::fromUtf8(profile->profile_info.name.c_str())); case COLUMN_THREAD_NAME: return QVariant(QString::fromUtf8(profile->profile_info.name.c_str()));
case COLUMN_THREAD_ID: return QVariant(QString::fromStdString(profile->profile_info.gpg_id.toStdString()) ); case COLUMN_THREAD_ID: return QVariant(QString::fromStdString(profile->profile_info.gpg_id.toStdString()) );
default: default:
return QVariant(); return QVariant();
} }
} }
break; break;
case ENTRY_TYPE_NODE: case ENTRY_TYPE_NODE:
const HierarchicalNodeInformation *node = getNodeInfo(e); {
const HierarchicalNodeInformation *node = getNodeInfo(e);
if(!node) if(!node)
return QVariant(); return QVariant();
#ifdef DEBUG_MODEL_INDEX #ifdef DEBUG_MODEL_INDEX
std::cerr << node->node_info.location.c_str() ; std::cerr << node->node_info.location.c_str() ;
#endif #endif
switch(col) switch(col)
{ {
case COLUMN_THREAD_NAME: if(node->node_info.location.empty()) case COLUMN_THREAD_NAME: if(node->node_info.location.empty())
return QVariant(QString::fromStdString(node->node_info.id.toStdString())); return QVariant(QString::fromStdString(node->node_info.id.toStdString()));
{ {
std::string css = rsMsgs->getCustomStateString(node->node_info.id); std::string css = rsMsgs->getCustomStateString(node->node_info.id);
if(!css.empty() && mDisplayStatusString) if(!css.empty() && mDisplayStatusString)
return QVariant(QString::fromUtf8(node->node_info.location.c_str())+"\n"+QString::fromUtf8(css.c_str())); return QVariant(QString::fromUtf8(node->node_info.location.c_str())+"\n"+QString::fromUtf8(css.c_str()));
else else
return QVariant(QString::fromUtf8(node->node_info.location.c_str())); return QVariant(QString::fromUtf8(node->node_info.location.c_str()));
} }
case COLUMN_THREAD_LAST_CONTACT: return QVariant(QDateTime::fromTime_t(node->node_info.lastConnect).toString()); case COLUMN_THREAD_LAST_CONTACT: return QVariant(QDateTime::fromTime_t(node->node_info.lastConnect).toString());
case COLUMN_THREAD_IP: return QVariant( (node->node_info.state & RS_PEER_STATE_CONNECTED) ? StatusDefs::connectStateIpString(node->node_info) : QString("---")); case COLUMN_THREAD_IP: return QVariant( (node->node_info.state & RS_PEER_STATE_CONNECTED) ? StatusDefs::connectStateIpString(node->node_info) : QString("---"));
case COLUMN_THREAD_ID: return QVariant( QString::fromStdString(node->node_info.id.toStdString()) ); case COLUMN_THREAD_ID: return QVariant( QString::fromStdString(node->node_info.id.toStdString()) );
default: default:
return QVariant(); return QVariant();
} break; } break;
}
break;
default: //ENTRY_TYPE
return QVariant(); return QVariant();
} }
} }