Skip to content

Commit 39315c1

Browse files
committed
GUI: Intro: Output a std::unique_ptr<Intro> from Intro::showIfNeeded
1 parent 30308cc commit 39315c1

File tree

3 files changed

+15
-17
lines changed

3 files changed

+15
-17
lines changed

src/qt/bitcoin.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -552,10 +552,9 @@ int GuiMain(int argc, char* argv[])
552552

553553
/// 5. Now that settings and translations are available, ask user for data directory
554554
// User language is set up: pick a data directory
555-
bool did_show_intro = false;
556-
int64_t prune_MiB = 0; // Intro dialog prune configuration
555+
std::unique_ptr<Intro> intro;
557556
// Gracefully exit if the user cancels
558-
if (!Intro::showIfNeeded(did_show_intro, prune_MiB)) return EXIT_SUCCESS;
557+
if (!Intro::showIfNeeded(intro)) return EXIT_SUCCESS;
559558

560559
/// 6. Determine availability of data directory and parse bitcoin.conf
561560
/// - Do not call gArgs.GetDataDirNet() before this step finishes
@@ -634,9 +633,10 @@ int GuiMain(int argc, char* argv[])
634633
// Load GUI settings from QSettings
635634
app.createOptionsModel(gArgs.GetBoolArg("-resetguisettings", false));
636635

637-
if (did_show_intro) {
636+
if (intro) {
638637
// Store intro dialog settings other than datadir (network specific)
639-
app.InitPruneSetting(prune_MiB);
638+
app.InitPruneSetting(intro->getPruneMiB());
639+
intro.reset();
640640
}
641641

642642
if (gArgs.GetBoolArg("-splash", DEFAULT_SPLASHSCREEN) && !gArgs.GetBoolArg("-min", false))

src/qt/intro.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,9 @@ int64_t Intro::getPruneMiB() const
202202
}
203203
}
204204

205-
bool Intro::showIfNeeded(bool& did_show_intro, int64_t& prune_MiB)
205+
bool Intro::showIfNeeded(std::unique_ptr<Intro>& intro)
206206
{
207-
did_show_intro = false;
207+
intro.reset();
208208

209209
QSettings settings;
210210
/* If data directory provided on command line, no need to look at settings
@@ -226,19 +226,18 @@ bool Intro::showIfNeeded(bool& did_show_intro, int64_t& prune_MiB)
226226
}
227227

228228
/* If current default data directory does not exist, let the user choose one */
229-
Intro intro(0, Params().AssumedBlockchainSize(), Params().AssumedChainStateSize());
230-
intro.setDataDirectory(dataDir);
231-
intro.setWindowIcon(QIcon(":icons/bitcoin"));
232-
did_show_intro = true;
229+
intro = std::make_unique<Intro>(0, Params().AssumedBlockchainSize(), Params().AssumedChainStateSize());
230+
intro->setDataDirectory(dataDir);
231+
intro->setWindowIcon(QIcon(QStringLiteral(":icons/bitcoin")));
233232

234233
while(true)
235234
{
236-
if(!intro.exec())
235+
if(!intro->exec())
237236
{
238237
/* Cancel clicked */
239238
return false;
240239
}
241-
dataDir = intro.getDataDirectory();
240+
dataDir = intro->getDataDirectory();
242241
try {
243242
if (TryCreateDirectories(GUIUtil::QStringToPath(dataDir))) {
244243
// If a new data directory has been created, make wallets subdirectory too
@@ -252,9 +251,6 @@ bool Intro::showIfNeeded(bool& did_show_intro, int64_t& prune_MiB)
252251
}
253252
}
254253

255-
// Additional preferences:
256-
prune_MiB = intro.getPruneMiB();
257-
258254
settings.setValue("strDataDir", dataDir);
259255
settings.setValue("fReset", false);
260256
}

src/qt/intro.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include <QMutex>
1010
#include <QThread>
1111

12+
#include <memory>
13+
1214
static const bool DEFAULT_CHOOSE_DATADIR = false;
1315

1416
class FreespaceChecker;
@@ -48,7 +50,7 @@ class Intro : public QDialog
4850
* @note do NOT call global gArgs.GetDataDirNet() before calling this function, this
4951
* will cause the wrong path to be cached.
5052
*/
51-
static bool showIfNeeded(bool& did_show_intro, int64_t& prune_MiB);
53+
static bool showIfNeeded(std::unique_ptr<Intro>& intro);
5254

5355
Q_SIGNALS:
5456
void requestCheck();

0 commit comments

Comments
 (0)