Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Don't prompt to cancel the news feed task on shutdown
If it hasn't completed, just cancel it immediately without prompting
users -- it's not essential that it completes
  • Loading branch information
nyalldawson committed Apr 12, 2020
1 parent c0f0a49 commit da4a195
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
Expand Up @@ -34,15 +34,15 @@ without danger of the task being first removed by the QgsTaskManager.
%End
public:

QgsNetworkContentFetcherTask( const QUrl &url, const QString &authcfg = QString() );
QgsNetworkContentFetcherTask( const QUrl &url, const QString &authcfg = QString(), QgsTask::Flags flags = QgsTask::CanCancel );
%Docstring
Constructor for a QgsNetworkContentFetcherTask which fetches
the specified ``url``.

Optionally, authentication configuration can be set via the ``authcfg`` argument.
%End

QgsNetworkContentFetcherTask( const QNetworkRequest &request, const QString &authcfg = QString() );
QgsNetworkContentFetcherTask( const QNetworkRequest &request, const QString &authcfg = QString(), QgsTask::Flags flags = QgsTask::CanCancel );
%Docstring
Constructor for a QgsNetworkContentFetcherTask which fetches
the specified network ``request``.
Expand Down
8 changes: 4 additions & 4 deletions src/core/qgsnetworkcontentfetchertask.cpp
Expand Up @@ -19,13 +19,13 @@
#include "qgsnetworkcontentfetchertask.h"
#include "qgsnetworkcontentfetcher.h"

QgsNetworkContentFetcherTask::QgsNetworkContentFetcherTask( const QUrl &url, const QString &authcfg )
: QgsNetworkContentFetcherTask( QNetworkRequest( url ), authcfg )
QgsNetworkContentFetcherTask::QgsNetworkContentFetcherTask( const QUrl &url, const QString &authcfg, Flags flags )
: QgsNetworkContentFetcherTask( QNetworkRequest( url ), authcfg, flags )
{
}

QgsNetworkContentFetcherTask::QgsNetworkContentFetcherTask( const QNetworkRequest &request, const QString &authcfg )
: QgsTask( tr( "Fetching %1" ).arg( request.url().toString() ) )
QgsNetworkContentFetcherTask::QgsNetworkContentFetcherTask( const QNetworkRequest &request, const QString &authcfg, Flags flags )
: QgsTask( tr( "Fetching %1" ).arg( request.url().toString() ), flags )
, mRequest( request )
, mAuthcfg( authcfg )
{
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsnetworkcontentfetchertask.h
Expand Up @@ -56,15 +56,15 @@ class CORE_EXPORT QgsNetworkContentFetcherTask : public QgsTask
*
* Optionally, authentication configuration can be set via the \a authcfg argument.
*/
QgsNetworkContentFetcherTask( const QUrl &url, const QString &authcfg = QString() );
QgsNetworkContentFetcherTask( const QUrl &url, const QString &authcfg = QString(), QgsTask::Flags flags = QgsTask::CanCancel );

/**
* Constructor for a QgsNetworkContentFetcherTask which fetches
* the specified network \a request.
*
* Optionally, authentication configuration can be set via the \a authcfg argument.
*/
QgsNetworkContentFetcherTask( const QNetworkRequest &request, const QString &authcfg = QString() );
QgsNetworkContentFetcherTask( const QNetworkRequest &request, const QString &authcfg = QString(), QgsTask::Flags flags = QgsTask::CanCancel );

~QgsNetworkContentFetcherTask() override;

Expand Down
3 changes: 2 additions & 1 deletion src/core/qgsnewsfeedparser.cpp
Expand Up @@ -140,7 +140,8 @@ void QgsNewsFeedParser::fetch()

mFetchStartTime = QDateTime::currentDateTimeUtc().toSecsSinceEpoch();

QgsNetworkContentFetcherTask *task = new QgsNetworkContentFetcherTask( req, mAuthCfg );
// allow canceling the news fetching without prompts -- it's not crucial if this gets finished or not
QgsNetworkContentFetcherTask *task = new QgsNetworkContentFetcherTask( req, mAuthCfg, QgsTask::CanCancel | QgsTask::CancelWithoutPrompt );
task->setDescription( tr( "Fetching News Feed" ) );
connect( task, &QgsNetworkContentFetcherTask::fetched, this, [this, task]
{
Expand Down

0 comments on commit da4a195

Please sign in to comment.