Created
June 20, 2012 13:32
-
-
Save pvdk/2959901 to your computer and use it in GitHub Desktop.
QApplication exit problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, QWidget *parent) | |
: QWidget(parent) | |
, mCfgMgr(cfg) | |
{ | |
mDataFilesModel = new QStandardItemModel(); // Contains all plugins with masters | |
mPluginsModel = new PluginsModel(); // Contains selectable plugins | |
[...] | |
createActions(); | |
setupConfig(); | |
setupDataFiles(); | |
} | |
void DataFilesPage::setupDataFiles() | |
{ | |
// We use the Configuration Manager to retrieve the configuration values | |
boost::program_options::variables_map variables; | |
boost::program_options::options_description desc; | |
desc.add_options() | |
("data", boost::program_options::value<Files::PathContainer>()->default_value(Files::PathContainer(), "data")->multitoken()) | |
// ("data-local", boost::program_options::value<std::string>()->default_value("")) | |
("fs-strict", boost::program_options::value<bool>()->implicit_value(true)->default_value(false)) | |
("encoding", boost::program_options::value<std::string>()->default_value("win1252")); | |
mCfgMgr.readConfiguration(variables, desc); | |
// Put the paths in a boost::filesystem vector to use with Files::Collections | |
mDataDirs = Files::PathContainer(variables["data"].as<Files::PathContainer>()); | |
// std::string local = variables["data-local"].as<std::string>(); | |
// if (!local.empty()) { | |
// mDataLocal.push_back(Files::PathContainer::value_type(local)); | |
// dataDirs.push_back(Files::PathContainer::value_type(local)); | |
// } | |
if (mDataDirs.size()>1) | |
mDataDirs.resize (1); | |
mCfgMgr.processPaths(mDataDirs); | |
QString selectedDir; | |
while (mDataDirs.empty()) { | |
QMessageBox msgBox; | |
msgBox.setWindowTitle("Error detecting Morrowind installation"); | |
msgBox.setIcon(QMessageBox::Warning); | |
msgBox.setStandardButtons(QMessageBox::Cancel); | |
msgBox.setText(tr("<br><b>Could not find the Data Files location</b><br><br> \ | |
The directory containing the data files was not found.<br><br> \ | |
Press \"Browse...\" to specify the location manually.<br>")); | |
QAbstractButton *dirSelectButton = | |
msgBox.addButton(tr("B&rowse..."), QMessageBox::ActionRole); | |
msgBox.exec(); | |
if (msgBox.clickedButton() == dirSelectButton) { | |
// Show a custom dir selection dialog which only accepts valid dirs | |
selectedDir = FileDialog::getExistingDirectory( | |
this, tr("Select Data Files Directory"), | |
QDir::currentPath(), | |
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); | |
// Add the user selected data directory | |
if (!selectedDir.isEmpty()) { | |
mDataDirs.push_back(Files::PathContainer::value_type(selectedDir.toStdString())); | |
mCfgMgr.processPaths(mDataDirs); | |
} else { | |
// Cancel from within the dir selection dialog | |
qDebug() << "breakage!"; | |
break; | |
} | |
} else { | |
// Cancel | |
break; | |
} | |
} | |
qDebug() << "selecteddir is " << selectedDir; | |
>>> THIS IS WHERE IT WON'T QUIT <<< | |
// Check if cancel was clicked because we can't exit from while loop | |
if (selectedDir.isEmpty()) { | |
qDebug() << "quit please"; | |
QCoreApplication::exit(1); | |
return; | |
} | |
[...] | |
} | |
void DataFilesPage::writeConfig(QString profile) | |
{ | |
// Don't overwrite the config if no masters are found | |
if (mMastersWidget->rowCount() < 1) { | |
return; | |
} | |
QString pathStr = QString::fromStdString(mCfgMgr.getUserPath().string()); | |
QDir userPath(pathStr); | |
>>> THIS IS WHERE IT DOES (function called from MainDialog) <<< | |
if (!userPath.exists()) { | |
if (!userPath.mkpath(pathStr)) { | |
QMessageBox msgBox; | |
msgBox.setWindowTitle("Error creating OpenMW configuration directory"); | |
msgBox.setIcon(QMessageBox::Critical); | |
msgBox.setStandardButtons(QMessageBox::Ok); | |
msgBox.setText(tr("<br><b>Could not create %0</b><br><br> \ | |
Please make sure you have the right permissions and try again.<br>").arg(pathStr)); | |
msgBox.exec(); | |
qApp->exit(1); | |
return; | |
} | |
} | |
[...] | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment