Skip to content

Commit

Permalink
FIX: [STUDIO-1754] limit_handles has bugs on posix, not use
Browse files Browse the repository at this point in the history
Change-Id: If65ac7196dfc02cb4ba37473127ecf48f3254049
  • Loading branch information
bambu123 authored and lanewei120 committed Dec 15, 2022
1 parent ffd94f9 commit 8d8b5c9
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions src/slic3r/GUI/MediaPlayCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,20 +238,6 @@ void MediaPlayCtrl::TogglePlay()
}
}

struct detach_process
#ifdef __WIN32__
: public ::boost::process::detail::windows::handler_base_ext
#else
: public ::boost::process::detail::posix::handler_base_ext
#endif
{
#ifdef __WIN32__
template<class Executor> void on_setup(Executor &exec) const {
exec.creation_flags |= ::boost::winapi::CREATE_NO_WINDOW_;
}
#endif
};

void MediaPlayCtrl::ToggleStream()
{
std::string file_url = data_dir() + "/cameratools/url.txt";
Expand Down Expand Up @@ -344,7 +330,7 @@ void MediaPlayCtrl::SetStatus(wxString const &msg2, bool hyperlink)
if (hyperlink) {
style |= LB_HYPERLINK;
}
//m_label_status->SetWindowStyle(style);
m_label_status->SetWindowStyle(style);
m_label_status->InvalidateBestSize();
Layout();
}
Expand Down Expand Up @@ -392,6 +378,14 @@ void MediaPlayCtrl::media_proc()
}
}

#ifdef __WIN32__
struct detach_process
: public ::boost::process::detail::windows::handler_base_ext
{
template<class Executor> void on_setup(Executor &exec) const { exec.creation_flags |= ::boost::winapi::CREATE_NO_WINDOW_; }
};
#endif

bool MediaPlayCtrl::start_stream_service(bool *need_install)
{
#ifdef __WIN32__
Expand Down Expand Up @@ -429,13 +423,17 @@ bool MediaPlayCtrl::start_stream_service(bool *need_install)
std::string file_dll2 = data_dir() + "/plugins/BambuSource.dll";
if (!boost::filesystem::exists(file_dll) || boost::filesystem::last_write_time(file_dll) != boost::filesystem::last_write_time(file_dll2))
boost::filesystem::copy_file(file_dll2, file_dll, boost::filesystem::copy_option::overwrite_if_exists);
boost::process::child process_source(file_source, file_url2.data().AsInternal(), boost::process::std_out > intermediate, detach_process(),
boost::process::start_dir(start_dir), boost::process::limit_handles);
boost::process::child process_ffmpeg(file_ffmpeg, configss, boost::process::std_in < intermediate, detach_process(), boost::process::limit_handles);
#else
boost::filesystem::permissions(file_source, boost::filesystem::owner_exe | boost::filesystem::add_perms);
boost::filesystem::permissions(file_ffmpeg, boost::filesystem::owner_exe | boost::filesystem::add_perms);
// TODO: limit_handles has bugs on posix
boost::process::child process_source(file_source, file_url2.data().AsInternal(), boost::process::std_out > intermediate,
boost::process::start_dir(start_dir));
boost::process::child process_ffmpeg(file_ffmpeg, configss, boost::process::std_in < intermediate);
#endif
boost::process::child process_source(file_source, file_url2.data().AsInternal(), boost::process::std_out > intermediate, detach_process(),
boost::process::start_dir(start_dir), boost::process::limit_handles);
boost::process::child process_ffmpeg(file_ffmpeg, configss, boost::process::std_in < intermediate, detach_process(), boost::process::limit_handles);
process_source.detach();
process_ffmpeg.detach();
} catch (std::exception &e) {
Expand Down

0 comments on commit 8d8b5c9

Please sign in to comment.