Skip to content

Commit 68c9bbe

Browse files
committed
qt: Force set nPruneSize in QSettings after intro
If QSettings is set already, it is required to force set nPruneSize after the intro dialog.
1 parent a82bd8f commit 68c9bbe

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

src/qt/bitcoin.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,11 @@ void BitcoinApplication::parameterSetup()
281281
m_node.initParameterInteraction();
282282
}
283283

284-
void BitcoinApplication::SetPrune(bool prune, bool force) {
285-
optionsModel->SetPrune(prune, force);
284+
void BitcoinApplication::SetPrune(bool prune, bool force)
285+
{
286+
// If prune is set, intentionally override existing prune size with
287+
// the default size since this is called when choosing a new datadir.
288+
optionsModel->SetPruneTargetGB(prune ? DEFAULT_PRUNE_TARGET_GB : 0, force);
286289
}
287290

288291
void BitcoinApplication::requestInitialize()

src/qt/optionsmodel.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ void OptionsModel::Init(bool resetSettings)
9292
settings.setValue("bPrune", false);
9393
if (!settings.contains("nPruneSize"))
9494
settings.setValue("nPruneSize", DEFAULT_PRUNE_TARGET_GB);
95-
SetPrune(settings.value("bPrune").toBool());
95+
SetPruneEnabled(settings.value("bPrune").toBool());
9696

9797
if (!settings.contains("nDatabaseCache"))
9898
settings.setValue("nDatabaseCache", (qint64)nDefaultDbCache);
@@ -236,7 +236,7 @@ static const QString GetDefaultProxyAddress()
236236
return QString("%1:%2").arg(DEFAULT_GUI_PROXY_HOST).arg(DEFAULT_GUI_PROXY_PORT);
237237
}
238238

239-
void OptionsModel::SetPrune(bool prune, bool force)
239+
void OptionsModel::SetPruneEnabled(bool prune, bool force)
240240
{
241241
QSettings settings;
242242
settings.setValue("bPrune", prune);
@@ -252,6 +252,16 @@ void OptionsModel::SetPrune(bool prune, bool force)
252252
}
253253
}
254254

255+
void OptionsModel::SetPruneTargetGB(int prune_target_gb, bool force)
256+
{
257+
const bool prune = prune_target_gb > 0;
258+
if (prune) {
259+
QSettings settings;
260+
settings.setValue("nPruneSize", prune_target_gb);
261+
}
262+
SetPruneEnabled(prune, force);
263+
}
264+
255265
// read QSettings values and return them
256266
QVariant OptionsModel::data(const QModelIndex & index, int role) const
257267
{

src/qt/optionsmodel.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ class OptionsModel : public QAbstractListModel
7373
const QString& getOverriddenByCommandLine() { return strOverriddenByCommandLine; }
7474

7575
/* Explicit setters */
76-
void SetPrune(bool prune, bool force = false);
76+
void SetPruneEnabled(bool prune, bool force = false);
77+
void SetPruneTargetGB(int prune_target_gb, bool force = false);
7778

7879
/* Restart flag helper */
7980
void setRestartRequired(bool fRequired);

0 commit comments

Comments
 (0)