Skip to content

Commit 1ad2636

Browse files
committed
qt: Prevent non-functional GUI from popping up during Init
When a InitError or InitWarning happens, the GUI pops up but is unusable (until Init finishes). This is caused by showNormalIfMinimized. Add a message flag to skip this call for Init errors or warnings.
1 parent 93a7861 commit 1ad2636

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

src/init.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,13 @@ void HandleSIGHUP(int)
164164

165165
bool static InitError(const std::string &str)
166166
{
167-
uiInterface.ThreadSafeMessageBox(str, "", CClientUIInterface::MSG_ERROR);
167+
uiInterface.ThreadSafeMessageBox(str, "", CClientUIInterface::MSG_ERROR | CClientUIInterface::NOSHOWGUI);
168168
return false;
169169
}
170170

171171
bool static InitWarning(const std::string &str)
172172
{
173-
uiInterface.ThreadSafeMessageBox(str, "", CClientUIInterface::MSG_WARNING);
173+
uiInterface.ThreadSafeMessageBox(str, "", CClientUIInterface::MSG_WARNING | CClientUIInterface::NOSHOWGUI);
174174
return true;
175175
}
176176

src/qt/bitcoingui.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -681,8 +681,11 @@ void BitcoinGUI::message(const QString &title, const QString &message, unsigned
681681
if (!(buttons = (QMessageBox::StandardButton)(style & CClientUIInterface::BTN_MASK)))
682682
buttons = QMessageBox::Ok;
683683

684-
// Ensure we get users attention
685-
showNormalIfMinimized();
684+
// Ensure we get users attention, but only if main window is visible
685+
// as we don't want to pop up the main window for messages that happen before
686+
// initialization is finished.
687+
if(!(style & CClientUIInterface::NOSHOWGUI))
688+
showNormalIfMinimized();
686689
QMessageBox mBox((QMessageBox::Icon)nMBoxIcon, strTitle, message, buttons, this);
687690
int r = mBox.exec();
688691
if (ret != NULL)

src/ui_interface.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ class CClientUIInterface
6262

6363
/** Force blocking, modal message box dialog (not just OS notification) */
6464
MODAL = 0x10000000U,
65+
/** Don't bring GUI to foreground. Use for messages during initialization */
66+
NOSHOWGUI = 0x20000000U,
6567

6668
/** Predefined combinations for certain default usage cases */
6769
MSG_INFORMATION = ICON_INFORMATION,

0 commit comments

Comments
 (0)