From 87e8c64cb048ac1109d6d9f6d3326d812b704a22 Mon Sep 17 00:00:00 2001 From: "chunmao.guo" Date: Tue, 1 Aug 2023 16:45:06 +0800 Subject: [PATCH] FIX: [STUDIO-3892] warn bambu source dll from another install Change-Id: I23ae1b93d99035135786a6f40321475ea6c1c373 --- src/slic3r/GUI/wxMediaCtrl2.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/slic3r/GUI/wxMediaCtrl2.cpp b/src/slic3r/GUI/wxMediaCtrl2.cpp index de4f766eb..0a2c3e29a 100644 --- a/src/slic3r/GUI/wxMediaCtrl2.cpp +++ b/src/slic3r/GUI/wxMediaCtrl2.cpp @@ -79,14 +79,15 @@ void wxMediaCtrl2::Load(wxURI url) key2.QueryRawValue("Source Filter", clsid); BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": clsid %1% path %2%") % clsid % path; + std::string data_dir_str = Slic3r::data_dir(); + boost::filesystem::path data_dir_path(data_dir_str); + auto dll_path = data_dir_path / "plugins" / "BambuSource.dll"; + if (path.empty() || !wxFile::Exists(path) || clsid != CLSID_BAMBU_SOURCE) { - std::string data_dir_str = Slic3r::data_dir(); - boost::filesystem::path data_dir_path(data_dir_str); - auto dll_path = data_dir_path / "plugins" / "BambuSource.dll"; if (boost::filesystem::exists(dll_path)) { CallAfter( [dll_path] { - int res = wxMessageBox(_L("BambuSource has not correctly been registered for media playing! Press Yes to re-register it."), _L("Error"), wxYES_NO); + int res = wxMessageBox(_L("BambuSource has not correctly been registered for media playing! Press Yes to re-register it."), _L("Error"), wxYES_NO | wxICON_ERROR); if (res == wxYES) { SHELLEXECUTEINFO info{sizeof(info), 0, NULL, L"runas", L"regsvr32", dll_path.wstring().c_str(), SW_HIDE }; ::ShellExecuteEx(&info); @@ -94,7 +95,7 @@ void wxMediaCtrl2::Load(wxURI url) }); } else { CallAfter([] { - wxMessageBox(_L("Missing BambuSource component registered for media playing! Please re-install BambuStutio or seek after-sales help."), _L("Error"), wxOK); + wxMessageBox(_L("Missing BambuSource component registered for media playing! Please re-install BambuStutio or seek after-sales help."), _L("Error"), wxOK | wxICON_ERROR); }); } m_error = clsid != CLSID_BAMBU_SOURCE ? 101 : path.empty() ? 102 : 103; @@ -104,6 +105,17 @@ void wxMediaCtrl2::Load(wxURI url) wxPostEvent(this, event); return; } + if (path != dll_path) { + static bool notified = false; + if (!notified) CallAfter([dll_path] { + int res = wxMessageBox(_L("Using a BambuSource from a different install, video play may not work correctly!"), _L("Warning"), wxOK | wxICON_WARNING); + if (res == wxYES) { + SHELLEXECUTEINFO info{sizeof(info), 0, NULL, L"runas", L"regsvr32", dll_path.wstring().c_str(), SW_HIDE}; + ::ShellExecuteEx(&info); + } + }); + notified = true; + } wxRegKey keyWmp(wxRegKey::HKCU, "SOFTWARE\\Microsoft\\MediaPlayer\\Player\\Extensions\\."); keyWmp.Create(); long permissions = 0;