Fixed a crash in a constructor of FullPrintConfig due to an incorrect use
of virtual inheritance. Note that an invocation of ConfigBase::optptr() is routed to FullPrintConfig::optptr() for all classes of the FullPrintConfig hierarchy. FullPrintConfig::optptr() in turn invokes optptr() of PrintObjectConfig, PrintRegionConfig, PrintConfig and HostConfig. Due to the use of virtual inheritance, this all happens, when PrintObjectConfig gets constructed as part of FullPrintConfig, but at that time PrintRegionConfig, PrintConfig and HostConfig are not constructed yet. Accessing them at that time leads to crashes, when compiled with Visual Studio 2013 compiler. For some reason the code generated by gcc does not crash, but I believe the behavior is undefined and it is better to be fixed anyway. The patch solves the problem by calling set_defaults() by the topmost object, which not only fixes the crashes, but also avoids repeated initialization.
This commit is contained in:
parent
3e8575c931
commit
bd23fe9c44
@ -126,9 +126,10 @@ class PrintObjectConfig : public virtual StaticPrintConfig
|
|||||||
ConfigOptionInt support_material_threshold;
|
ConfigOptionInt support_material_threshold;
|
||||||
ConfigOptionFloat xy_size_compensation;
|
ConfigOptionFloat xy_size_compensation;
|
||||||
|
|
||||||
PrintObjectConfig() : StaticPrintConfig() {
|
PrintObjectConfig(bool initialize = true) : StaticPrintConfig() {
|
||||||
this->set_defaults();
|
if (initialize)
|
||||||
};
|
this->set_defaults();
|
||||||
|
}
|
||||||
|
|
||||||
virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) {
|
virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) {
|
||||||
OPT_PTR(dont_support_bridges);
|
OPT_PTR(dont_support_bridges);
|
||||||
@ -195,9 +196,10 @@ class PrintRegionConfig : public virtual StaticPrintConfig
|
|||||||
ConfigOptionInt top_solid_layers;
|
ConfigOptionInt top_solid_layers;
|
||||||
ConfigOptionFloatOrPercent top_solid_infill_speed;
|
ConfigOptionFloatOrPercent top_solid_infill_speed;
|
||||||
|
|
||||||
PrintRegionConfig() : StaticPrintConfig() {
|
PrintRegionConfig(bool initialize = true) : StaticPrintConfig() {
|
||||||
this->set_defaults();
|
if (initialize)
|
||||||
};
|
this->set_defaults();
|
||||||
|
}
|
||||||
|
|
||||||
virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) {
|
virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) {
|
||||||
OPT_PTR(bottom_solid_layers);
|
OPT_PTR(bottom_solid_layers);
|
||||||
@ -266,9 +268,10 @@ class GCodeConfig : public virtual StaticPrintConfig
|
|||||||
ConfigOptionBool use_relative_e_distances;
|
ConfigOptionBool use_relative_e_distances;
|
||||||
ConfigOptionBool use_volumetric_e;
|
ConfigOptionBool use_volumetric_e;
|
||||||
|
|
||||||
GCodeConfig() : StaticPrintConfig() {
|
GCodeConfig(bool initialize = true) : StaticPrintConfig() {
|
||||||
this->set_defaults();
|
if (initialize)
|
||||||
};
|
this->set_defaults();
|
||||||
|
}
|
||||||
|
|
||||||
virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) {
|
virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) {
|
||||||
OPT_PTR(before_layer_gcode);
|
OPT_PTR(before_layer_gcode);
|
||||||
@ -366,9 +369,10 @@ class PrintConfig : public GCodeConfig
|
|||||||
ConfigOptionBools wipe;
|
ConfigOptionBools wipe;
|
||||||
ConfigOptionFloat z_offset;
|
ConfigOptionFloat z_offset;
|
||||||
|
|
||||||
PrintConfig() : GCodeConfig() {
|
PrintConfig(bool initialize = true) : GCodeConfig(false) {
|
||||||
this->set_defaults();
|
if (initialize)
|
||||||
};
|
this->set_defaults();
|
||||||
|
}
|
||||||
|
|
||||||
virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) {
|
virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) {
|
||||||
OPT_PTR(avoid_crossing_perimeters);
|
OPT_PTR(avoid_crossing_perimeters);
|
||||||
@ -438,9 +442,10 @@ class HostConfig : public virtual StaticPrintConfig
|
|||||||
ConfigOptionString serial_port;
|
ConfigOptionString serial_port;
|
||||||
ConfigOptionInt serial_speed;
|
ConfigOptionInt serial_speed;
|
||||||
|
|
||||||
HostConfig() : StaticPrintConfig() {
|
HostConfig(bool initialize = true) : StaticPrintConfig() {
|
||||||
this->set_defaults();
|
if (initialize)
|
||||||
};
|
this->set_defaults();
|
||||||
|
}
|
||||||
|
|
||||||
virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) {
|
virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) {
|
||||||
OPT_PTR(octoprint_host);
|
OPT_PTR(octoprint_host);
|
||||||
@ -456,6 +461,16 @@ class FullPrintConfig
|
|||||||
: public PrintObjectConfig, public PrintRegionConfig, public PrintConfig, public HostConfig
|
: public PrintObjectConfig, public PrintRegionConfig, public PrintConfig, public HostConfig
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
FullPrintConfig(bool initialize = true) :
|
||||||
|
PrintObjectConfig(false),
|
||||||
|
PrintRegionConfig(false),
|
||||||
|
PrintConfig(false),
|
||||||
|
HostConfig(false)
|
||||||
|
{
|
||||||
|
if (initialize)
|
||||||
|
this->set_defaults();
|
||||||
|
}
|
||||||
|
|
||||||
virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) {
|
virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) {
|
||||||
ConfigOption* opt;
|
ConfigOption* opt;
|
||||||
if ((opt = PrintObjectConfig::optptr(opt_key, create)) != NULL) return opt;
|
if ((opt = PrintObjectConfig::optptr(opt_key, create)) != NULL) return opt;
|
||||||
|
Loading…
Reference in New Issue
Block a user