Skip to content
Permalink
Browse files

Fix ownership of algorithm instance used by processing dialog

(cherry picked from commit a350b42)
  • Loading branch information
nyalldawson committed Nov 17, 2018
1 parent 049c65c commit d1cec84825acae0514b48a950bcbceb01a2ceff3
@@ -38,11 +38,14 @@ Base class for processing algorithm dialogs.
%Docstring
Constructor for QgsProcessingAlgorithmDialogBase.
%End
~QgsProcessingAlgorithmDialogBase();

void setAlgorithm( QgsProcessingAlgorithm *algorithm );
void setAlgorithm( QgsProcessingAlgorithm *algorithm /Transfer/ );
%Docstring
Sets the ``algorithm`` to run in the dialog.

Ownership of the algorithm instance is transferred to the dialog.

.. seealso:: :py:func:`algorithm`
%End

@@ -119,9 +119,11 @@ QgsProcessingAlgorithmDialogBase::QgsProcessingAlgorithmDialogBase( QWidget *par
connect( QgsApplication::taskManager(), &QgsTaskManager::taskTriggered, this, &QgsProcessingAlgorithmDialogBase::taskTriggered );
}

QgsProcessingAlgorithmDialogBase::~QgsProcessingAlgorithmDialogBase() = default;

void QgsProcessingAlgorithmDialogBase::setAlgorithm( QgsProcessingAlgorithm *algorithm )
{
mAlgorithm = algorithm;
mAlgorithm.reset( algorithm );
QString title;
if ( ( QgsGui::higFlags() & QgsGui::HigDialogTitleIsTitleCase ) && !( algorithm->flags() & QgsProcessingAlgorithm::FlagDisplayNameIsLiteral ) )
{
@@ -156,7 +158,7 @@ void QgsProcessingAlgorithmDialogBase::setAlgorithm( QgsProcessingAlgorithm *alg

QgsProcessingAlgorithm *QgsProcessingAlgorithmDialogBase::algorithm()
{
return mAlgorithm;
return mAlgorithm.get();
}

void QgsProcessingAlgorithmDialogBase::setMainWidget( QWidget *widget )
@@ -99,12 +99,16 @@ class GUI_EXPORT QgsProcessingAlgorithmDialogBase : public QDialog, private Ui::
* Constructor for QgsProcessingAlgorithmDialogBase.
*/
QgsProcessingAlgorithmDialogBase( QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags flags = nullptr );
~QgsProcessingAlgorithmDialogBase() override;

/**
* Sets the \a algorithm to run in the dialog.
*
* Ownership of the algorithm instance is transferred to the dialog.
*
* \see algorithm()
*/
void setAlgorithm( QgsProcessingAlgorithm *algorithm );
void setAlgorithm( QgsProcessingAlgorithm *algorithm SIP_TRANSFER );

/**
* Returns the algorithm running in the dialog.
@@ -333,7 +337,7 @@ class GUI_EXPORT QgsProcessingAlgorithmDialogBase : public QDialog, private Ui::
bool mExecuted = false;
QVariantMap mResults;
QWidget *mMainWidget = nullptr;
QgsProcessingAlgorithm *mAlgorithm = nullptr;
std::unique_ptr< QgsProcessingAlgorithm > mAlgorithm;
QgsProcessingAlgRunnerTask *mAlgorithmTask = nullptr;

bool mHelpCollapsed = false;

0 comments on commit d1cec84

Please sign in to comment.
You can’t perform that action at this time.