mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-17 06:00:03 +02:00
Avoid potential UB in loggers using composition
This cast would work fine, but any other fields added to those loggers would be left uninitialized.
This commit is contained in:
@@ -33,10 +33,24 @@
|
||||
std::optional<std::string> opcode_to_string(bool is_dispatch, int opcode);
|
||||
|
||||
/**
|
||||
* Provides VST2 specific logging functionality for debugging plugins.
|
||||
* Wraps around `Logger` to provide VST2 specific logging functionality for
|
||||
* debugging plugins. This way we can have all the complex initialisation be
|
||||
* performed in one place.
|
||||
*/
|
||||
class Vst2Logger : public Logger {
|
||||
class Vst2Logger {
|
||||
public:
|
||||
Vst2Logger(Logger& generic_logger);
|
||||
|
||||
/**
|
||||
* @see Logger::log
|
||||
*/
|
||||
inline void log(const std::string& message) { logger.log(message); }
|
||||
|
||||
/**
|
||||
* @see Logger::log_trace
|
||||
*/
|
||||
inline void log_trace(const std::string& message) { logger.log(message); }
|
||||
|
||||
// The following functions are for logging specific events, they are only
|
||||
// enabled for verbosity levels higher than 1 (i.e. `Verbosity::events`)
|
||||
void log_get_parameter(int index);
|
||||
@@ -60,6 +74,11 @@ class Vst2Logger : public Logger {
|
||||
const EventResultPayload& payload,
|
||||
const std::optional<EventResultPayload>& value_payload);
|
||||
|
||||
/**
|
||||
* The underlying logger instance we're wrapping.
|
||||
*/
|
||||
Logger& logger;
|
||||
|
||||
private:
|
||||
/**
|
||||
* Determine whether an event should be filtered based on the current
|
||||
|
||||
Reference in New Issue
Block a user