diff --git a/server/TracyTexture.cpp b/server/TracyTexture.cpp index f17d6f17..fcac8053 100644 --- a/server/TracyTexture.cpp +++ b/server/TracyTexture.cpp @@ -21,10 +21,10 @@ void* MakeTexture() return (void*)(intptr_t)tex; } -void FreeTexture( void* _tex ) +void FreeTexture( void* _tex, void(*runOnMainThread)(std::function) ) { auto tex = (GLuint)(intptr_t)_tex; - glDeleteTextures( 1, &tex ); + runOnMainThread( [tex] { glDeleteTextures( 1, &tex ); } ); } void UpdateTexture( void* _tex, const char* data, int w, int h ) diff --git a/server/TracyTexture.hpp b/server/TracyTexture.hpp index 87e03f04..fbaa5d62 100644 --- a/server/TracyTexture.hpp +++ b/server/TracyTexture.hpp @@ -1,11 +1,13 @@ #ifndef __TRACYTEXTURE_HPP__ #define __TRACYTEXTURE_HPP__ +#include + namespace tracy { void* MakeTexture(); -void FreeTexture( void* tex ); +void FreeTexture( void* tex, void(*runOnMainThread)(std::function) ); void UpdateTexture( void* tex, const char* data, int w, int h ); } diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 8276c21f..9803910b 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -192,8 +192,8 @@ View::~View() if( m_compare.loadThread.joinable() ) m_compare.loadThread.join(); if( m_saveThread.joinable() ) m_saveThread.join(); - if( m_frameTexture ) FreeTexture( m_frameTexture ); - if( m_playback.texture ) FreeTexture( m_playback.texture ); + if( m_frameTexture ) FreeTexture( m_frameTexture, m_cbMainThread ); + if( m_playback.texture ) FreeTexture( m_playback.texture, m_cbMainThread ); assert( s_instance != nullptr ); s_instance = nullptr;