Skip to content

Commit

Permalink
Merge pull request bitcoin#337 from kyuupichan/qt-segfault
Browse files Browse the repository at this point in the history
[Backport] Fix Qt Segfault
  • Loading branch information
gandrewstone authored Mar 7, 2017
2 parents 51c4a8b + ff73759 commit acc32ff
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/qt/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,8 @@ int main(int argc, char *argv[])

/// 5. Now that settings and translations are available, ask user for data directory
// User language is set up: pick a data directory
Intro::pickDataDirectory();
if (!Intro::pickDataDirectory())
return 0;

/// 6. Determine availability of data directory and parse bitcoin.conf
/// - Do not call GetDataDir(true) before this step finishes
Expand Down
7 changes: 4 additions & 3 deletions src/qt/intro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,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 */
Expand All @@ -185,7 +185,7 @@ void Intro::pickDataDirectory()
if(!intro.exec())
{
/* Cancel clicked */
exit(0);
return false;
}
dataDir = intro.getDataDirectory();
try {
Expand All @@ -206,6 +206,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)
Expand Down
5 changes: 4 additions & 1 deletion src/qt/intro.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@ class Intro : public QDialog
/**
* Determine data directory. Let the user choose if the current one doesn't exist.
*
* @returns true if a data directory was selected, false if the user cancelled the selection
* dialog.
*
* @note do NOT call global GetDataDir() before calling this function, this
* will cause the wrong path to be cached.
*/
static void pickDataDirectory();
static bool pickDataDirectory();

/**
* Determine default data directory for operating system.
Expand Down

0 comments on commit acc32ff

Please sign in to comment.