mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-14 11:21:18 +00:00
* Remove Unused Project Includes and Forward-Declare Where a Type Is Only Referenced Generated with include-what-you-use and applied conservatively. Only OrcaSlicer's own headers, the ones under src/ and tests/, are removed or forward-declared; standard-library and third-party includes are left alone. An include is removed only when both the Release and the Debug configuration leave it unused, never from inside a conditional block, and never from a file with platform-specific blocks, which only gain includes. Files whose only use of a header sits behind a feature or debug macro (libvgcode's OpenGL ES and marker code, the ARACHNE/TESTS_EXPORT_SVGS debug output) keep their includes. clonable_ptr.hpp gains #pragma once; it had no include guard and was only safe while Config.hpp was its sole includer. * Remove Unused Project Includes From Files With Platform-Specific Code A Linux include-what-you-use run cannot see the code inside _WIN32, __APPLE__ or __linux__ blocks, so its verdict is only taken where nothing the removed header declares, directly or through what it includes, is named inside those blocks. Removals also have to hold in both the Release and Debug configuration and never touch a line inside a conditional block. * Restore the libslic3r Precompiled Header and Direct Includes Lost in the Platform Pass The platform-file pass treated pchheader.hpp as an ordinary header and emptied it, and left GUI_Preview.hpp and 14 other files relying on headers they no longer reached directly. * Restore MainFrame.hpp in ParamsDialog.cpp for the Windows-Only Reparent Call * Include Headers That Files Reached Through Ones the Cleanup Removed * Drop Includes Duplicated by the Cleanup or by Main's Own Additions * Leave PreciseSeam.cpp as Main Has It After the Precise Seam Rework
86 lines
3.4 KiB
C++
86 lines
3.4 KiB
C++
#include "GUI_Init.hpp"
|
|
|
|
#include "libslic3r/AppConfig.hpp"
|
|
|
|
#include "slic3r/GUI/GUI_App.hpp"
|
|
#include "slic3r/GUI/InstanceCheck.hpp"
|
|
#include "slic3r/GUI/format.hpp"
|
|
#include "slic3r/GUI/MainFrame.hpp"
|
|
#include "slic3r/GUI/I18N.hpp"
|
|
|
|
// To show a message box if GUI initialization ends up with an exception thrown.
|
|
#include <vector>
|
|
#include <utility>
|
|
#include <wx/init.h>
|
|
#include "libslic3r/Exception.hpp"
|
|
#include <boost/log/trivial.hpp>
|
|
#include <ostream>
|
|
#include <exception>
|
|
#include <wx/msgdlg.h>
|
|
|
|
#include <boost/nowide/iostream.hpp>
|
|
#include <boost/nowide/convert.hpp>
|
|
#include <wx/string.h>
|
|
|
|
#if __APPLE__
|
|
#include <signal.h>
|
|
#endif // __APPLE__
|
|
|
|
namespace Slic3r {
|
|
namespace GUI {
|
|
|
|
const std::vector<std::pair<int, int>> OpenGLVersions::core = { {3,2}, {3,3}, {4,0}, {4,1}, {4,2}, {4,3}, {4,4}, {4,5}, {4,6} };
|
|
|
|
int GUI_Run(GUI_InitParams ¶ms)
|
|
{
|
|
#if __APPLE__
|
|
// On OSX, we use boost::process::spawn() to launch new instances of PrusaSlicer from another PrusaSlicer.
|
|
// boost::process::spawn() sets SIGCHLD to SIGIGN for the child process, thus if a child PrusaSlicer spawns another
|
|
// subprocess and the subrocess dies, the child PrusaSlicer will not receive information on end of subprocess
|
|
// (posix waitpid() call will always fail).
|
|
// https://jmmv.dev/2008/10/boostprocess-and-sigchld.html
|
|
// The child instance of PrusaSlicer has to reset SIGCHLD to its default, so that posix waitpid() and similar continue to work.
|
|
// See GH issue #5507
|
|
signal(SIGCHLD, SIG_DFL);
|
|
#endif // __APPLE__
|
|
|
|
//BBS: remove the try-catch and let exception goto above
|
|
try {
|
|
//GUI::GUI_App* gui = new GUI::GUI_App(params.start_as_gcodeviewer ? GUI::GUI_App::EAppMode::GCodeViewer : GUI::GUI_App::EAppMode::Editor);
|
|
GUI::GUI_App* gui = new GUI::GUI_App();
|
|
//if (gui->get_app_mode() != GUI::GUI_App::EAppMode::GCodeViewer) {
|
|
// G-code viewer is currently not performing instance check, a new G-code viewer is started every time.
|
|
bool gui_single_instance_setting = gui->app_config->get("app", "single_instance") == "true";
|
|
if (Slic3r::instance_check(params.argc, params.argv, gui_single_instance_setting)) {
|
|
//TODO: do we have delete gui and other stuff?
|
|
return -1;
|
|
}
|
|
//}
|
|
|
|
// gui->autosave = m_config.opt_string("autosave");
|
|
GUI::GUI_App::SetInstance(gui);
|
|
gui->init_params = ¶ms;
|
|
|
|
if (params.argc > 1) {
|
|
// STUDIO-273 wxWidgets report error when opening some files with specific names
|
|
// wxWidgets does not handle parameters, so intercept parameters here, only keep the app name
|
|
int argc = 1;
|
|
std::vector<char *> argv;
|
|
argv.push_back(params.argv[0]);
|
|
return wxEntry(argc, argv.data());
|
|
} else {
|
|
return wxEntry(params.argc, params.argv);
|
|
}
|
|
} catch (const Slic3r::Exception &ex) {
|
|
BOOST_LOG_TRIVIAL(error) << ex.what() << std::endl;
|
|
wxMessageBox(boost::nowide::widen(ex.what()), _L("Orca Slicer GUI initialization failed"), wxICON_STOP);
|
|
} catch (const std::exception &ex) {
|
|
BOOST_LOG_TRIVIAL(error) << ex.what() << std::endl;
|
|
wxMessageBox(format_wxstr(_L("Fatal error, exception: %1%"), ex.what()), _L("Orca Slicer GUI initialization failed"), wxICON_STOP);
|
|
}
|
|
// error
|
|
return 1;
|
|
}
|
|
}
|
|
}
|