mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-13 04:09:18 +08:00
Mods making slic3r runnable from commandline without crashing (Pshemek)
This commit is contained in:
parent
daaceff20a
commit
1db87ed41a
@ -11,6 +11,7 @@ option(COVERAGE "Build with gcov code coverage profiling." OFF)
|
||||
|
||||
# only on newer GCCs: -ftemplate-backtrace-limit=0
|
||||
add_compile_options(-DNO_PERL -DM_PI=3.14159265358979323846 -D_GLIBCXX_USE_C99 -DHAS_BOOL -DNOGDI -DBOOST_ASIO_DISABLE_KQUEUE)
|
||||
#add_link_options(-rdynamic)
|
||||
|
||||
if (MSVC)
|
||||
add_compile_options(-W3)
|
||||
|
@ -36,7 +36,7 @@ int CLI::run(int argc, char **argv) {
|
||||
// Convert arguments to UTF-8 (needed on Windows).
|
||||
// argv then points to memory owned by a.
|
||||
boost::nowide::args a(argc, argv);
|
||||
|
||||
std::cerr<<"after boost::nowide<<args"<<std::endl;
|
||||
// parse all command line options into a DynamicConfig
|
||||
t_config_option_keys opt_order;
|
||||
this->config_def.merge(cli_actions_config_def);
|
||||
@ -44,19 +44,18 @@ int CLI::run(int argc, char **argv) {
|
||||
this->config_def.merge(cli_misc_config_def);
|
||||
this->config_def.merge(print_config_def);
|
||||
this->config.def = &this->config_def;
|
||||
|
||||
std::cerr<<"after merges"<<std::endl;
|
||||
// if any option is unsupported, print usage and abort immediately
|
||||
if (!this->config.read_cli(argc, argv, &this->input_files, &opt_order)) {
|
||||
this->print_help();
|
||||
return 1;
|
||||
}
|
||||
|
||||
// parse actions and transform options
|
||||
for (auto const &opt_key : opt_order) {
|
||||
if (cli_actions_config_def.has(opt_key)) this->actions.push_back(opt_key);
|
||||
if (cli_transform_config_def.has(opt_key)) this->transforms.push_back(opt_key);
|
||||
}
|
||||
|
||||
try{
|
||||
// load config files supplied via --load
|
||||
for (auto const &file : config.getStrings("load")) {
|
||||
if (!boost::filesystem::exists(file)) {
|
||||
@ -78,15 +77,18 @@ int CLI::run(int argc, char **argv) {
|
||||
c.normalize();
|
||||
this->print_config.apply(c);
|
||||
}
|
||||
}catch (...){
|
||||
std::cerr<<"Exception in 'load' processing "<<std::endl;
|
||||
}
|
||||
|
||||
// apply command line options to a more specific DynamicPrintConfig which provides normalize()
|
||||
// (command line options override --load files)
|
||||
this->print_config.apply(config, true);
|
||||
this->print_config.normalize();
|
||||
|
||||
std::cerr<<"after config normalize" << std::endl;
|
||||
// create a static (full) print config to be used in our logic
|
||||
this->full_print_config.apply(this->print_config);
|
||||
|
||||
std::cerr<<"apply full config"<<std::endl;
|
||||
// validate config
|
||||
try {
|
||||
this->full_print_config.validate();
|
||||
@ -94,6 +96,7 @@ int CLI::run(int argc, char **argv) {
|
||||
boost::nowide::cerr << e.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
std::cerr<<"after config validation"<<std::endl;
|
||||
|
||||
// read input file(s) if any
|
||||
for (auto const &file : input_files) {
|
||||
|
@ -372,6 +372,7 @@ void
|
||||
ConfigBase::apply_only(const ConfigBase &other, const t_config_option_keys &opt_keys, bool ignore_nonexistent, bool default_nonexistent) {
|
||||
// loop through options and apply them
|
||||
for (const t_config_option_key &opt_key : opt_keys) {
|
||||
try{
|
||||
ConfigOption* my_opt = this->option(opt_key, true);
|
||||
if (opt_key.size() == 0) continue;
|
||||
if (my_opt == NULL) {
|
||||
@ -395,6 +396,10 @@ ConfigBase::apply_only(const ConfigBase &other, const t_config_option_keys &opt_
|
||||
std::string error = "Unexpected failure when deserializing serialized value for " + opt_key;
|
||||
CONFESS(error.c_str());
|
||||
}
|
||||
} catch ( UnknownOptionException & e ){
|
||||
|
||||
// std::cerr<<e.what()<<std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,10 @@
|
||||
#ifndef slic3r_ConfigBase_hpp_
|
||||
#define slic3r_ConfigBase_hpp_
|
||||
|
||||
#include <execinfo.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <map>
|
||||
#include <climits>
|
||||
#include <cstdio>
|
||||
@ -15,6 +19,8 @@
|
||||
#include "Point.hpp"
|
||||
#include "Geometry.hpp"
|
||||
|
||||
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
/// Name of the configuration option.
|
||||
@ -31,20 +37,40 @@ class ConfigOptionException : public std::exception {
|
||||
public:
|
||||
const t_config_option_key opt_key;
|
||||
ConfigOptionException(const t_config_option_key _opt_key)
|
||||
: opt_key(_opt_key) {};
|
||||
: opt_key(_opt_key) {
|
||||
/*
|
||||
void *array[10];
|
||||
size_t size;
|
||||
char **strings;
|
||||
size_t i;
|
||||
|
||||
size = backtrace (array, 10);
|
||||
strings = backtrace_symbols (array, size);
|
||||
|
||||
printf ("Obtained %zd stack frames.\n", size);
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
std::cerr<<strings[i]<<std::endl;
|
||||
|
||||
free (strings);
|
||||
//*/
|
||||
};
|
||||
|
||||
virtual const char* what() const noexcept {
|
||||
std::string s("Exception with the option: ");
|
||||
s += this->opt_key;
|
||||
return s.c_str();
|
||||
}
|
||||
|
||||
};
|
||||
class UnknownOptionException : public ConfigOptionException {
|
||||
using ConfigOptionException::ConfigOptionException;
|
||||
|
||||
};
|
||||
class InvalidOptionException : public ConfigOptionException {
|
||||
using ConfigOptionException::ConfigOptionException;
|
||||
|
||||
public:
|
||||
virtual const char* what() const noexcept {
|
||||
std::string s("Invalid value for option: ");
|
||||
s += this->opt_key;
|
||||
return s.c_str();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/// Specialization of std::exception to indicate that an unsupported accessor was called on a config option.
|
||||
|
Loading…
x
Reference in New Issue
Block a user