|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
|
|
| #include "../FCConfig.h"
|
|
|
| #if HAVE_CONFIG_H
|
| # include <config.h>
|
| #endif
|
|
|
| #include <cstdio>
|
| #include <ostream>
|
| #include <QString>
|
|
|
|
|
| #include <Base/Console.h>
|
| #include <Base/Exception.h>
|
| #include <Base/Interpreter.h>
|
|
|
|
|
| #include <App/Application.h>
|
|
|
|
|
| using App::Application;
|
| using Base::Console;
|
|
|
| const char sBanner[]
|
| = "(C) 2001-2025 FreeCAD contributors\n"
|
| "FreeCAD is free and open-source software licensed under the terms of LGPL2+ license.\n\n";
|
|
|
| int main(int argc, char** argv)
|
| {
|
|
|
| setlocale(LC_ALL, "");
|
| setlocale(LC_NUMERIC, "C");
|
|
|
| #if defined(__MINGW32__)
|
| const char* mingw_prefix = getenv("MINGW_PREFIX");
|
| const char* py_home = getenv("PYTHONHOME");
|
| if (!py_home && mingw_prefix) {
|
| _putenv_s("PYTHONHOME", mingw_prefix);
|
| }
|
| #endif
|
|
|
|
|
| App::Application::Config()["ExeName"] = "FreeCAD";
|
| App::Application::Config()["ExeVendor"] = "FreeCAD";
|
| App::Application::Config()["AppDataSkipVendor"] = "true";
|
|
|
|
|
| App::Application::Config()["CopyrightInfo"] = sBanner;
|
|
|
| try {
|
|
|
|
|
|
|
| App::Application::Config()["RunMode"] = "Exit";
|
| App::Application::Config()["LoggingConsole"] = "1";
|
|
|
|
|
| App::Application::init(argc, argv);
|
| }
|
| catch (const Base::UnknownProgramOption& e) {
|
| std::cerr << e.what();
|
| exit(1);
|
| }
|
| catch (const Base::ProgramInformation& e) {
|
| if (std::strcmp(e.what(), App::Application::verboseVersionEmitMessage) == 0) {
|
| QString data;
|
| QTextStream str(&data);
|
| const std::map<std::string, std::string> config = App::Application::Config();
|
|
|
| App::Application::getVerboseCommonInfo(str, config);
|
| App::Application::getVerboseAddOnsInfo(str, config);
|
|
|
| std::cout << data.toStdString();
|
| exit(0);
|
| }
|
| std::cout << e.what();
|
| exit(0);
|
| }
|
| catch (const Base::Exception& e) {
|
| std::string appName = App::Application::Config()["ExeName"];
|
| std::cout << "While initializing " << appName << " the following exception occurred: '"
|
| << e.what() << "'\n\n";
|
| std::cout << "Python is searching for its runtime files in the following directories:\n"
|
| << Base::Interpreter().getPythonPath() << "\n\n";
|
| std::cout << "Python version information:\n" << Py_GetVersion() << "\n";
|
| const char* pythonhome = getenv("PYTHONHOME");
|
| if (pythonhome) {
|
| std::cout << "\nThe environment variable PYTHONHOME is set to '" << pythonhome << "'.";
|
| std::cout << "\nSetting this environment variable might cause Python to fail. "
|
| "Please contact your administrator to unset it on your system.";
|
| }
|
| else {
|
| std::cout << "\nPlease contact the application's support team for more information.";
|
| }
|
| std::cout << std::endl;
|
| exit(100);
|
| }
|
| catch (...) {
|
| std::string appName = App::Application::Config()["ExeName"];
|
| std::cout << "Unknown runtime error occurred while initializing " << appName << ".\n\n";
|
| std::cout << "Please contact the application's support team for more information.";
|
| std::cout << std::endl;
|
| exit(101);
|
| }
|
|
|
|
|
| try {
|
| Application::runApplication();
|
| }
|
| catch (const Base::SystemExitException& e) {
|
| exit(e.getExitCode());
|
| }
|
| catch (const Base::Exception& e) {
|
| e.reportException();
|
| exit(1);
|
| }
|
| catch (...) {
|
| Console().error("Application unexpectedly terminated\n");
|
| exit(1);
|
| }
|
|
|
|
|
| Console().log("FreeCAD terminating...\n");
|
|
|
| try {
|
|
|
| App::GetApplication().closeAllDocuments();
|
| }
|
| catch (...) {
|
| }
|
|
|
|
|
| Application::destruct();
|
|
|
| Console().log("FreeCAD completely terminated\n");
|
|
|
| return 0;
|
| }
|
|
|