| 3241 | } |
| 3242 | |
| 3243 | void Application::LoadParameters() |
| 3244 | { |
| 3245 | // Init parameter sets =========================================================== |
| 3246 | // |
| 3247 | if (mConfig.find("UserParameter") == mConfig.end()) |
| 3248 | mConfig["UserParameter"] = mConfig["UserConfigPath"] + "user.cfg"; |
| 3249 | if (mConfig.find("SystemParameter") == mConfig.end()) |
| 3250 | mConfig["SystemParameter"] = mConfig["UserConfigPath"] + "system.cfg"; |
| 3251 | |
| 3252 | // create standard parameter sets |
| 3253 | _pcSysParamMngr = ParameterManager::Create(); |
| 3254 | _pcSysParamMngr->SetSerializer(new ParameterSerializer(mConfig["SystemParameter"])); |
| 3255 | |
| 3256 | _pcUserParamMngr = ParameterManager::Create(); |
| 3257 | _pcUserParamMngr->SetSerializer(new ParameterSerializer(mConfig["UserParameter"])); |
| 3258 | |
| 3259 | try { |
| 3260 | if (_pcSysParamMngr->LoadOrCreateDocument() && mConfig["Verbose"] != "Strict") { |
| 3261 | // Configuration file optional when using as Python module |
| 3262 | if (!Py_IsInitialized()) { |
| 3263 | Base::Console().warning(" Parameter does not exist, writing initial one\n"); |
| 3264 | Base::Console().message(" This warning normally means that FreeCAD is running for the first time\n" |
| 3265 | " or the configuration was deleted or moved. FreeCAD is generating the standard\n" |
| 3266 | " configuration.\n"); |
| 3267 | } |
| 3268 | } |
| 3269 | } |
| 3270 | catch (const Base::Exception& e) { |
| 3271 | // try to proceed with an empty XML document |
| 3272 | Base::Console().error("%s in file %s.\n" |
| 3273 | "Continue with an empty configuration.\n", |
| 3274 | e.what(), mConfig["SystemParameter"].c_str()); |
| 3275 | _pcSysParamMngr->CreateDocument(); |
| 3276 | } |
| 3277 | |
| 3278 | try { |
| 3279 | if (_pcUserParamMngr->LoadOrCreateDocument() && mConfig["Verbose"] != "Strict") { |
| 3280 | // The user parameter file doesn't exist. When an alternative parameter file is offered |
| 3281 | // this will be used. |
| 3282 | const auto it = mConfig.find("UserParameterTemplate"); |
| 3283 | if (it != mConfig.end()) { |
| 3284 | QString path = QString::fromUtf8(it->second.c_str()); |
| 3285 | if (QDir(path).isRelative()) { |
| 3286 | const QString home = QString::fromUtf8(mConfig["AppHomePath"].c_str()); |
| 3287 | path = QFileInfo(QDir(home), path).absoluteFilePath(); |
| 3288 | } |
| 3289 | const QFileInfo fi(path); |
| 3290 | if (fi.exists()) { |
| 3291 | _pcUserParamMngr->LoadDocument(path.toUtf8().constData()); |
| 3292 | } |
| 3293 | } |
| 3294 | |
| 3295 | // Configuration file optional when using as Python module |
| 3296 | if (!Py_IsInitialized()) { |
| 3297 | Base::Console().warning(" User settings do not exist, writing initial one\n"); |
| 3298 | Base::Console().message(" This warning normally means that FreeCAD is running for the first time\n" |
| 3299 | " or your configuration was deleted or moved. The system defaults\n" |
| 3300 | " will be automatically generated for you.\n"); |
nothing calls this directly
no test coverage detected