Workaround to remove crash when closing PrusaSlicer on OSX 10.9.5

This commit is contained in:
Enrico Turri 2020-02-27 14:55:27 +01:00
parent abca180f9f
commit d6b86b5e2b
3 changed files with 48 additions and 2 deletions

View File

@ -43,9 +43,11 @@
//================== //==================
// 2.2.0.beta1 techs // 2.2.0.rc1 techs
//================== //==================
#define ENABLE_2_2_0_BETA1 1 #define ENABLE_2_2_0_RC1 1
// Enable hack to remove crash when closing on OSX 10.9.5
#define ENABLE_HACK_CLOSING_ON_OSX_10_9_5 (1 && ENABLE_2_2_0_RC1)
#endif // _technologies_h_ #endif // _technologies_h_

View File

@ -16,6 +16,11 @@
#include <string> #include <string>
#include <iostream> #include <iostream>
#if ENABLE_HACK_CLOSING_ON_OSX_10_9_5
// Part of temporary hack to remove crash when closing on OSX 10.9.5
#include <wx/platinfo.h>
#endif // ENABLE_HACK_CLOSING_ON_OSX_10_9_5
#ifdef __APPLE__ #ifdef __APPLE__
#include "../Utils/MacDarkMode.hpp" #include "../Utils/MacDarkMode.hpp"
#endif // __APPLE__ #endif // __APPLE__
@ -192,6 +197,11 @@ GLCanvas3DManager::EMultisampleState GLCanvas3DManager::s_multisample = GLCanvas
bool GLCanvas3DManager::s_compressed_textures_supported = false; bool GLCanvas3DManager::s_compressed_textures_supported = false;
GLCanvas3DManager::EFramebufferType GLCanvas3DManager::s_framebuffers_type = GLCanvas3DManager::FB_None; GLCanvas3DManager::EFramebufferType GLCanvas3DManager::s_framebuffers_type = GLCanvas3DManager::FB_None;
GLCanvas3DManager::GLInfo GLCanvas3DManager::s_gl_info; GLCanvas3DManager::GLInfo GLCanvas3DManager::s_gl_info;
#if ENABLE_HACK_CLOSING_ON_OSX_10_9_5
#ifdef __APPLE__
GLCanvas3DManager::OSInfo GLCanvas3DManager::s_os_info;
#endif // __APPLE__
#endif // ENABLE_HACK_CLOSING_ON_OSX_10_9_5
GLCanvas3DManager::GLCanvas3DManager() GLCanvas3DManager::GLCanvas3DManager()
: m_context(nullptr) : m_context(nullptr)
@ -223,6 +233,15 @@ bool GLCanvas3DManager::add(wxGLCanvas* canvas, Bed3D& bed, Camera& camera, GLTo
m_context = new wxGLContext(canvas); m_context = new wxGLContext(canvas);
if (m_context == nullptr) if (m_context == nullptr)
return false; return false;
#if ENABLE_HACK_CLOSING_ON_OSX_10_9_5
#ifdef __APPLE__
// Part of temporary hack to remove crash when closing on OSX 10.9.5
s_os_info.major = wxPlatformInfo::Get().GetOSMajorVersion();
s_os_info.minor = wxPlatformInfo::Get().GetOSMinorVersion();
s_os_info.micro = wxPlatformInfo::Get().GetOSMicroVersion();
#endif //__APPLE__
#endif // ENABLE_HACK_CLOSING_ON_OSX_10_9_5
} }
canvas3D->set_context(m_context); canvas3D->set_context(m_context);
@ -307,6 +326,15 @@ void GLCanvas3DManager::destroy()
{ {
if (m_context != nullptr) if (m_context != nullptr)
{ {
#if ENABLE_HACK_CLOSING_ON_OSX_10_9_5
#ifdef __APPLE__
// this is a temporary ugly hack to solve the crash happening when closing the application on OSX 10.9.5
// the crash is inside wxGLContext destructor
if (s_os_info.major == 10 && s_os_info.minor == 9 && s_os_info.micro == 5)
return;
#endif //__APPLE__
#endif // ENABLE_HACK_CLOSING_ON_OSX_10_9_5
delete m_context; delete m_context;
m_context = nullptr; m_context = nullptr;
} }

View File

@ -68,6 +68,17 @@ public:
void detect() const; void detect() const;
}; };
#if ENABLE_HACK_CLOSING_ON_OSX_10_9_5
#ifdef __APPLE__
struct OSInfo
{
int major{ 0 };
int minor{ 0 };
int micro{ 0 };
};
#endif //__APPLE__
#endif // ENABLE_HACK_CLOSING_ON_OSX_10_9_5
private: private:
enum EMultisampleState : unsigned char enum EMultisampleState : unsigned char
{ {
@ -81,6 +92,11 @@ private:
CanvasesMap m_canvases; CanvasesMap m_canvases;
wxGLContext* m_context; wxGLContext* m_context;
static GLInfo s_gl_info; static GLInfo s_gl_info;
#if ENABLE_HACK_CLOSING_ON_OSX_10_9_5
#ifdef __APPLE__
static OSInfo s_os_info;
#endif //__APPLE__
#endif // ENABLE_HACK_CLOSING_ON_OSX_10_9_5
bool m_gl_initialized; bool m_gl_initialized;
static EMultisampleState s_multisample; static EMultisampleState s_multisample;
static bool s_compressed_textures_supported; static bool s_compressed_textures_supported;