From 4fcd1bcf175069aa515a1d778b2712b92b0d8ecb Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Mon, 19 Dec 2022 12:22:11 -0500 Subject: [PATCH] 2022-12-19 Fred Gleason * Fixed a bug in rdcastmanager(1) that could cause items from non-selected feeds to appear in the 'Podcast Item List' dialog. * Fixed a regression in rdcastmanager(1) that could cause a segfault when posting a new item. Signed-off-by: Fred Gleason --- ChangeLog | 5 +++++ lib/rdfeed.cpp | 17 +++++++---------- lib/rdfeed.h | 1 - lib/rdpodcastlistmodel.cpp | 10 ++++++---- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index b9229082..d92df9c6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23825,3 +23825,8 @@ * Incremented the package version to 4.0.0rc0int9 2022-12-16 Fred Gleason * Removed stale debugging printf() from 'RDLogListModel'. +2022-12-19 Fred Gleason + * Fixed a bug in rdcastmanager(1) that could cause items from + non-selected feeds to appear in the 'Podcast Item List' dialog. + * Fixed a regression in rdcastmanager(1) that could cause a segfault + when posting a new item. diff --git a/lib/rdfeed.cpp b/lib/rdfeed.cpp index 074fa840..f5cc2715 100644 --- a/lib/rdfeed.cpp +++ b/lib/rdfeed.cpp @@ -60,7 +60,7 @@ int __RDFeed_Debug_Callback(CURL *handle,curl_infotype type,char *data, size_t __RDFeed_Write_Callback(char *ptr,size_t size,size_t nmemb, void *userdata) { - static QByteArray *buffer=(QByteArray *)userdata; + QByteArray *buffer=(QByteArray *)userdata; buffer->append(QByteArray(ptr,size*nmemb)); @@ -867,9 +867,9 @@ bool RDFeed::postPodcast(unsigned cast_id,QString *err_msg) return false; } QStringList *err_msgs=SetupCurlLogging(curl); + QByteArray write_buffer; curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,__RDFeed_Write_Callback); - feed_curl_write_buffer.clear(); - curl_easy_setopt(curl,CURLOPT_WRITEDATA,&feed_curl_write_buffer); + curl_easy_setopt(curl,CURLOPT_WRITEDATA,&write_buffer); curl_easy_setopt(curl,CURLOPT_HTTPPOST,first); curl_easy_setopt(curl,CURLOPT_USERAGENT, rda->config()->userAgent().toUtf8().constData()); @@ -906,7 +906,7 @@ bool RDFeed::postPodcast(unsigned cast_id,QString *err_msg) if((response_code<200)||(response_code>299)) { ProcessCurlLogging("RDFeed::postPodcast()",err_msgs); RDWebResult *wr=new RDWebResult(); - if(wr->readXml(QString::fromUtf8(feed_curl_write_buffer))) { + if(wr->readXml(QString::fromUtf8(write_buffer))) { *err_msg=wr->text(); } else { @@ -1353,7 +1353,6 @@ unsigned RDFeed::postCut(const QString &cutname,QString *err_msg) } delete settings; delete conv; - postProgressChanged(2); // // Save to Audio Store @@ -1379,7 +1378,6 @@ unsigned RDFeed::postCut(const QString &cutname,QString *err_msg) emit postProgressChanged(5); return 0; } - postProgressChanged(3); // // Set default cast parameters @@ -1492,7 +1490,6 @@ unsigned RDFeed::postFile(const QString &srcfile,QString *err_msg) emit postProgressChanged(6); return 0; } - postProgressChanged(4); // // Set default cast parameters @@ -1921,9 +1918,9 @@ bool RDFeed::SavePodcast(unsigned cast_id,const QString &src_filename, return false; } QStringList *err_msgs=SetupCurlLogging(curl); - feed_curl_write_buffer.clear(); + QByteArray write_buffer; curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,__RDFeed_Write_Callback); - curl_easy_setopt(curl,CURLOPT_WRITEDATA,&feed_curl_write_buffer); + curl_easy_setopt(curl,CURLOPT_WRITEDATA,&write_buffer); curl_easy_setopt(curl,CURLOPT_HTTPPOST,first); curl_easy_setopt(curl,CURLOPT_USERAGENT, rda->config()->userAgent().toUtf8().constData()); @@ -1957,7 +1954,7 @@ bool RDFeed::SavePodcast(unsigned cast_id,const QString &src_filename, // if((response_code<200)||(response_code>299)) { ProcessCurlLogging("RDFeed::postPodcast()",err_msgs); - *err_msg=QString::fromUtf8(feed_curl_write_buffer); + *err_msg=QString::fromUtf8(write_buffer); return false; } delete err_msgs; diff --git a/lib/rdfeed.h b/lib/rdfeed.h index 7213dc9a..88c8edc0 100644 --- a/lib/rdfeed.h +++ b/lib/rdfeed.h @@ -187,7 +187,6 @@ class RDFeed : public QObject int feed_xml_ptr; int feed_render_start_line; int feed_render_end_line; - QByteArray feed_curl_write_buffer; }; diff --git a/lib/rdpodcastlistmodel.cpp b/lib/rdpodcastlistmodel.cpp index 0b26e72b..66b32fdf 100644 --- a/lib/rdpodcastlistmodel.cpp +++ b/lib/rdpodcastlistmodel.cpp @@ -292,11 +292,14 @@ void RDPodcastListModel::processNotification(RDNotification *notify) RDPodcast *cast=NULL; if(notify->type()==RDNotification::FeedItemType) { - cast_id=notify->id().toUInt(); - cast=new RDPodcast(rda->config(),cast_id); switch(notify->action()) { case RDNotification::AddAction: - addCast(cast_id); + cast_id=notify->id().toUInt(); + cast=new RDPodcast(rda->config(),cast_id); + if(cast->feedId()==d_feed_id) { + addCast(cast_id); + } + delete cast; break; case RDNotification::DeleteAction: @@ -311,7 +314,6 @@ void RDPodcastListModel::processNotification(RDNotification *notify) case RDNotification::NoAction: break; } - delete cast; } }