Prevent crash when setting a PSF texture for Stars that didn't exist (closes #1222)

This commit is contained in:
Alexander Bock
2020-10-20 23:46:42 +02:00
parent 03a29eaf2d
commit 1eea6eedeb

View File

@@ -42,6 +42,7 @@
#include <ghoul/opengl/textureunit.h>
#include <array>
#include <cstdint>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <limits>
@@ -688,7 +689,7 @@ RenderableStars::RenderableStars(const ghoul::Dictionary& dictionary)
RenderableStars::~RenderableStars() {}
bool RenderableStars::isReady() const {
return _program != nullptr;
return _program && _pointSpreadFunctionTexture;
}
void RenderableStars::initializeGL() {
@@ -1214,7 +1215,9 @@ void RenderableStars::update(const UpdateData&) {
if (_pointSpreadFunctionTextureIsDirty) {
LDEBUG("Reloading Point Spread Function texture");
_pointSpreadFunctionTexture = nullptr;
if (!_pointSpreadFunctionTexturePath.value().empty()) {
if (!_pointSpreadFunctionTexturePath.value().empty() &&
std::filesystem::exists(_pointSpreadFunctionTexturePath.value()))
{
_pointSpreadFunctionTexture = ghoul::io::TextureReader::ref().loadTexture(
absPath(_pointSpreadFunctionTexturePath)
);