From 7624c46f190ebd8d5740479a282b3f7b43b56b03 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Mon, 22 Apr 2019 09:56:07 -0400 Subject: [PATCH] Add assertions for 0-width ModuleWidgets. Add warning if framebuffer cannot be created in FramebufferWidget. --- include/widget/Widget.hpp | 2 +- src/app/RackWidget.cpp | 2 ++ src/widget/FramebufferWidget.cpp | 8 ++++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/widget/Widget.hpp b/include/widget/Widget.hpp index 93d3f343..681c29c2 100644 --- a/include/widget/Widget.hpp +++ b/include/widget/Widget.hpp @@ -136,7 +136,7 @@ struct Widget { } /** Override these event callbacks to respond to events. - See events.hpp for a description of each event. + See event.hpp for a description of each event. */ virtual void onHover(const event::Hover &e) {recursePositionEvent(&Widget::onHover, e);} virtual void onButton(const event::Button &e) {recursePositionEvent(&Widget::onButton, e);} diff --git a/src/app/RackWidget.cpp b/src/app/RackWidget.cpp index ddc8cdbf..ddcf2ca5 100644 --- a/src/app/RackWidget.cpp +++ b/src/app/RackWidget.cpp @@ -358,6 +358,8 @@ static void RackWidget_updateAdjacent(RackWidget *that) { void RackWidget::addModule(ModuleWidget *m) { // Add module to ModuleContainer assert(m); + // Module must be 3U high and at least 1HP wide + assert(m->box.size.x >= RACK_GRID_WIDTH); assert(m->box.size.y == RACK_GRID_HEIGHT); moduleContainer->addChild(m); diff --git a/src/widget/FramebufferWidget.cpp b/src/widget/FramebufferWidget.cpp index d75e219b..7da418ce 100644 --- a/src/widget/FramebufferWidget.cpp +++ b/src/widget/FramebufferWidget.cpp @@ -70,8 +70,10 @@ void FramebufferWidget::step() { fb = nvgluCreateFramebuffer(vg, fbSize.x * oversample, fbSize.y * oversample, 0); } - if (!fb) + if (!fb) { + WARN("Framebuffer of size (%f, %f) * %f could not be created for FramebufferWidget", VEC_ARGS(fbSize), oversample); return; + } nvgluBindFramebuffer(fb); drawFramebuffer(); @@ -80,8 +82,10 @@ void FramebufferWidget::step() { // If oversampling, create another framebuffer and copy it to actual size. if (oversample != 1.0) { NVGLUframebuffer *newFb = nvgluCreateFramebuffer(vg, fbSize.x, fbSize.y, 0); - if (!newFb) + if (!newFb) { + WARN("Non-oversampled framebuffer of size (%f, %f) could not be created for FramebufferWidget", VEC_ARGS(fbSize)); return; + } // Use NanoVG for resizing framebuffers nvgluBindFramebuffer(newFb);