forked from qt-creator/qt-creator
Qt4ProjectManager: Fix crash on importing builds
Task-Nr: QTCREATORBUG-2723
This commit is contained in:
@@ -404,77 +404,12 @@ void Qt4ProjectConfigWidget::importLabelClicked()
|
||||
{
|
||||
if (!m_buildConfiguration->qmakeStep() || !m_buildConfiguration->makeStep())
|
||||
return;
|
||||
QString directory = m_buildConfiguration->buildDirectory();
|
||||
if (!directory.isEmpty()) {
|
||||
QString makefile = directory;
|
||||
if (m_buildConfiguration->makefile().isEmpty())
|
||||
makefile.append("/Makefile");
|
||||
else
|
||||
makefile.append(m_buildConfiguration->makefile());
|
||||
|
||||
QString qmakePath = QtVersionManager::findQMakeBinaryFromMakefile(makefile);
|
||||
if (!qmakePath.isEmpty()) {
|
||||
QtVersionManager *vm = QtVersionManager::instance();
|
||||
QtVersion *version = vm->qtVersionForQMakeBinary(qmakePath);
|
||||
if (!version) {
|
||||
version = new QtVersion(qmakePath);
|
||||
vm->addVersion(version);
|
||||
}
|
||||
|
||||
QPair<QtVersion::QmakeBuildConfigs, QString> result =
|
||||
QtVersionManager::scanMakeFile(directory, version->defaultBuildConfig());
|
||||
QtVersion::QmakeBuildConfigs qmakeBuildConfig = result.first;
|
||||
|
||||
QString aa = result.second;
|
||||
QString parsedSpec = Qt4BuildConfiguration::extractSpecFromArguments(&aa, directory, version);
|
||||
QString versionSpec = version->mkspec();
|
||||
QString additionalArguments;
|
||||
if (parsedSpec.isEmpty() || parsedSpec == versionSpec || parsedSpec == "default") {
|
||||
// using the default spec, don't modify additional arguments
|
||||
} else {
|
||||
additionalArguments = "-spec " + Utils::QtcProcess::quoteArg(parsedSpec);
|
||||
}
|
||||
Utils::QtcProcess::addArgs(&additionalArguments, aa);
|
||||
|
||||
Qt4BuildConfiguration::removeQMLInspectorFromArguments(&additionalArguments);
|
||||
|
||||
// So we got all the information now apply it...
|
||||
m_buildConfiguration->setQtVersion(version);
|
||||
|
||||
QMakeStep *qmakeStep = m_buildConfiguration->qmakeStep();
|
||||
qmakeStep->setUserArguments(additionalArguments);
|
||||
MakeStep *makeStep = m_buildConfiguration->makeStep();
|
||||
|
||||
m_buildConfiguration->setQMakeBuildConfiguration(qmakeBuildConfig);
|
||||
// Adjust command line arguments, this is ugly as hell
|
||||
// If we are switching to BuildAll we want "release" in there and no "debug"
|
||||
// or "debug" in there and no "release"
|
||||
// If we are switching to not BuildAl we want neither "release" nor "debug" in there
|
||||
bool debug = qmakeBuildConfig & QtVersion::DebugBuild;
|
||||
bool haveTag = !(qmakeBuildConfig & QtVersion::BuildAll);
|
||||
QString makeCmdArguments = makeStep->userArguments();
|
||||
Utils::QtcProcess::ArgIterator ait(&makeCmdArguments);
|
||||
while (ait.next()) {
|
||||
if (ait.value() == QLatin1String("debug")) {
|
||||
if (!haveTag && debug)
|
||||
haveTag = true;
|
||||
else
|
||||
ait.deleteArg();
|
||||
} else if (ait.value() == QLatin1String("release")) {
|
||||
if (!haveTag && !debug)
|
||||
haveTag = true;
|
||||
else
|
||||
ait.deleteArg();
|
||||
}
|
||||
}
|
||||
if (!haveTag)
|
||||
ait.appendArg(QLatin1String(debug ? "debug" : "release"));
|
||||
makeStep->setUserArguments(makeCmdArguments);
|
||||
}
|
||||
}
|
||||
// All our widgets are updated by signals from the buildconfiguration
|
||||
// if not, there's either a signal missing
|
||||
// or we don't respond to it correctly
|
||||
// We do the importing via a single shot timer due to QTCREATORBUG-2723
|
||||
// Adding a qtversion might trigger a supportedTargetIds changed signal
|
||||
// which results in a recreation of all the widgets on the page
|
||||
// That means also "this" gets deleted
|
||||
QTimer::singleShot(0, m_buildConfiguration, SLOT(importFromBuildDirectory()));
|
||||
}
|
||||
|
||||
void Qt4ProjectConfigWidget::qtVersionSelected(const QString &)
|
||||
|
||||
Reference in New Issue
Block a user