From dc55105000dfbb4ab91b920b031636c8fbae72ac Mon Sep 17 00:00:00 2001 From: Malin E Date: Mon, 29 Aug 2022 13:13:47 +0200 Subject: [PATCH] Move loading of data error handling --- .../rendering/renderableconstellationbounds.cpp | 12 ++++++++++-- .../space/rendering/renderableconstellationbounds.h | 1 + .../space/rendering/renderableconstellationlines.cpp | 12 +++++++----- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/modules/space/rendering/renderableconstellationbounds.cpp b/modules/space/rendering/renderableconstellationbounds.cpp index 7972203696..2dc8eea9c0 100644 --- a/modules/space/rendering/renderableconstellationbounds.cpp +++ b/modules/space/rendering/renderableconstellationbounds.cpp @@ -81,7 +81,7 @@ RenderableConstellationBounds::RenderableConstellationBounds( // Avoid reading files here, instead do it in multithreaded initialize() _vertexFilename = absPath(p.file.string()).string(); - _vertexFilename.onChange([&](){ loadVertexFile(); }); + _vertexFilename.onChange([&](){ loadData(); }); addProperty(_vertexFilename); _color.setViewOption(properties::Property::ViewOptions::Color); @@ -92,7 +92,7 @@ RenderableConstellationBounds::RenderableConstellationBounds( void RenderableConstellationBounds::initialize() { RenderableConstellationsBase::initialize(); - loadVertexFile(); + loadData(); if (!_assetSelection.empty()) { const std::vector options = _selection.options(); @@ -198,6 +198,14 @@ void RenderableConstellationBounds::render(const RenderData& data, RendererTasks void RenderableConstellationBounds::update(const UpdateData& data) { } +bool RenderableConstellationBounds::loadData() { + bool success = loadVertexFile(); + if (!success) { + throw ghoul::RuntimeError("Error loading data"); + } + return success; +} + bool RenderableConstellationBounds::loadVertexFile() { if (_vertexFilename.value().empty()) { return false; diff --git a/modules/space/rendering/renderableconstellationbounds.h b/modules/space/rendering/renderableconstellationbounds.h index b5fcefe299..e5fda8c9d6 100644 --- a/modules/space/rendering/renderableconstellationbounds.h +++ b/modules/space/rendering/renderableconstellationbounds.h @@ -75,6 +75,7 @@ private: * \return \c true if the loading succeeded, \c false otherwise */ bool loadVertexFile(); + bool loadData(); /** * Callback method that gets triggered when _constellationSelection diff --git a/modules/space/rendering/renderableconstellationlines.cpp b/modules/space/rendering/renderableconstellationlines.cpp index 4b5c2d100c..baf6343591 100644 --- a/modules/space/rendering/renderableconstellationlines.cpp +++ b/modules/space/rendering/renderableconstellationlines.cpp @@ -101,6 +101,7 @@ RenderableConstellationLines::RenderableConstellationLines( const Parameters p = codegen::bake(dictionary); _speckFile = absPath(p.file); + addProperty(_drawElements); if (p.lineUnit.has_value()) { @@ -150,10 +151,7 @@ bool RenderableConstellationLines::isReady() const { void RenderableConstellationLines::initialize() { RenderableConstellationsBase::initialize(); - bool success = loadData(); - if (!success) { - throw ghoul::RuntimeError("Error loading data"); - } + loadData(); if (!_assetSelection.empty()) { const std::vector options = _selection.options(); @@ -268,7 +266,11 @@ void RenderableConstellationLines::update(const UpdateData&) { } bool RenderableConstellationLines::loadData() { - return readSpeckFile(); + bool success = readSpeckFile(); + if (!success) { + throw ghoul::RuntimeError("Error loading data"); + } + return success; } bool RenderableConstellationLines::readSpeckFile() {