added custom debug handler

This commit is contained in:
itsmattkc
2019-09-10 23:44:35 +10:00
parent 69ca2b2a50
commit 6dc62a8703
8 changed files with 50 additions and 6 deletions
+2
View File
@@ -18,6 +18,8 @@ set(OLIVE_SOURCES
${OLIVE_SOURCES} ${OLIVE_SOURCES}
common/channellayout.h common/channellayout.h
common/clamp.h common/clamp.h
common/debug.h
common/debug.cpp
common/filefunctions.h common/filefunctions.h
common/filefunctions.cpp common/filefunctions.cpp
common/lerp.h common/lerp.h
+28
View File
@@ -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);
}
+8
View File
@@ -0,0 +1,8 @@
#ifndef DEBUG_H
#define DEBUG_H
#include <QDebug>
void DebugHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg);
#endif // DEBUG_H
+4
View File
@@ -35,6 +35,7 @@ extern "C" {
#include <QSurfaceFormat> #include <QSurfaceFormat>
#include "core.h" #include "core.h"
#include "common/debug.h"
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
// Create application instance // Create application instance
@@ -57,6 +58,9 @@ int main(int argc, char *argv[]) {
QGuiApplication::setDesktopFileName("org.olivevideoeditor.Olive"); QGuiApplication::setDesktopFileName("org.olivevideoeditor.Olive");
#endif #endif
// Set up debug handler
qInstallMessageHandler(DebugHandler);
// Set OpenGL display profile (3.2 Core) // Set OpenGL display profile (3.2 Core)
QSurfaceFormat format; QSurfaceFormat format;
format.setVersion(3, 2); format.setVersion(3, 2);
+4
View File
@@ -59,6 +59,8 @@ void NodeOutput::set_data_type(const NodeParam::DataType &type)
QVariant NodeOutput::get_value(const rational& time) QVariant NodeOutput::get_value(const rational& time)
{ {
mutex_.lock();
QVariant v; QVariant v;
if (time_ != time || !value_caching_) { if (time_ != time || !value_caching_) {
@@ -70,6 +72,8 @@ QVariant NodeOutput::get_value(const rational& time)
v = value_; v = value_;
mutex_.unlock();
return v; return v;
} }
+2
View File
@@ -68,6 +68,8 @@ public:
private: private:
DataType data_type_; DataType data_type_;
QMutex mutex_;
}; };
#endif // NODEOUTPUT_H #endif // NODEOUTPUT_H
+2 -2
View File
@@ -139,7 +139,7 @@ void RendererProcessor::InvalidateCache(const rational &start_range, const ratio
rational start_range_adj = qMax(rational(0), start_range); rational start_range_adj = qMax(rational(0), start_range);
rational end_range_adj = qMin(length_input()->get_value(0).value<rational>(), end_range); rational end_range_adj = qMin(length_input()->get_value(0).value<rational>(), end_range);
qDebug() << "[RendererProcessor] Cache invalidated between" qDebug() << "Cache invalidated between"
<< start_range_adj.toDouble() << start_range_adj.toDouble()
<< "and" << "and"
<< end_range_adj.toDouble(); << end_range_adj.toDouble();
@@ -359,7 +359,7 @@ void RendererProcessor::CacheNext()
rational cache_frame = cache_queue_.takeFirst(); 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); threads_.first()->Queue(NodeDependency(texture_input_->get_connected_output(), cache_frame), true);
@@ -54,13 +54,9 @@ void RendererThreadBase::run()
instance.SetShareContext(share_ctx_); instance.SetShareContext(share_ctx_);
qDebug() << this << "is starting its OpenGL context";
// Allocate and create resources // Allocate and create resources
if (instance.Start()) { if (instance.Start()) {
qDebug() << this << "OpenGL context creation succeeded";
// Main loop (use Cancel() to exit it) // Main loop (use Cancel() to exit it)
ProcessLoop(); ProcessLoop();