mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-08-29 21:07:11 +00:00
fix merge conflicts
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include "../GUI/PartPlate.hpp"
|
||||
#include "libslic3r/CutUtils.hpp"
|
||||
#include "libslic3r/ClipperUtils.hpp"
|
||||
#include "libslic3r/Utils.hpp"
|
||||
|
||||
#include "libslic3r/Model.hpp"
|
||||
#include "slic3r/GUI/Jobs/BoostThreadWorker.hpp"
|
||||
@@ -27,11 +28,19 @@ const double MIN_PA_K_VALUE = 0.0;
|
||||
const double MAX_PA_K_VALUE = 2.0;
|
||||
|
||||
std::unique_ptr<Worker> CalibUtils::print_worker;
|
||||
wxString wxstr_temp_dir = fs::path(fs::temp_directory_path() / "calib").wstring();
|
||||
static const std::string temp_dir = wxstr_temp_dir.utf8_string();
|
||||
static const std::string temp_gcode_path = temp_dir + "/temp.gcode";
|
||||
static const std::string path = temp_dir + "/test.3mf";
|
||||
static const std::string config_3mf_path = temp_dir + "/test_config.3mf";
|
||||
|
||||
// Built lazily so temporary_dir() is read on first use, after set_temporary_dir()
|
||||
// has run at startup (it isolates the temp root per user to avoid cross-user collisions).
|
||||
static const std::string& calib_temp_dir()
|
||||
{
|
||||
static const std::string dir = temporary_dir() + "/calib";
|
||||
return dir;
|
||||
}
|
||||
static std::string calib_temp_file(const std::string& name) { return calib_temp_dir() + "/" + name; }
|
||||
|
||||
static const std::string gcode_filename = "temp.gcode";
|
||||
static const std::string model_filename = "test.3mf";
|
||||
static const std::string config_filename = "test_config.3mf";
|
||||
|
||||
static std::string MachineBedTypeString[7] = {
|
||||
"auto",
|
||||
@@ -85,6 +94,10 @@ wxString get_nozzle_volume_type_name(NozzleVolumeType type)
|
||||
return _L("Standard");
|
||||
} else if (NozzleVolumeType::nvtHighFlow == type) {
|
||||
return _L("High Flow");
|
||||
} else if (NozzleVolumeType::nvtHybrid == type) {
|
||||
return _L("Hybrid");
|
||||
} else if (NozzleVolumeType::nvtTPUHighFlow == type) {
|
||||
return _L("TPU High Flow");
|
||||
}
|
||||
return wxString();
|
||||
}
|
||||
@@ -1599,7 +1612,7 @@ bool CalibUtils::process_and_store_3mf(Model *model, const DynamicPrintConfig &f
|
||||
part_plate->update_slice_result_valid_state(true);
|
||||
|
||||
gcode_result->reset();
|
||||
fff_print->export_gcode(temp_gcode_path, gcode_result, nullptr);
|
||||
fff_print->export_gcode(calib_temp_file(gcode_filename), gcode_result, nullptr);
|
||||
|
||||
std::vector<ThumbnailData*> thumbnails;
|
||||
PlateDataPtrs plate_data_list;
|
||||
@@ -1618,7 +1631,7 @@ bool CalibUtils::process_and_store_3mf(Model *model, const DynamicPrintConfig &f
|
||||
}
|
||||
|
||||
for (auto plate_data : plate_data_list) {
|
||||
plate_data->gcode_file = temp_gcode_path;
|
||||
plate_data->gcode_file = calib_temp_file(gcode_filename);
|
||||
plate_data->is_sliced_valid = true;
|
||||
plate_data->printer_model_id = obj_->printer_type;
|
||||
FilamentInfo& filament_info = plate_data->slice_filaments_info.front();
|
||||
@@ -1681,7 +1694,7 @@ bool CalibUtils::process_and_store_3mf(Model *model, const DynamicPrintConfig &f
|
||||
}
|
||||
|
||||
StoreParams store_params;
|
||||
store_params.path = path.c_str();
|
||||
store_params.path = calib_temp_file(model_filename);
|
||||
store_params.model = model;
|
||||
store_params.plate_data_list = plate_data_list;
|
||||
store_params.config = &new_print_config;
|
||||
@@ -1695,7 +1708,7 @@ bool CalibUtils::process_and_store_3mf(Model *model, const DynamicPrintConfig &f
|
||||
bool success = Slic3r::store_bbs_3mf(store_params);
|
||||
|
||||
store_params.strategy = SaveStrategy::Silence | SaveStrategy::SplitModel | SaveStrategy::WithSliceInfo | SaveStrategy::SkipAuxiliary;
|
||||
store_params.path = config_3mf_path.c_str();
|
||||
store_params.path = calib_temp_file(config_filename);
|
||||
success = Slic3r::store_bbs_3mf(store_params);
|
||||
|
||||
release_PlateData_list(plate_data_list);
|
||||
@@ -1784,9 +1797,9 @@ void CalibUtils::send_to_print(const CalibInfo &calib_info, wxString &error_mess
|
||||
PrintPrepareData job_data;
|
||||
job_data.is_from_plater = false;
|
||||
job_data.plate_idx = 0;
|
||||
job_data._3mf_config_path = config_3mf_path;
|
||||
job_data._3mf_path = path;
|
||||
job_data._temp_path = temp_dir;
|
||||
job_data._3mf_config_path = calib_temp_file(config_filename);
|
||||
job_data._3mf_path = calib_temp_file(model_filename);
|
||||
job_data._temp_path = calib_temp_dir();
|
||||
|
||||
PlateListData plate_data;
|
||||
plate_data.is_valid = true;
|
||||
@@ -1889,9 +1902,9 @@ void CalibUtils::send_to_print(const std::vector<CalibInfo> &calib_infos, wxStri
|
||||
PrintPrepareData job_data;
|
||||
job_data.is_from_plater = false;
|
||||
job_data.plate_idx = 0;
|
||||
job_data._3mf_config_path = config_3mf_path;
|
||||
job_data._3mf_path = path;
|
||||
job_data._temp_path = temp_dir;
|
||||
job_data._3mf_config_path = calib_temp_file(config_filename);
|
||||
job_data._3mf_path = calib_temp_file(model_filename);
|
||||
job_data._temp_path = calib_temp_dir();
|
||||
|
||||
PlateListData plate_data;
|
||||
plate_data.is_valid = true;
|
||||
|
||||
@@ -229,35 +229,33 @@ std::unique_ptr<NetworkAgent> create_agent_from_config(const std::string& log_di
|
||||
|
||||
void NetworkAgentFactory::register_python_plugin(const std::string& plugin_key)
|
||||
{
|
||||
auto capabilities = PluginManager::instance().get_loader().get_plugin_capabilities_by_type(
|
||||
plugin_key, PluginCapabilityType::PrinterConnection);
|
||||
for (const auto& capability : capabilities)
|
||||
if (capability && capability->enabled)
|
||||
register_python_printer_agent(plugin_key, capability->name);
|
||||
for (const auto& capability : PluginManager::instance().get_plugin_capabilities(plugin_key, PluginCapabilityType::PrinterConnection,
|
||||
/*only_enabled=*/true))
|
||||
register_python_printer_agent(plugin_key, capability->name());
|
||||
}
|
||||
|
||||
void NetworkAgentFactory::register_python_printer_agent(const std::string& plugin_key, const std::string& capability_name)
|
||||
{
|
||||
PluginManager& plugin_manager = PluginManager::instance();
|
||||
|
||||
auto cap = plugin_manager.get_loader().get_plugin_capability_by_name(plugin_key, PluginCapabilityType::PrinterConnection,
|
||||
capability_name);
|
||||
auto cap = plugin_manager.get_plugin_capability(plugin_key, capability_name, PluginCapabilityType::PrinterConnection,
|
||||
/*only_enabled=*/false);
|
||||
if (!cap) {
|
||||
BOOST_LOG_TRIVIAL(warning) << "Printer-agent capability '" << capability_name << "' not found for plugin '" << plugin_key << "'";
|
||||
return;
|
||||
}
|
||||
if (!cap->enabled) {
|
||||
|
||||
PluginDescriptor descriptor;
|
||||
if (!plugin_manager.try_get_plugin_descriptor(plugin_key, descriptor)) {
|
||||
BOOST_LOG_TRIVIAL(warning) << "Could not find descriptor for plugin key: '" << plugin_key;
|
||||
return;
|
||||
}
|
||||
if (!cap->is_enabled()) {
|
||||
BOOST_LOG_TRIVIAL(warning) << "Printer-agent capability '" << capability_name << "' is disabled for plugin '" << plugin_key << "'";
|
||||
return;
|
||||
}
|
||||
|
||||
PluginDescriptor descriptor;
|
||||
if (!plugin_manager.get_catalog().try_get_plugin_descriptor(plugin_key, descriptor)) {
|
||||
BOOST_LOG_TRIVIAL(warning) << "Could not find descriptor for plugin key: '" << plugin_key;
|
||||
return;
|
||||
}
|
||||
|
||||
auto plugin = std::dynamic_pointer_cast<PrinterAgentPluginCapability>(cap->instance);
|
||||
auto plugin = std::dynamic_pointer_cast<PrinterAgentPluginCapability>(cap);
|
||||
|
||||
if (!plugin) {
|
||||
BOOST_LOG_TRIVIAL(warning) << "Loaded plugin capability '" << capability_name << "' is not a printer-agent plugin";
|
||||
@@ -305,9 +303,10 @@ void NetworkAgentFactory::register_python_printer_agent(const std::string& plugi
|
||||
|
||||
// Python work above may allow disable/unload/reload to replace this capability.
|
||||
// Re-resolve without holding the registry mutex to avoid lock inversion and reentrancy.
|
||||
auto current_cap = plugin_manager.get_loader().get_plugin_capability_by_name(plugin_key, PluginCapabilityType::PrinterConnection,
|
||||
capability_name);
|
||||
if (current_cap != cap || !current_cap->enabled) {
|
||||
// only_enabled defaults to true here, so a capability that changed identity (reload) or was
|
||||
// merely disabled both surface the same way: current_cap no longer equals cap.
|
||||
auto current_cap = plugin_manager.get_plugin_capability(plugin_key, capability_name, PluginCapabilityType::PrinterConnection);
|
||||
if (current_cap != cap) {
|
||||
BOOST_LOG_TRIVIAL(debug) << "Printer-agent capability '" << capability_name << "' from plugin '" << plugin_key
|
||||
<< "' changed or was disabled during registration";
|
||||
return;
|
||||
@@ -322,7 +321,9 @@ void NetworkAgentFactory::register_python_printer_agent(const std::string& plugi
|
||||
[&plugin_key, &capability_name](const auto& entry) {
|
||||
return entry.first.first == plugin_key && entry.first.second == capability_name;
|
||||
});
|
||||
if (token_it == s_python_printer_agent_registration_tokens.end() || token_it->second != registration_token || !cap->enabled) {
|
||||
const bool cap_still_enabled = cap->is_enabled();
|
||||
if (token_it == s_python_printer_agent_registration_tokens.end() || token_it->second != registration_token ||
|
||||
!cap_still_enabled) {
|
||||
BOOST_LOG_TRIVIAL(debug) << "Printer-agent capability '" << capability_name << "' from plugin '" << plugin_key
|
||||
<< "' was disabled before registry commit";
|
||||
return;
|
||||
@@ -448,6 +449,18 @@ void NetworkAgentFactory::deregister_python_printer_agent(const std::string& plu
|
||||
if (cached_agent)
|
||||
cached_agent->disconnect_printer();
|
||||
|
||||
// The GUI may still own the active capability separately from the factory cache. Clear that
|
||||
// handle before the plugin module is torn down, otherwise NetworkAgent can retain a Python
|
||||
// object whose implementation is about to be unloaded.
|
||||
if (!agent_id.empty() && wxTheApp) {
|
||||
NetworkAgent* network_agent = GUI::wxGetApp().getAgent();
|
||||
if (network_agent) {
|
||||
const auto active_agent = network_agent->get_printer_agent();
|
||||
if (active_agent && active_agent->get_agent_info().id == agent_id)
|
||||
network_agent->set_printer_agent(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << "Deregistered Python printer-agent capability '" << capability_name << "' from plugin '"
|
||||
<< plugin_key << "' with agent ID '" << agent_id << "'";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user