mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
FeedReeder:
- Fixed memory leak in xpath processing - Stop long loops when closing the preview dialog or shutdown - Added drag and drop to xpath lists in preview dialog - Fixed save of xpaths lists git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6074 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
66c4a3d71b
commit
13f2863569
@ -191,7 +191,9 @@ PreviewFeedDialog::PreviewFeedDialog(RsFeedReader *feedReader, FeedReaderNotify
|
||||
updateMsgCount();
|
||||
|
||||
ui->xpathUseListWidget->installEventFilter(this);
|
||||
ui->xpathUseListWidget->viewport()->installEventFilter(this);
|
||||
ui->xpathRemoveListWidget->installEventFilter(this);
|
||||
ui->xpathRemoveListWidget->viewport()->installEventFilter(this);
|
||||
|
||||
/* load settings */
|
||||
processSettings(true);
|
||||
@ -253,6 +255,9 @@ bool PreviewFeedDialog::eventFilter(QObject *obj, QEvent *event)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (event->type() == QEvent::Drop) {
|
||||
processXPath();
|
||||
}
|
||||
/* pass the event on to the parent class */
|
||||
return QDialog::eventFilter(obj, event);
|
||||
}
|
||||
@ -733,6 +738,9 @@ void PreviewFeedDialog::fillStructureTree()
|
||||
|
||||
void PreviewFeedDialog::getXPaths(std::list<std::string> &xpathsToUse, std::list<std::string> &xpathsToRemove)
|
||||
{
|
||||
xpathsToUse.clear();
|
||||
xpathsToRemove.clear();
|
||||
|
||||
int row;
|
||||
int rowCount = ui->xpathUseListWidget->count();
|
||||
for (row = 0; row < rowCount; ++row) {
|
||||
|
@ -166,6 +166,22 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>10</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="messageCountLabel">
|
||||
<property name="sizePolicy">
|
||||
@ -179,6 +195,22 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>10</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="nextPushButton">
|
||||
<property name="sizePolicy">
|
||||
@ -282,7 +314,16 @@
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
@ -369,7 +410,16 @@ border-image: url(:/images/closepressed.png)
|
||||
<property name="spacing">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
@ -410,7 +460,16 @@ border-image: url(:/images/closepressed.png)
|
||||
<property name="spacing">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
@ -425,6 +484,9 @@ border-image: url(:/images/closepressed.png)
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::CustomContextMenu</enum>
|
||||
</property>
|
||||
<property name="dragDropMode">
|
||||
<enum>QAbstractItemView::InternalMove</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -439,6 +501,9 @@ border-image: url(:/images/closepressed.png)
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::CustomContextMenu</enum>
|
||||
</property>
|
||||
<property name="dragDropMode">
|
||||
<enum>QAbstractItemView::InternalMove</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -93,6 +93,10 @@ void p3FeedReaderThread::run()
|
||||
if (isRunning()) {
|
||||
/* second, process the descriptions */
|
||||
for (it = msgs.begin(); it != msgs.end(); ) {
|
||||
if (!isRunning()) {
|
||||
break;
|
||||
}
|
||||
|
||||
RsFeedReaderMsg *mi = *it;
|
||||
result = processMsg(feed, mi, errorString);
|
||||
if (result != RS_FEED_ERRORSTATE_OK) {
|
||||
@ -116,6 +120,7 @@ void p3FeedReaderThread::run()
|
||||
++it;
|
||||
}
|
||||
}
|
||||
if (isRunning()) {
|
||||
if (result == RS_FEED_ERRORSTATE_OK) {
|
||||
/* third, add messages */
|
||||
mFeedReader->onProcessSuccess_addMsgs(feed.feedId, msgs, false);
|
||||
@ -123,6 +128,7 @@ void p3FeedReaderThread::run()
|
||||
mFeedReader->onProcessError(feed.feedId, result, errorString);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mFeedReader->onProcessError(feed.feedId, result, errorString);
|
||||
}
|
||||
@ -1057,6 +1063,7 @@ RsFeedReaderErrorState p3FeedReaderThread::processMsg(const RsFeedReaderFeed &fe
|
||||
return result;
|
||||
}
|
||||
|
||||
if (isRunning()) {
|
||||
/* process description */
|
||||
long todo; // encoding
|
||||
HTMLWrapper html;
|
||||
@ -1157,11 +1164,11 @@ RsFeedReaderErrorState p3FeedReaderThread::processMsg(const RsFeedReaderFeed &fe
|
||||
}
|
||||
nodesToDelete.clear();
|
||||
|
||||
if (!feed.preview) {
|
||||
if (isRunning() && !feed.preview) {
|
||||
result = processXPath(feed.xpathsToUse.ids, feed.xpathsToRemove.ids, html, errorString);
|
||||
}
|
||||
|
||||
if (result == RS_FEED_ERRORSTATE_OK) {
|
||||
if (isRunning() && result == RS_FEED_ERRORSTATE_OK) {
|
||||
unsigned int xpathCount;
|
||||
unsigned int xpathIndex;
|
||||
XPathWrapper *xpath = html.createXPath();
|
||||
@ -1170,6 +1177,9 @@ RsFeedReaderErrorState p3FeedReaderThread::processMsg(const RsFeedReaderFeed &fe
|
||||
if (xpath->compile("//img")) {
|
||||
xpathCount = xpath->count();
|
||||
for (xpathIndex = 0; xpathIndex < xpathCount; ++xpathIndex) {
|
||||
if (!isRunning()) {
|
||||
break;
|
||||
}
|
||||
xmlNodePtr node = xpath->node(xpathIndex);
|
||||
|
||||
if (node->type == XML_ELEMENT_NODE) {
|
||||
@ -1250,6 +1260,7 @@ RsFeedReaderErrorState p3FeedReaderThread::processMsg(const RsFeedReaderFeed &fe
|
||||
#endif
|
||||
result = RS_FEED_ERRORSTATE_PROCESS_HTML_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -1352,6 +1363,8 @@ RsFeedReaderErrorState p3FeedReaderThread::processXPath(const std::list<std::str
|
||||
nodesToDelete.clear();
|
||||
}
|
||||
|
||||
delete(xpath);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -71,12 +71,25 @@ bool XPathWrapper::compile(const char *expression)
|
||||
return true;
|
||||
}
|
||||
|
||||
xmlXPathObjectType XPathWrapper::type()
|
||||
{
|
||||
if (mResult) {
|
||||
return mResult->type;
|
||||
}
|
||||
|
||||
return XPATH_UNDEFINED;
|
||||
}
|
||||
|
||||
unsigned int XPathWrapper::count()
|
||||
{
|
||||
if (!mResult) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (mResult->type != XPATH_NODESET) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (xmlXPathNodeSetIsEmpty(mResult->nodesetval)) {
|
||||
return 0;
|
||||
}
|
||||
@ -90,6 +103,10 @@ xmlNodePtr XPathWrapper::node(unsigned int index)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (mResult->type != XPATH_NODESET) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (xmlXPathNodeSetIsEmpty(mResult->nodesetval)) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -37,6 +37,8 @@ public:
|
||||
|
||||
bool compile(const char *expression);
|
||||
|
||||
xmlXPathObjectType type();
|
||||
|
||||
unsigned int count();
|
||||
xmlNodePtr node(unsigned int index);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user