From 5f0afb3d6e867306c7d86b73102e3a730f2b96fa Mon Sep 17 00:00:00 2001 From: Phenom Date: Mon, 8 Feb 2016 19:42:56 +0100 Subject: [PATCH] Fix Channel filter when loading big post. And fix "Not a GxsChannelPostItem, deleting!" error message Don't search empty text in very long string. --- libretroshare/src/services/p3gxschannels.cc | 28 ++++++++++-- .../gui/gxschannels/GxsChannelPostsWidget.cpp | 43 ++++++++++--------- 2 files changed, 48 insertions(+), 23 deletions(-) diff --git a/libretroshare/src/services/p3gxschannels.cc b/libretroshare/src/services/p3gxschannels.cc index a8b7224ef..36378d37d 100644 --- a/libretroshare/src/services/p3gxschannels.cc +++ b/libretroshare/src/services/p3gxschannels.cc @@ -353,7 +353,18 @@ bool p3GxsChannels::getPostData(const uint32_t &token, std::vector(*vit); + if(!cmt) + { + RsGxsMsgItem* msg = (*vit); + //const uint16_t RS_SERVICE_GXS_TYPE_CHANNELS = 0x0217; + //const uint8_t RS_PKT_SUBTYPE_GXSCHANNEL_POST_ITEM = 0x03; + //const uint8_t RS_PKT_SUBTYPE_GXSCOMMENT_COMMENT_ITEM = 0xf1; + std::cerr << "Not a GxsChannelPostItem neither a RsGxsCommentItem" + << " PacketService=" << std::hex << (int)msg->PacketService() << std::dec + << " PacketSubType=" << std::hex << (int)msg->PacketSubType() << std::dec + << " , deleting!" << std::endl; + } delete *vit; } } @@ -401,7 +412,18 @@ bool p3GxsChannels::getRelatedPosts(const uint32_t &token, std::vector(*vit); + if(!cmt) + { + RsGxsMsgItem* msg = (*vit); + //const uint16_t RS_SERVICE_GXS_TYPE_CHANNELS = 0x0217; + //const uint8_t RS_PKT_SUBTYPE_GXSCHANNEL_POST_ITEM = 0x03; + //const uint8_t RS_PKT_SUBTYPE_GXSCOMMENT_COMMENT_ITEM = 0xf1; + std::cerr << "Not a GxsChannelPostItem neither a RsGxsCommentItem" + << " PacketService=" << std::hex << (int)msg->PacketService() << std::dec + << " PacketSubType=" << std::hex << (int)msg->PacketSubType() << std::dec + << " , deleting!" << std::endl; + } delete *vit; } } @@ -1560,7 +1582,7 @@ void p3GxsChannels::handle_event(uint32_t event_type, const std::string &elabel) default: /* error */ - std::cerr << "p3GxsChannels::handle_event() Unknown Event Type: " << event_type; + std::cerr << "p3GxsChannels::handle_event() Unknown Event Type: " << event_type << " elabel:" << elabel; std::cerr << std::endl; break; } diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp index 0041976a3..15cb71092 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp @@ -327,29 +327,32 @@ void GxsChannelPostsWidget::filterChanged(int filter) bool bVisible = text.isEmpty(); - switch(filter) + if (!bVisible) { - case FILTER_TITLE: - bVisible = item->getTitleLabel().contains(text,Qt::CaseInsensitive); - break; - case FILTER_MSG: - bVisible = item->getMsgLabel().contains(text,Qt::CaseInsensitive); - break; - case FILTER_FILE_NAME: - { - std::list fileItems = item->getFileItems(); - std::list::iterator lit; - for(lit = fileItems.begin(); lit != fileItems.end(); ++lit) + switch(filter) { - SubFileItem *fi = *lit; - QString fileName = QString::fromUtf8(fi->FileName().c_str()); - bVisible = (bVisible || fileName.contains(text,Qt::CaseInsensitive)); + case FILTER_TITLE: + bVisible = item->getTitleLabel().contains(text,Qt::CaseInsensitive); + break; + case FILTER_MSG: + bVisible = item->getMsgLabel().contains(text,Qt::CaseInsensitive); + break; + case FILTER_FILE_NAME: + { + std::list fileItems = item->getFileItems(); + std::list::iterator lit; + for(lit = fileItems.begin(); lit != fileItems.end(); ++lit) + { + SubFileItem *fi = *lit; + QString fileName = QString::fromUtf8(fi->FileName().c_str()); + bVisible = (bVisible || fileName.contains(text,Qt::CaseInsensitive)); + } + break; + } + default: + bVisible = true; + break; } - break; - } - default: - bVisible = true; - break; } return bVisible;