mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-20 11:53:48 +00:00
FIX: reset bambu lib after restart network plugin
Change-Id: I4a3a4b7420745835ca3fa00c6edebe9d8d98cbf6 Jira: STUDIO-7571 (cherry picked from commit 28d9c6743fae80bfd40e4ee391e30d62cb16d4ab)
This commit is contained in:
@@ -154,6 +154,11 @@ typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS2)(
|
||||
using namespace std::literals;
|
||||
namespace pt = boost::property_tree;
|
||||
|
||||
struct StaticBambuLib
|
||||
{
|
||||
static void reset();
|
||||
};
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
@@ -1512,6 +1517,7 @@ void GUI_App::restart_networking()
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__<< boost::format(" enter, mainframe %1%")%mainframe;
|
||||
on_init_network(true);
|
||||
StaticBambuLib::reset();
|
||||
if(m_agent) {
|
||||
init_networking_callbacks();
|
||||
m_agent->set_on_ssdp_msg_fn(
|
||||
|
||||
@@ -66,12 +66,15 @@ static std::map<int, std::string> error_messages = {
|
||||
};
|
||||
|
||||
struct StaticBambuLib : BambuLib {
|
||||
static StaticBambuLib & get();
|
||||
static StaticBambuLib &get(BambuLib * copy = nullptr);
|
||||
static int Fake_Bambu_Create(Bambu_Tunnel*, char const*) { return -2; }
|
||||
static void reset();
|
||||
private:
|
||||
std::vector<BambuLib *> copies_;
|
||||
};
|
||||
|
||||
PrinterFileSystem::PrinterFileSystem()
|
||||
: BambuLib(StaticBambuLib::get())
|
||||
: BambuLib(StaticBambuLib::get(this))
|
||||
{
|
||||
if (!default_thumbnail.IsOk()) {
|
||||
default_thumbnail = *Slic3r::GUI::BitmapCache().load_svg("printer_file", 0, 0);
|
||||
@@ -1610,12 +1613,12 @@ static void* get_function(const char* name)
|
||||
|
||||
#define GET_FUNC(x) lib.x = reinterpret_cast<decltype(lib.x)>(get_function(#x))
|
||||
|
||||
StaticBambuLib &StaticBambuLib::get()
|
||||
StaticBambuLib &StaticBambuLib::get(BambuLib *copy)
|
||||
{
|
||||
static StaticBambuLib lib;
|
||||
// first load the library
|
||||
|
||||
if (lib.Bambu_Open)
|
||||
if (lib.Bambu_Create)
|
||||
return lib;
|
||||
|
||||
if (!module) {
|
||||
@@ -1639,11 +1642,22 @@ StaticBambuLib &StaticBambuLib::get()
|
||||
GET_FUNC(Bambu_SetLogger);
|
||||
GET_FUNC(Bambu_FreeLogMsg);
|
||||
|
||||
if (!lib.Bambu_Open)
|
||||
if (!lib.Bambu_Create) {
|
||||
lib.Bambu_Create = Fake_Bambu_Create;
|
||||
if (copy)
|
||||
lib.copies_.push_back(copy);
|
||||
}
|
||||
return lib;
|
||||
}
|
||||
|
||||
void StaticBambuLib::reset()
|
||||
{
|
||||
get().Bambu_Create = nullptr;
|
||||
auto &lib = get();
|
||||
for (auto c : lib.copies_)
|
||||
*c = lib;
|
||||
}
|
||||
|
||||
extern "C" BambuLib *bambulib_get() {
|
||||
return &StaticBambuLib::get();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user