@@ -78,6 +78,12 @@ static void initTranslations(QTranslator &qtTranslatorBase, QTranslator &qtTrans
78
78
{
79
79
QSettings settings;
80
80
81
+ // Remove old translators
82
+ QApplication::removeTranslator (&qtTranslatorBase);
83
+ QApplication::removeTranslator (&qtTranslator);
84
+ QApplication::removeTranslator (&translatorBase);
85
+ QApplication::removeTranslator (&translator);
86
+
81
87
// Get desired locale (e.g. "de_DE")
82
88
// 1) System default language
83
89
QString lang_territory = QLocale::system ().name ();
@@ -439,21 +445,9 @@ void BitcoinApplication::handleRunawayException(const QString &message)
439
445
#ifndef BITCOIN_QT_TEST
440
446
int main (int argc, char *argv[])
441
447
{
442
- bool fSelParFromCLFailed = false ;
443
448
// / 1. Parse command-line options. These take precedence over anything else.
444
449
// Command-line options take precedence:
445
450
ParseParameters (argc, argv);
446
- // Check for -testnet or -regtest parameter (TestNet() calls are only valid after this clause)
447
- if (!SelectParamsFromCommandLine ()) {
448
- fSelParFromCLFailed = true ;
449
- }
450
- #ifdef ENABLE_WALLET
451
- // Parse URIs on command line -- this can affect Params()
452
- if (!PaymentServer::ipcParseCommandLine (argc, argv))
453
- exit (0 );
454
- #endif
455
-
456
- bool isaTestNet = Params ().NetworkID () != CChainParams::MAIN;
457
451
458
452
// Do not refer to data directory yet, this can be overridden by Intro::pickDataDirectory
459
453
@@ -480,12 +474,9 @@ int main(int argc, char *argv[])
480
474
// / 3. Application identification
481
475
// must be set before OptionsModel is initialized or translations are loaded,
482
476
// as it is used to locate QSettings
483
- QApplication::setOrganizationName (" Bitcoin" );
484
- QApplication::setOrganizationDomain (" bitcoin.org" );
485
- if (isaTestNet) // Separate UI settings for testnets
486
- QApplication::setApplicationName (" Bitcoin-Qt-testnet" );
487
- else
488
- QApplication::setApplicationName (" Bitcoin-Qt" );
477
+ QApplication::setOrganizationName (QAPP_ORG_NAME);
478
+ QApplication::setOrganizationDomain (QAPP_ORG_DOMAIN);
479
+ QApplication::setApplicationName (QAPP_APP_NAME_DEFAULT);
489
480
490
481
// / 4. Initialization of translations, so that intro dialog is in user's language
491
482
// Now that QSettings are accessible, initialize translations
@@ -501,17 +492,13 @@ int main(int argc, char *argv[])
501
492
help.showOrPrint ();
502
493
return 1 ;
503
494
}
504
- // Now that translations are initialized, check for earlier errors and show a translatable error message
505
- if (fSelParFromCLFailed ) {
506
- QMessageBox::critical (0 , QObject::tr (" Bitcoin" ), QObject::tr (" Error: Invalid combination of -regtest and -testnet." ));
507
- return 1 ;
508
- }
509
495
510
496
// / 5. Now that settings and translations are available, ask user for data directory
511
497
// User language is set up: pick a data directory
512
- Intro::pickDataDirectory (isaTestNet );
498
+ Intro::pickDataDirectory ();
513
499
514
500
// / 6. Determine availability of data directory and parse bitcoin.conf
501
+ // / - Do not call GetDataDir(true) before this step finishes
515
502
if (!boost::filesystem::is_directory (GetDataDir (false )))
516
503
{
517
504
QMessageBox::critical (0 , QObject::tr (" Bitcoin" ),
@@ -520,8 +507,33 @@ int main(int argc, char *argv[])
520
507
}
521
508
ReadConfigFile (mapArgs, mapMultiArgs);
522
509
510
+ // / 7. Determine network (and switch to network specific options)
511
+ // - Do not call Params() before this step
512
+ // - Do this after parsing the configuration file, as the network can be switched there
513
+ // - QSettings() will use the new application name after this, resulting in network-specific settings
514
+ // - Needs to be done before createOptionsModel
515
+
516
+ // Check for -testnet or -regtest parameter (Params() calls are only valid after this clause)
517
+ if (!SelectParamsFromCommandLine ()) {
518
+ QMessageBox::critical (0 , QObject::tr (" Bitcoin" ), QObject::tr (" Error: Invalid combination of -regtest and -testnet." ));
519
+ return 1 ;
520
+ }
521
+ #ifdef ENABLE_WALLET
522
+ // Parse URIs on command line -- this can affect Params()
523
+ if (!PaymentServer::ipcParseCommandLine (argc, argv))
524
+ exit (0 );
525
+ #endif
526
+ bool isaTestNet = Params ().NetworkID () != CChainParams::MAIN;
527
+ // Allow for separate UI settings for testnets
528
+ if (isaTestNet)
529
+ QApplication::setApplicationName (QAPP_APP_NAME_TESTNET);
530
+ else
531
+ QApplication::setApplicationName (QAPP_APP_NAME_DEFAULT);
532
+ // Re-initialize translations after changing application name (language in network-specific settings can be different)
533
+ initTranslations (qtTranslatorBase, qtTranslator, translatorBase, translator);
534
+
523
535
#ifdef ENABLE_WALLET
524
- // / 7 . URI IPC sending
536
+ // / 8 . URI IPC sending
525
537
// - Do this early as we don't want to bother initializing if we are just calling IPC
526
538
// - Do this *after* setting up the data directory, as the data directory hash is used in the name
527
539
// of the server.
@@ -535,7 +547,7 @@ int main(int argc, char *argv[])
535
547
app.createPaymentServer ();
536
548
#endif
537
549
538
- // / 8 . Main GUI initialization
550
+ // / 9 . Main GUI initialization
539
551
// Install global event filter that makes sure that long tooltips can be word-wrapped
540
552
app.installEventFilter (new GUIUtil::ToolTipToRichTextFilter (TOOLTIP_WRAP_THRESHOLD, &app));
541
553
// Install qDebug() message handler to route to debug.log
0 commit comments