| 1844 | } |
| 1845 | |
| 1846 | void MainWindow::delayedStartup() |
| 1847 | { |
| 1848 | // automatically run unit tests in Gui |
| 1849 | if (Gui::isInternalGuiTestRun()) { |
| 1850 | try { |
| 1851 | // Command-line GUI tests should not depend on the interactive QtUnitGui |
| 1852 | // dialog. In headless runs such as QT_QPA_PLATFORM=offscreen/minimal, |
| 1853 | // that dialog path can hang before the test body executes. Run the |
| 1854 | // embedded text-based GUI test script directly once startup reaches |
| 1855 | // delayedStartup(). |
| 1856 | Base::Interpreter().runString(Base::ScriptFactory().ProduceScript("FreeCADGuiTest")); |
| 1857 | if (App::Application::Config()["ExitTests"] == "yes") { |
| 1858 | Base::Interpreter().runString( |
| 1859 | "import sys\n" |
| 1860 | "sys.exit(0 if test_result.wasSuccessful() else 1)\n" |
| 1861 | ); |
| 1862 | } |
| 1863 | } |
| 1864 | catch (const Base::SystemExitException&) { |
| 1865 | // Properly quit the Qt event loop before propagating the exception |
| 1866 | QApplication::quit(); |
| 1867 | throw; |
| 1868 | } |
| 1869 | catch (const Base::Exception& e) { |
| 1870 | e.reportException(); |
| 1871 | QApplication::quit(); |
| 1872 | throw; |
| 1873 | } |
| 1874 | return; |
| 1875 | } |
| 1876 | |
| 1877 | // processing all command line files |
| 1878 | try { |
| 1879 | std::list<std::string> files = App::Application::getCmdLineFiles(); |
| 1880 | files = App::Application::processFiles(files); |
| 1881 | for (const auto& file : files) { |
| 1882 | QString filename = QString::fromUtf8(file.c_str(), file.size()); |
| 1883 | FileDialog::setWorkingDirectory(filename); |
| 1884 | QFileInfo fi(filename); |
| 1885 | appendRecentFile(fi.absoluteFilePath()); |
| 1886 | } |
| 1887 | } |
| 1888 | catch (const Base::SystemExitException&) { |
| 1889 | throw; |
| 1890 | } |
| 1891 | |
| 1892 | if (Application::hiddenMainWindow()) { |
| 1893 | QApplication::quit(); |
| 1894 | return; |
| 1895 | } |
| 1896 | |
| 1897 | // TODO: Check for deprecated settings |
| 1898 | Application::Instance->checkForDeprecatedSettings(); |
| 1899 | |
| 1900 | // Create new document? |
| 1901 | ParameterGrp::handle hGrp = WindowParameter::getDefaultParameter()->GetGroup("Document"); |
| 1902 | if (hGrp->GetBool("CreateNewDoc", false)) { |
| 1903 | if (App::GetApplication().getDocuments().empty()) { |
nothing calls this directly
no test coverage detected