diff --git a/src/libslic3r/Config.cpp b/src/libslic3r/Config.cpp index bfa0991a7..e065360aa 100644 --- a/src/libslic3r/Config.cpp +++ b/src/libslic3r/Config.cpp @@ -16,6 +16,7 @@ #include <boost/nowide/cenv.hpp> #include <boost/nowide/fstream.hpp> #include <boost/property_tree/ini_parser.hpp> +#include <boost/format.hpp> #include <string.h> namespace Slic3r { diff --git a/src/libslic3r/Utils.hpp b/src/libslic3r/Utils.hpp index c0ffad727..0fbad537c 100644 --- a/src/libslic3r/Utils.hpp +++ b/src/libslic3r/Utils.hpp @@ -2,6 +2,8 @@ #define slic3r_Utils_hpp_ #include <locale> +#include <utility> +#include <functional> #include <type_traits> #include "libslic3r.h" @@ -148,6 +150,37 @@ template<class T> size_t next_highest_power_of_2(T v, extern std::string xml_escape(std::string text); + +class ScopeGuard +{ +public: + typedef std::function<void()> Closure; +private: + bool committed; + Closure closure; + +public: + ScopeGuard() {} + ScopeGuard(Closure closure) : closure(std::move(closure)) {} + ScopeGuard(const ScopeGuard&) = delete; + ScopeGuard(ScopeGuard &&other) : closure(std::move(other.closure)) {} + + ~ScopeGuard() + { + if (closure) { closure(); } + } + + ScopeGuard& operator=(const ScopeGuard&) = delete; + ScopeGuard& operator=(ScopeGuard &&other) + { + closure = std::move(other.closure); + return *this; + } + + void reset() { closure = Closure(); } +}; + + } // namespace Slic3r #endif // slic3r_Utils_hpp_ diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index e153161d4..d792a3bbe 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -4768,8 +4768,14 @@ void GLCanvas3D::_refresh_if_shown_on_screen() { const Size& cnv_size = get_canvas_size(); _resize((unsigned int)cnv_size.get_width(), (unsigned int)cnv_size.get_height()); - if (m_canvas != nullptr) - m_canvas->Refresh(); + + // Because of performance problems on macOS, where PaintEvents are not delivered + // frequently enough, we call render() here directly when we can. + // We can't do that when m_force_zoom_to_bed_enabled == true, because then render() + // ends up calling back here via _force_zoom_to_bed(), causing a stack overflow. + if (m_canvas != nullptr) { + m_force_zoom_to_bed_enabled ? m_canvas->Refresh() : render(); + } } }