aboutsummaryrefslogtreecommitdiff
path: root/src/qt/intro.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2016-08-18 16:58:04 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2016-08-18 16:58:25 +0200
commitb4a9aa511c95a1bd0da8ae363b3b9c0b3b7afe4e (patch)
tree8aa54ab822f23670a1e8cce4520e0b2baa114d6a /src/qt/intro.cpp
parent8250de13587ed05ca45df3e12c5dc9bcb1500e2c (diff)
downloadbitcoin-b4a9aa511c95a1bd0da8ae363b3b9c0b3b7afe4e.tar.xz
qt: Fix random segfault when closing "Choose data directory" dialog
The `pickDataDirectory()` function was calling `exit(0)` to quit the application when the user closes the dialog without choosing a data directory. This is a bad idea because a background thread is created (to check free space on the drive of the currently selected datadir). The thread is not stopped and unwound properly, resulting in a potential race condition somewhere deep in Qt. So replace the `exit()` by a boolean return value, and let the stack unwind normally.
Diffstat (limited to 'src/qt/intro.cpp')
-rw-r--r--src/qt/intro.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/qt/intro.cpp b/src/qt/intro.cpp
index 6d6af54290..6a5740e21d 100644
--- a/src/qt/intro.cpp
+++ b/src/qt/intro.cpp
@@ -165,14 +165,14 @@ QString Intro::getDefaultDataDirectory()
return GUIUtil::boostPathToQString(GetDefaultDataDir());
}
-void Intro::pickDataDirectory()
+bool Intro::pickDataDirectory()
{
namespace fs = boost::filesystem;
QSettings settings;
/* If data directory provided on command line, no need to look at settings
or show a picking dialog */
if(!GetArg("-datadir", "").empty())
- return;
+ return true;
/* 1) Default data directory for operating system */
QString dataDir = getDefaultDataDirectory();
/* 2) Allow QSettings to override default dir */
@@ -190,7 +190,7 @@ void Intro::pickDataDirectory()
if(!intro.exec())
{
/* Cancel clicked */
- exit(0);
+ return false;
}
dataDir = intro.getDataDirectory();
try {
@@ -211,6 +211,7 @@ void Intro::pickDataDirectory()
*/
if(dataDir != getDefaultDataDirectory())
SoftSetArg("-datadir", GUIUtil::qstringToBoostPath(dataDir).string()); // use OS locale for path setting
+ return true;
}
void Intro::setStatus(int status, const QString &message, quint64 bytesAvailable)