Skip to content

Commit b4e0d2c

Browse files
committed
qt, refactor: Allocate SendConfirmationDialog instances on heap
This change is require for the next commit.
1 parent 332dea2 commit b4e0d2c

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/qt/sendcoinsdialog.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,9 +399,10 @@ void SendCoinsDialog::sendButtonClicked([[maybe_unused]] bool checked)
399399

400400
const QString confirmation = model->wallet().privateKeysDisabled() && !model->wallet().hasExternalSigner() ? tr("Confirm transaction proposal") : tr("Confirm send coins");
401401
const QString confirmButtonText = model->wallet().privateKeysDisabled() && !model->wallet().hasExternalSigner() ? tr("Create Unsigned") : tr("Sign and send");
402-
SendConfirmationDialog confirmationDialog(confirmation, question_string, informative_text, detailed_text, SEND_CONFIRM_DELAY, confirmButtonText, this);
403-
confirmationDialog.exec();
404-
QMessageBox::StandardButton retval = static_cast<QMessageBox::StandardButton>(confirmationDialog.result());
402+
auto confirmationDialog = new SendConfirmationDialog(confirmation, question_string, informative_text, detailed_text, SEND_CONFIRM_DELAY, confirmButtonText, this);
403+
confirmationDialog->setAttribute(Qt::WA_DeleteOnClose);
404+
// TODO: Replace QDialog::exec() with safer QDialog::show().
405+
const auto retval = static_cast<QMessageBox::StandardButton>(confirmationDialog->exec());
405406

406407
if(retval != QMessageBox::Yes)
407408
{

src/qt/walletmodel.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -506,9 +506,10 @@ bool WalletModel::bumpFee(uint256 hash, uint256& new_hash)
506506
questionString.append(tr("Warning: This may pay the additional fee by reducing change outputs or adding inputs, when necessary. It may add a new change output if one does not already exist. These changes may potentially leak privacy."));
507507
}
508508

509-
SendConfirmationDialog confirmationDialog(tr("Confirm fee bump"), questionString);
510-
confirmationDialog.exec();
511-
QMessageBox::StandardButton retval = static_cast<QMessageBox::StandardButton>(confirmationDialog.result());
509+
auto confirmationDialog = new SendConfirmationDialog(tr("Confirm fee bump"), questionString);
510+
confirmationDialog->setAttribute(Qt::WA_DeleteOnClose);
511+
// TODO: Replace QDialog::exec() with safer QDialog::show().
512+
const auto retval = static_cast<QMessageBox::StandardButton>(confirmationDialog->exec());
512513

513514
// cancel sign&broadcast if user doesn't want to bump the fee
514515
if (retval != QMessageBox::Yes) {

0 commit comments

Comments
 (0)