Skip to content

Commit

Permalink
Fix an issue that Bambu printer camera is not prompted to register du…
Browse files Browse the repository at this point in the history
…e to the Bambu's registry path changes

Fix #5554
  • Loading branch information
SoftFever committed Jun 5, 2024
1 parent 6af6a42 commit cb4b84c
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions src/slic3r/GUI/wxMediaCtrl2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,20 @@ void wxMediaCtrl2::Load(wxURI url)
return;
}
{
wxRegKey key1(wxRegKey::HKCR, L"CLSID\\" CLSID_BAMBU_SOURCE L"\\InProcServer32");
wxString path = key1.Exists() ? key1.QueryDefaultValue() : wxString{};
wxRegKey key11(wxRegKey::HKCU, L"SOFTWARE\\Classes\\CLSID\\" CLSID_BAMBU_SOURCE L"\\InProcServer32");
wxRegKey key12(wxRegKey::HKCR, L"CLSID\\" CLSID_BAMBU_SOURCE L"\\InProcServer32");
wxString path = key11.Exists() ? key11.QueryDefaultValue()
: key12.Exists() ? key12.QueryDefaultValue() : wxString{};
wxRegKey key2(wxRegKey::HKCR, "bambu");
wxString clsid;
if (key2.Exists())
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] {
Expand Down Expand Up @@ -132,6 +133,20 @@ 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! Press Yes to fix it."), _L("Warning"), wxYES_NO | wxICON_WARNING);
if (res == wxYES) {
auto path = dll_path.wstring();
if (path.find(L' ') != std::wstring::npos)
path = L"\"" + path + L"\"";
SHELLEXECUTEINFO info{sizeof(info), 0, NULL, L"open", L"regsvr32", path.c_str(), SW_HIDE};
::ShellExecuteEx(&info);
}
});
notified = true;
}
wxRegKey keyWmp(wxRegKey::HKCU, "SOFTWARE\\Microsoft\\MediaPlayer\\Player\\Extensions\\.");
keyWmp.Create();
long permissions = 0;
Expand Down

0 comments on commit cb4b84c

Please sign in to comment.