Browse Source

Prevent crashes when UI initializes too early

Signed-off-by: falkTX <falktx@falktx.com>
pull/338/head
falkTX 4 years ago
parent
commit
d9044f27fe
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
4 changed files with 30 additions and 12 deletions
  1. +5
    -1
      dgl/src/WindowPrivateData.cpp
  2. +2
    -0
      distrho/src/DistrhoUIInternal.hpp
  3. +12
    -0
      distrho/src/DistrhoUIPrivateData.hpp
  4. +11
    -11
      distrho/src/DistrhoUIVST3.cpp

+ 5
- 1
dgl/src/WindowPrivateData.cpp View File

@@ -33,7 +33,11 @@
#define DGL_DEBUG_EVENTS

#if defined(DEBUG) && defined(DGL_DEBUG_EVENTS)
# include <cinttypes>
# ifdef DISTRHO_PROPER_CPP11_SUPPORT
# include <cinttypes>
# else
# include <inttypes.h>
# endif
#endif

START_NAMESPACE_DGL


+ 2
- 0
distrho/src/DistrhoUIInternal.hpp View File

@@ -99,6 +99,8 @@ public:
DISTRHO_SAFE_ASSERT_RETURN(uiPtr != nullptr,);
ui = uiPtr;

uiData->initializing = false;

#if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI
// unused
(void)bundlePath;


+ 12
- 0
distrho/src/DistrhoUIPrivateData.hpp View File

@@ -285,6 +285,7 @@ struct UI::PrivateData {
void* dspPtr;

// UI
bool initializing;
uint bgColor;
uint fgColor;
double scaleFactor;
@@ -308,6 +309,7 @@ struct UI::PrivateData {
sampleRate(0),
parameterOffset(0),
dspPtr(nullptr),
initializing(true),
bgColor(0),
fgColor(0xffffffff),
scaleFactor(1.0),
@@ -358,30 +360,40 @@ struct UI::PrivateData {

void editParamCallback(const uint32_t rindex, const bool started)
{
DISTRHO_SAFE_ASSERT_RETURN(!initializing,);

if (editParamCallbackFunc != nullptr)
editParamCallbackFunc(callbacksPtr, rindex, started);
}

void setParamCallback(const uint32_t rindex, const float value)
{
DISTRHO_SAFE_ASSERT_RETURN(!initializing,);

if (setParamCallbackFunc != nullptr)
setParamCallbackFunc(callbacksPtr, rindex, value);
}

void setStateCallback(const char* const key, const char* const value)
{
DISTRHO_SAFE_ASSERT_RETURN(!initializing,);

if (setStateCallbackFunc != nullptr)
setStateCallbackFunc(callbacksPtr, key, value);
}

void sendNoteCallback(const uint8_t channel, const uint8_t note, const uint8_t velocity)
{
DISTRHO_SAFE_ASSERT_RETURN(!initializing,);

if (sendNoteCallbackFunc != nullptr)
sendNoteCallbackFunc(callbacksPtr, channel, note, velocity);
}

void setSizeCallback(const uint width, const uint height)
{
DISTRHO_SAFE_ASSERT_RETURN(!initializing,);

if (setSizeCallbackFunc != nullptr)
setSizeCallbackFunc(callbacksPtr, width, height);
}


+ 11
- 11
distrho/src/DistrhoUIVST3.cpp View File

@@ -486,17 +486,17 @@ private:
DISTRHO_SAFE_ASSERT_RETURN(fFrame != nullptr,);
d_stdout("from UI setSize %u %u | %p %p", width, height, fView, fFrame);

// #ifdef DISTRHO_OS_MAC
// const double scaleFactor = fUI.getScaleFactor();
// width /= scaleFactor;
// height /= scaleFactor;
// #endif
//
// v3_view_rect rect;
// std::memset(&rect, 0, sizeof(rect));
// rect.right = width;
// rect.bottom = height;
// v3_cpp_obj(fFrame)->resize_view(fFrame, fView, &rect);
#ifdef DISTRHO_OS_MAC
const double scaleFactor = fUI.getScaleFactor();
width /= scaleFactor;
height /= scaleFactor;
#endif
v3_view_rect rect;
std::memset(&rect, 0, sizeof(rect));
rect.right = width;
rect.bottom = height;
v3_cpp_obj(fFrame)->resize_view(fFrame, fView, &rect);
}

static void setSizeCallback(void* ptr, uint width, uint height)


Loading…
Cancel
Save