Skip to content

Commit 3f4a546

Browse files
committed
Avoid segfault when failing to create materials
1 parent 0d7aa66 commit 3f4a546

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/gui_backdrop.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ void backdrop::set_background(const std::string& background_file) {
5757

5858
auto& renderer = parent_.get_manager().get_renderer();
5959
background_texture_ = renderer.create_atlas_material("GUI", background_file);
60+
if (!background_texture_) {
61+
return;
62+
}
6063

6164
tile_size_ = original_tile_size_ = static_cast<float>(background_texture_->get_rect().width());
6265
background_file_ = background_file;
@@ -157,6 +160,9 @@ void backdrop::set_edge(const std::string& edge_file) {
157160

158161
auto& renderer = parent_.get_manager().get_renderer();
159162
edge_texture_ = renderer.create_atlas_material("GUI", edge_file);
163+
if (!edge_texture_) {
164+
return;
165+
}
160166

161167
if (edge_texture_->get_rect().width() / edge_texture_->get_rect().height() != 8.0f) {
162168
edge_texture_ = nullptr;

0 commit comments

Comments
 (0)