Fix segfault when shutdown during wallet open

If you open a wallet and send a shutdown signal during
that process, the GUI will segfault due to some queued
wallet events happening after the wallet controller
is deleted. This is a minimal fix for those issues.
This commit is contained in:
John Moffett
2022-12-30 16:09:56 -05:00
parent 65de8eeeca
commit 9a1d73fdff
3 changed files with 17 additions and 6 deletions

View File

@@ -600,10 +600,15 @@ SendCoinsEntry *SendCoinsDialog::addEntry()
entry->clear();
entry->setFocus();
ui->scrollAreaWidgetContents->resize(ui->scrollAreaWidgetContents->sizeHint());
qApp->processEvents();
QScrollBar* bar = ui->scrollArea->verticalScrollBar();
if(bar)
bar->setSliderPosition(bar->maximum());
// Scroll to the newly added entry on a QueuedConnection because Qt doesn't
// adjust the scroll area and scrollbar immediately when the widget is added.
// Invoking on a DirectConnection will only scroll to the second-to-last entry.
QMetaObject::invokeMethod(ui->scrollArea, [this] {
if (ui->scrollArea->verticalScrollBar()) {
ui->scrollArea->verticalScrollBar()->setValue(ui->scrollArea->verticalScrollBar()->maximum());
}
}, Qt::QueuedConnection);
updateTabsAndLabels();
return entry;