From 33a661fe0e64cf14f4cd9832286b3010c70315fe Mon Sep 17 00:00:00 2001 From: falkTX Date: Fri, 27 Aug 2021 16:27:29 +0100 Subject: [PATCH] Less annoying nanovg error logs when it fails to initialize --- dgl/src/NanoVG.cpp | 4 ++-- tests/NanoSubWidgets.cpp | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/dgl/src/NanoVG.cpp b/dgl/src/NanoVG.cpp index d6c78f1e..beaf2722 100644 --- a/dgl/src/NanoVG.cpp +++ b/dgl/src/NanoVG.cpp @@ -280,12 +280,12 @@ NanoVG::~NanoVG() void NanoVG::beginFrame(const uint width, const uint height, const float scaleFactor) { - if (fContext == nullptr) return; DISTRHO_SAFE_ASSERT_RETURN(scaleFactor > 0.0f,); DISTRHO_SAFE_ASSERT_RETURN(! fInFrame,); fInFrame = true; - nvgBeginFrame(fContext, static_cast(width), static_cast(height), scaleFactor); + if (fContext != nullptr) + nvgBeginFrame(fContext, static_cast(width), static_cast(height), scaleFactor); } void NanoVG::beginFrame(Widget* const widget) diff --git a/tests/NanoSubWidgets.cpp b/tests/NanoSubWidgets.cpp index 267d5878..1f205407 100644 --- a/tests/NanoSubWidgets.cpp +++ b/tests/NanoSubWidgets.cpp @@ -132,8 +132,11 @@ public: { const uint targetWidth = 400; const uint targetHeight = 400; + const double scaleFactor = getScaleFactor(); - setSize(targetWidth, targetHeight); + setGeometryConstraints(targetWidth, targetHeight, true); + setResizable(true); + setSize(targetWidth * scaleFactor, targetHeight * scaleFactor); setTitle("NanoVG SubWidgets test"); }