@@ -193,31 +193,20 @@ WalletControllerActivity::WalletControllerActivity(WalletController* wallet_cont
193
193
{
194
194
}
195
195
196
- WalletControllerActivity::~WalletControllerActivity ()
197
- {
198
- delete m_progress_dialog;
199
- }
200
-
201
196
void WalletControllerActivity::showProgressDialog (const QString& label_text)
202
197
{
203
- assert (!m_progress_dialog);
204
- m_progress_dialog = new QProgressDialog (m_parent_widget);
205
-
206
- m_progress_dialog->setLabelText (label_text);
207
- m_progress_dialog->setRange (0 , 0 );
208
- m_progress_dialog->setCancelButton (nullptr );
209
- m_progress_dialog->setWindowModality (Qt::ApplicationModal);
210
- GUIUtil::PolishProgressDialog (m_progress_dialog);
198
+ auto progress_dialog = new QProgressDialog (m_parent_widget);
199
+ progress_dialog->setAttribute (Qt::WA_DeleteOnClose);
200
+ connect (this , &WalletControllerActivity::finished, progress_dialog, &QWidget::close);
201
+
202
+ progress_dialog->setLabelText (label_text);
203
+ progress_dialog->setRange (0 , 0 );
204
+ progress_dialog->setCancelButton (nullptr );
205
+ progress_dialog->setWindowModality (Qt::ApplicationModal);
206
+ GUIUtil::PolishProgressDialog (progress_dialog);
211
207
// The setValue call forces QProgressDialog to start the internal duration estimation.
212
208
// See details in https://bugreports.qt.io/browse/QTBUG-47042.
213
- m_progress_dialog->setValue (0 );
214
- }
215
-
216
- void WalletControllerActivity::destroyProgressDialog ()
217
- {
218
- assert (m_progress_dialog);
219
- delete m_progress_dialog;
220
- m_progress_dialog = nullptr ;
209
+ progress_dialog->setValue (0 );
221
210
}
222
211
223
212
CreateWalletActivity::CreateWalletActivity (WalletController* wallet_controller, QWidget* parent_widget)
@@ -279,8 +268,6 @@ void CreateWalletActivity::createWallet()
279
268
280
269
void CreateWalletActivity::finish ()
281
270
{
282
- destroyProgressDialog ();
283
-
284
271
if (!m_error_message.empty ()) {
285
272
QMessageBox::critical (m_parent_widget, tr (" Create wallet failed" ), QString::fromStdString (m_error_message.translated ));
286
273
} else if (!m_warning_message.empty ()) {
@@ -329,8 +316,6 @@ OpenWalletActivity::OpenWalletActivity(WalletController* wallet_controller, QWid
329
316
330
317
void OpenWalletActivity::finish ()
331
318
{
332
- destroyProgressDialog ();
333
-
334
319
if (!m_error_message.empty ()) {
335
320
QMessageBox::critical (m_parent_widget, tr (" Open wallet failed" ), QString::fromStdString (m_error_message.translated ));
336
321
} else if (!m_warning_message.empty ()) {
0 commit comments