@@ -192,7 +192,6 @@ void SendWidget::loadClientModel()
192192void SendWidget::loadWalletModel ()
193193{
194194 if (walletModel) {
195- coinControlDialog->setModel (walletModel);
196195 if (walletModel->getOptionsModel ()) {
197196 // display unit
198197 nDisplayUnit = walletModel->getOptionsModel ()->getDisplayUnit ();
@@ -254,13 +253,13 @@ void SendWidget::onResetCustomOptions(bool fRefreshAmounts)
254253
255254void SendWidget::resetCoinControl ()
256255{
257- coinControlDialog->coinControl ->SetNull ();
256+ if (coinControlDialog) coinControlDialog->coinControl ->SetNull ();
258257 ui->btnCoinControl ->setActive (false );
259258}
260259
261260void SendWidget::resetChangeAddress ()
262261{
263- coinControlDialog->coinControl ->destChange = CNoDestination ();
262+ if (coinControlDialog) coinControlDialog->coinControl ->destChange = CNoDestination ();
264263 ui->btnChangeAddress ->setActive (false );
265264 ui->btnChangeAddress ->setVisible (isTransparent);
266265}
@@ -343,7 +342,7 @@ void SendWidget::showHideCheckBoxDelegations()
343342{
344343 // Show checkbox only when there is any available owned delegation and
345344 // coincontrol is not selected, and we are trying to spend transparent PIVs.
346- const bool isCControl = coinControlDialog->coinControl ->HasSelected ();
345+ const bool isCControl = coinControlDialog ? coinControlDialog ->coinControl ->HasSelected () : false ;
347346 const bool hasDel = cachedDelegatedBalance > 0 ;
348347
349348 const bool showCheckBox = isTransparent && !isCControl && hasDel;
@@ -471,7 +470,9 @@ OperationResult SendWidget::prepareTransparent(WalletModelTransaction* currentTr
471470 if (!walletModel) return errorOut (" Error, no wallet model loaded" );
472471 // prepare transaction for getting txFee earlier
473472 WalletModel::SendCoinsReturn prepareStatus;
474- prepareStatus = walletModel->prepareTransaction (currentTransaction, coinControlDialog->coinControl , fDelegationsChecked );
473+ prepareStatus = walletModel->prepareTransaction (currentTransaction,
474+ coinControlDialog ? coinControlDialog->coinControl : nullptr ,
475+ fDelegationsChecked );
475476
476477 // process prepareStatus and on error generate message shown to user
477478 CClientUIInterface::MessageBoxFlags informType;
@@ -676,6 +677,8 @@ void SendWidget::onChangeCustomFeeClicked()
676677void SendWidget::onCoinControlClicked ()
677678{
678679 if (walletModel->getBalance () > 0 ) {
680+ // future: move coin control initialization and refresh to a worker thread.
681+ if (!coinControlDialog->hasModel ()) coinControlDialog->setModel (walletModel);
679682 coinControlDialog->setSelectionType (isTransparent);
680683 coinControlDialog->refreshDialog ();
681684 setCoinControlPayAmounts ();
0 commit comments