Browse Source

Add new CARLA_CUSTOM_SAFE_ASSERT

Signed-off-by: falkTX <falktx@falktx.com>
tags/v2.2.0-RC1
falkTX 4 years ago
parent
commit
8f27bff6c4
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
4 changed files with 16 additions and 9 deletions
  1. +1
    -8
      source/backend/engine/CarlaEngine.cpp
  2. +1
    -1
      source/discovery/carla-discovery.cpp
  3. +4
    -0
      source/includes/CarlaDefines.h
  4. +10
    -0
      source/utils/CarlaUtils.hpp

+ 1
- 8
source/backend/engine/CarlaEngine.cpp View File

@@ -1394,14 +1394,7 @@ void CarlaEngine::callback(const bool sendHost, const bool sendOSC,

try {
pData->callback(pData->callbackPtr, action, pluginId, value1, value2, value3, valuef, valueStr);
#if defined(CARLA_OS_LINUX) && defined(__arm__)
} catch (__cxxabiv1::__forced_unwind&) {
carla_stderr2("Caught forced unwind exception in callback");
throw;
#endif
} catch (...) {
carla_safe_exception("callback", __FILE__, __LINE__);
}
} CARLA_SAFE_EXCEPTION("callback")

if (action == ENGINE_CALLBACK_IDLE)
--pData->isIdling;


+ 1
- 1
source/discovery/carla-discovery.cpp View File

@@ -1421,7 +1421,7 @@ static void do_juce_check(const char* const filename_, const char* const stype,
}

#ifdef CARLA_OS_WIN
CARLA_SAFE_ASSERT_RETURN(juce::File(filename).existsAsFile(),);
CARLA_CUSTOM_SAFE_ASSERT_RETURN("Plugin file/folder does not exist", juce::File(filename).exists(),);
#endif
CARLA_SAFE_ASSERT_RETURN(pluginFormat->fileMightContainThisPluginType(filename),);



+ 4
- 0
source/includes/CarlaDefines.h View File

@@ -175,6 +175,10 @@
#define CARLA_SAFE_ASSERT_CONTINUE(cond) if (! (cond)) { carla_safe_assert(#cond, __FILE__, __LINE__); continue; }
#define CARLA_SAFE_ASSERT_RETURN(cond, ret) if (! (cond)) { carla_safe_assert(#cond, __FILE__, __LINE__); return ret; }

#define CARLA_CUSTOM_SAFE_ASSERT_BREAK(msg, cond) if (! (cond)) { carla_custom_safe_assert(msg, #cond, __FILE__, __LINE__); break; }
#define CARLA_CUSTOM_SAFE_ASSERT_CONTINUE(msg, cond) if (! (cond)) { carla_custom_safe_assert(msg, #cond, __FILE__, __LINE__); continue; }
#define CARLA_CUSTOM_SAFE_ASSERT_RETURN(msg, cond, ret) if (! (cond)) { carla_custom_safe_assert(msg, #cond, __FILE__, __LINE__); return ret; }

#define CARLA_SAFE_ASSERT_INT_BREAK(cond, value) if (! (cond)) { carla_safe_assert_int(#cond, __FILE__, __LINE__, static_cast<int>(value); break; }
#define CARLA_SAFE_ASSERT_INT_CONTINUE(cond, value) if (! (cond)) { carla_safe_assert_int(#cond, __FILE__, __LINE__, static_cast<int>(value)); continue; }
#define CARLA_SAFE_ASSERT_INT_RETURN(cond, value, ret) if (! (cond)) { carla_safe_assert_int(#cond, __FILE__, __LINE__, static_cast<int>(value)); return ret; }


+ 10
- 0
source/utils/CarlaUtils.hpp View File

@@ -251,6 +251,16 @@ void carla_safe_assert_uint2(const char* const assertion, const char* const file
carla_stderr2("Carla assertion failure: \"%s\" in file %s, line %i, v1 %u, v2 %u", assertion, file, line, v1, v2);
}

/*
* Print a safe assertion error message, with a custom error message.
*/
static inline
void carla_custom_safe_assert(const char* const message,
const char* const assertion, const char* const file, const int line) noexcept
{
carla_stderr2("%s, condition \"%s\" in file %s, line %i", message, assertion, file, line);
}

// --------------------------------------------------------------------------------------------------------------------
// carla_safe_exception*



Loading…
Cancel
Save