diff --git a/projectmanagers/cmake/settings/cmakepreferences.cpp b/projectmanagers/cmake/settings/cmakepreferences.cpp --- a/projectmanagers/cmake/settings/cmakepreferences.cpp +++ b/projectmanagers/cmake/settings/cmakepreferences.cpp @@ -260,13 +260,7 @@ if(bdCreator.exec()) { - QString newbuilddir = bdCreator.buildFolder().toLocalFile(); - m_prefsUi->buildDirs->addItem(newbuilddir); - - int buildDirCount = m_prefsUi->buildDirs->count(); - int addedBuildDirIndex = buildDirCount - 1; - m_prefsUi->buildDirs->setCurrentIndex(addedBuildDirIndex); - m_prefsUi->removeBuildDir->setEnabled(true); + int addedBuildDirIndex = m_prefsUi->buildDirs->count(); // Initialize the kconfig items with the values from the dialog, this ensures the settings // end up in the config file once the changes are saved @@ -277,14 +271,20 @@ qCDebug(CMAKE) << "adding to cmake config: build type " << bdCreator.buildType(); qCDebug(CMAKE) << "adding to cmake config: cmake binary " << bdCreator.cmakeBinary(); qCDebug(CMAKE) << "adding to cmake config: environment empty"; - CMake::setBuildDirCount( m_project, buildDirCount ); + CMake::setOverrideBuildDirIndex( m_project, addedBuildDirIndex ); + CMake::setBuildDirCount( m_project, addedBuildDirIndex + 1 ); CMake::setCurrentBuildDir( m_project, bdCreator.buildFolder() ); CMake::setCurrentInstallDir( m_project, bdCreator.installPrefix() ); CMake::setCurrentExtraArguments( m_project, bdCreator.extraArguments() ); CMake::setCurrentBuildType( m_project, bdCreator.buildType() ); CMake::setCurrentCMakeBinary( m_project, bdCreator.cmakeBinary() ); CMake::setCurrentEnvironment( m_project, QString() ); + QString newbuilddir = bdCreator.buildFolder().toLocalFile(); + m_prefsUi->buildDirs->addItem( newbuilddir ); + m_prefsUi->buildDirs->setCurrentIndex( addedBuildDirIndex ); + m_prefsUi->removeBuildDir->setEnabled( true ); + qCDebug(CMAKE) << "Emitting changed signal for cmake kcm"; emit changed(); }