diff --git a/app/common/CMakeLists.txt b/app/common/CMakeLists.txt index 549c803ee..9c840f53f 100644 --- a/app/common/CMakeLists.txt +++ b/app/common/CMakeLists.txt @@ -18,6 +18,8 @@ set(OLIVE_SOURCES ${OLIVE_SOURCES} common/channellayout.h common/clamp.h + common/debug.h + common/debug.cpp common/filefunctions.h common/filefunctions.cpp common/lerp.h diff --git a/app/common/debug.cpp b/app/common/debug.cpp new file mode 100644 index 000000000..a00555acb --- /dev/null +++ b/app/common/debug.cpp @@ -0,0 +1,28 @@ +#include "debug.h" + + +void DebugHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg) +{ + QByteArray localMsg = msg.toLocal8Bit(); + + const char* msg_type; + switch (type) { + case QtDebugMsg: + msg_type = "DEBUG"; + break; + case QtInfoMsg: + msg_type = "INFO"; + break; + case QtWarningMsg: + msg_type = "WARNING"; + break; + case QtCriticalMsg: + msg_type = "ERROR"; + break; + case QtFatalMsg: + msg_type = "FATAL"; + break; + } + + fprintf(stderr, "[%s] %s (%s:%u)\n", msg_type, localMsg.constData(), context.function, context.line); +} diff --git a/app/common/debug.h b/app/common/debug.h new file mode 100644 index 000000000..39446adb8 --- /dev/null +++ b/app/common/debug.h @@ -0,0 +1,8 @@ +#ifndef DEBUG_H +#define DEBUG_H + +#include + +void DebugHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg); + +#endif // DEBUG_H diff --git a/app/main.cpp b/app/main.cpp index ab1ecc787..11ef2ff0c 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -35,6 +35,7 @@ extern "C" { #include #include "core.h" +#include "common/debug.h" int main(int argc, char *argv[]) { // Create application instance @@ -57,6 +58,9 @@ int main(int argc, char *argv[]) { QGuiApplication::setDesktopFileName("org.olivevideoeditor.Olive"); #endif + // Set up debug handler + qInstallMessageHandler(DebugHandler); + // Set OpenGL display profile (3.2 Core) QSurfaceFormat format; format.setVersion(3, 2); diff --git a/app/node/output.cpp b/app/node/output.cpp index 1eeba7a6c..0d33ffb93 100644 --- a/app/node/output.cpp +++ b/app/node/output.cpp @@ -59,6 +59,8 @@ void NodeOutput::set_data_type(const NodeParam::DataType &type) QVariant NodeOutput::get_value(const rational& time) { + mutex_.lock(); + QVariant v; if (time_ != time || !value_caching_) { @@ -70,6 +72,8 @@ QVariant NodeOutput::get_value(const rational& time) v = value_; + mutex_.unlock(); + return v; } diff --git a/app/node/output.h b/app/node/output.h index b3cfb8f8d..7d4ff7e82 100644 --- a/app/node/output.h +++ b/app/node/output.h @@ -68,6 +68,8 @@ public: private: DataType data_type_; + QMutex mutex_; + }; #endif // NODEOUTPUT_H diff --git a/app/node/processor/renderer/renderer.cpp b/app/node/processor/renderer/renderer.cpp index 477268fcf..d2b3bb376 100644 --- a/app/node/processor/renderer/renderer.cpp +++ b/app/node/processor/renderer/renderer.cpp @@ -139,7 +139,7 @@ void RendererProcessor::InvalidateCache(const rational &start_range, const ratio rational start_range_adj = qMax(rational(0), start_range); rational end_range_adj = qMin(length_input()->get_value(0).value(), end_range); - qDebug() << "[RendererProcessor] Cache invalidated between" + qDebug() << "Cache invalidated between" << start_range_adj.toDouble() << "and" << end_range_adj.toDouble(); @@ -359,7 +359,7 @@ void RendererProcessor::CacheNext() rational cache_frame = cache_queue_.takeFirst(); - qDebug() << "[RendererProcessor] Caching" << cache_frame.toDouble(); + qDebug() << "Caching" << cache_frame.toDouble(); threads_.first()->Queue(NodeDependency(texture_input_->get_connected_output(), cache_frame), true); diff --git a/app/node/processor/renderer/rendererthreadbase.cpp b/app/node/processor/renderer/rendererthreadbase.cpp index cd744229c..6a20a237a 100644 --- a/app/node/processor/renderer/rendererthreadbase.cpp +++ b/app/node/processor/renderer/rendererthreadbase.cpp @@ -54,13 +54,9 @@ void RendererThreadBase::run() instance.SetShareContext(share_ctx_); - qDebug() << this << "is starting its OpenGL context"; - // Allocate and create resources if (instance.Start()) { - qDebug() << this << "OpenGL context creation succeeded"; - // Main loop (use Cancel() to exit it) ProcessLoop();