31
31
#include < QTreeWidget>
32
32
33
33
QList<CAmount> CoinControlDialog::payAmounts;
34
- CCoinControl* CoinControlDialog::coinControl = new CCoinControl();
35
34
bool CoinControlDialog::fSubtractFeeFromAmount = false ;
36
35
37
36
bool CCoinControlWidgetItem::operator <(const QTreeWidgetItem &other) const {
@@ -193,7 +192,7 @@ void CoinControlDialog::buttonSelectAllClicked()
193
192
ui->treeWidget ->topLevelItem (i)->setCheckState (COLUMN_CHECKBOX, state);
194
193
ui->treeWidget ->setEnabled (true );
195
194
if (state == Qt::Unchecked)
196
- coinControl->UnSelectAll (); // just to be sure
195
+ coinControl () ->UnSelectAll (); // just to be sure
197
196
CoinControlDialog::updateLabels (model, this );
198
197
}
199
198
@@ -379,11 +378,11 @@ void CoinControlDialog::viewItemChanged(QTreeWidgetItem* item, int column)
379
378
COutPoint outpt (uint256S (item->text (COLUMN_TXHASH).toStdString ()), item->text (COLUMN_VOUT_INDEX).toUInt ());
380
379
381
380
if (item->checkState (COLUMN_CHECKBOX) == Qt::Unchecked)
382
- coinControl->UnSelect (outpt);
381
+ coinControl () ->UnSelect (outpt);
383
382
else if (item->isDisabled ()) // locked (this happens if "check all" through parent node)
384
383
item->setCheckState (COLUMN_CHECKBOX, Qt::Unchecked);
385
384
else
386
- coinControl->Select (outpt);
385
+ coinControl () ->Select (outpt);
387
386
388
387
// selection changed -> update labels
389
388
if (ui->treeWidget ->isEnabled ()) // do not update on every click for (un)select all
@@ -446,7 +445,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
446
445
447
446
std::vector<COutPoint> vCoinControl;
448
447
std::vector<COutput> vOutputs;
449
- coinControl->ListSelected (vCoinControl);
448
+ coinControl () ->ListSelected (vCoinControl);
450
449
model->getOutputs (vCoinControl, vOutputs);
451
450
452
451
for (const COutput& out : vOutputs) {
@@ -456,7 +455,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
456
455
COutPoint outpt (txhash, out.i );
457
456
if (model->isSpent (outpt))
458
457
{
459
- coinControl->UnSelect (outpt);
458
+ coinControl () ->UnSelect (outpt);
460
459
continue ;
461
460
}
462
461
@@ -509,7 +508,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
509
508
nBytes -= 34 ;
510
509
511
510
// Fee
512
- nPayFee = GetMinimumFee (nBytes, *coinControl, ::mempool, ::feeEstimator, nullptr /* FeeCalculation */ );
511
+ nPayFee = GetMinimumFee (nBytes, *coinControl () , ::mempool, ::feeEstimator, nullptr /* FeeCalculation */ );
513
512
514
513
if (nPayAmount > 0 )
515
514
{
@@ -600,6 +599,12 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
600
599
label->setVisible (nChange < 0 );
601
600
}
602
601
602
+ CCoinControl* CoinControlDialog::coinControl ()
603
+ {
604
+ static CCoinControl coin_control;
605
+ return &coin_control;
606
+ }
607
+
603
608
void CoinControlDialog::updateView ()
604
609
{
605
610
if (!model || !model->getOptionsModel () || !model->getAddressTableModel ())
@@ -703,13 +708,13 @@ void CoinControlDialog::updateView()
703
708
if (model->isLockedCoin (txhash, out.i ))
704
709
{
705
710
COutPoint outpt (txhash, out.i );
706
- coinControl->UnSelect (outpt); // just to be sure
711
+ coinControl () ->UnSelect (outpt); // just to be sure
707
712
itemOutput->setDisabled (true );
708
713
itemOutput->setIcon (COLUMN_CHECKBOX, platformStyle->SingleColorIcon (" :/icons/lock_closed" ));
709
714
}
710
715
711
716
// set checkbox
712
- if (coinControl->IsSelected (COutPoint (txhash, out.i )))
717
+ if (coinControl () ->IsSelected (COutPoint (txhash, out.i )))
713
718
itemOutput->setCheckState (COLUMN_CHECKBOX, Qt::Checked);
714
719
}
715
720
0 commit comments