@@ -260,7 +260,7 @@ bool BitcoinApplication::createOptionsModel(bool resetSettings)
260260 error.translated += tr (" Settings file %1 might be corrupt or invalid." ).arg (QString::fromStdString (quoted_path)).toStdString ();
261261 }
262262 InitError (error);
263- QMessageBox::critical ( nullptr , CLIENT_NAME, QString::fromStdString (error.translated ));
263+ GUIUtil::ShowMessageBox ( QString::fromStdString (error.translated ), static_cast <QMessageBox::Icon>(QMessageBox::Critical ));
264264 return false ;
265265 }
266266 return true ;
@@ -440,21 +440,25 @@ void BitcoinApplication::initializeResult(bool success, interfaces::BlockAndHead
440440
441441void BitcoinApplication::handleRunawayException (const QString &message)
442442{
443- QMessageBox::critical (
444- nullptr , tr (" Runaway exception" ),
445- tr (" A fatal error occurred. %1 can no longer continue safely and will quit." ).arg (CLIENT_NAME) +
446- QLatin1String (" <br><br>" ) + GUIUtil::MakeHtmlLink (message, CLIENT_BUGREPORT));
443+ const QString qMessage = tr (" A fatal error occurred. %1 can no longer continue safely and will quit." ).arg (CLIENT_NAME) +
444+ QLatin1String (" <br><br>" ) + GUIUtil::MakeHtmlLink (message, CLIENT_BUGREPORT);
445+ GUIUtil::ShowMessageBox (/* message=*/ qMessage,
446+ /* box_icon=*/ static_cast <QMessageBox::Icon>(QMessageBox::Critical),
447+ /* network_style=*/ nullptr ,
448+ /* title=*/ tr (" Runaway exception" ));
447449 ::exit (EXIT_FAILURE);
448450}
449451
450452void BitcoinApplication::handleNonFatalException (const QString& message)
451453{
452454 assert (QThread::currentThread () == thread ());
453- QMessageBox::warning (
454- nullptr , tr (" Internal error" ),
455- tr (" An internal error occurred. %1 will attempt to continue safely. This is "
456- " an unexpected bug which can be reported as described below." ).arg (CLIENT_NAME) +
457- QLatin1String (" <br><br>" ) + GUIUtil::MakeHtmlLink (message, CLIENT_BUGREPORT));
455+ const QString qMessage = tr (" An internal error occurred. %1 will attempt to continue safely. This is "
456+ " an unexpected bug which can be reported as described below." ).arg (CLIENT_NAME) +
457+ QLatin1String (" <br><br>" ) + GUIUtil::MakeHtmlLink (message, CLIENT_BUGREPORT);
458+ GUIUtil::ShowMessageBox (/* message=*/ qMessage,
459+ /* box_icon=*/ static_cast <QMessageBox::Icon>(QMessageBox::Warning),
460+ /* network_style=*/ nullptr ,
461+ /* title=*/ tr (" Internal error" ));
458462}
459463
460464WId BitcoinApplication::getMainWinId () const
@@ -529,11 +533,11 @@ int GuiMain(int argc, char* argv[])
529533 SetupUIArgs (gArgs );
530534 std::string error;
531535 if (!gArgs .ParseParameters (argc, argv, error)) {
532- InitError (Untranslated (strprintf (" Error parsing command line arguments: %s" , error)));
536+ const std::string message = tfm::format (" Error parsing command line arguments: %s" , error);
537+ // message cannot be translated because translations have not been initialized
538+ InitError (Untranslated (message));
533539 // Create a message box, because the gui has neither been created nor has subscribed to core signals
534- QMessageBox::critical (nullptr , CLIENT_NAME,
535- // message cannot be translated because translations have not been initialized
536- QString::fromStdString (" Error parsing command line arguments: %1." ).arg (QString::fromStdString (error)));
540+ GUIUtil::ShowMessageBox (QString::fromStdString (message), static_cast <QMessageBox::Icon>(QMessageBox::Critical));
537541 return EXIT_FAILURE;
538542 }
539543
@@ -550,17 +554,17 @@ int GuiMain(int argc, char* argv[])
550554 }
551555#endif
552556 if (payment_server_token_seen && arg.startsWith (" -" )) {
553- InitError ( Untranslated ( strprintf ( " Options ('%s') cannot follow a BIP-21 payment URI" , argv[i])) );
554- QMessageBox::critical ( nullptr , CLIENT_NAME,
555- // message cannot be translated because translations have not been initialized
556- QString::fromStdString (" Options ('%1') cannot follow a BIP-21 payment URI " ). arg ( QString::fromStdString (argv[i]) ));
557+ const std::string message = tfm::format ( " Options ('%s') cannot follow a BIP-21 payment URI" , argv[i]);
558+ // message cannot be translated because translations have not been initialized
559+ InitError ( Untranslated ( message));
560+ GUIUtil::ShowMessageBox ( QString::fromStdString (message), static_cast <QMessageBox::Icon>(QMessageBox::Critical ));
557561 return EXIT_FAILURE;
558562 }
559563 if (invalid_token) {
560- InitError ( Untranslated ( strprintf ( " Command line contains unexpected token '%s', see bitcoin-qt -h for a list of options." , argv[i])) );
561- QMessageBox::critical ( nullptr , CLIENT_NAME,
562- // message cannot be translated because translations have not been initialized
563- QString::fromStdString (" Command line contains unexpected token '%1', see bitcoin-qt -h for a list of options. " ). arg ( QString::fromStdString (argv[i]) ));
564+ const std::string message = tfm::format ( " Command line contains unexpected token '%s', see bitcoin-qt -h for a list of options." , argv[i]);
565+ // message cannot be translated because translations have not been initialized
566+ InitError ( Untranslated ( message));
567+ GUIUtil::ShowMessageBox ( QString::fromStdString (message), static_cast <QMessageBox::Icon>(QMessageBox::Critical ));
564568 return EXIT_FAILURE;
565569 }
566570 }
@@ -613,7 +617,9 @@ int GuiMain(int argc, char* argv[])
613617 } else if (error->status != common::ConfigStatus::ABORTED) {
614618 // Show a generic message in other cases, and no additional error
615619 // message in the case of a read error if the user decided to abort.
616- QMessageBox::critical (nullptr , CLIENT_NAME, QObject::tr (" Error: %1" ).arg (QString::fromStdString (error->message .translated )));
620+ GUIUtil::ShowMessageBox (
621+ QObject::tr (" Error: %1" ).arg (QString::fromStdString (error->message .translated )),
622+ static_cast <QMessageBox::Icon>(QMessageBox::Critical));
617623 }
618624 return EXIT_FAILURE;
619625 }
0 commit comments