From 118dd478e7a467619e1cc1092480523984d2125d Mon Sep 17 00:00:00 2001 From: Marcelo Fernandez Date: Tue, 5 Sep 2017 00:55:09 -0300 Subject: [PATCH] Fix crash when editing SampleLibrary with broken dependencies --- editor/plugins/sample_editor_plugin.cpp | 3 +++ editor/plugins/sample_library_editor_plugin.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/editor/plugins/sample_editor_plugin.cpp b/editor/plugins/sample_editor_plugin.cpp index 454698fa04c..3edcce2d734 100644 --- a/editor/plugins/sample_editor_plugin.cpp +++ b/editor/plugins/sample_editor_plugin.cpp @@ -69,6 +69,9 @@ void SampleEditor::_stop_pressed() { void SampleEditor::generate_preview_texture(const Ref &p_sample, Ref &p_texture) { + if (p_sample == NULL) + return; + DVector data = p_sample->get_data(); DVector img; diff --git a/editor/plugins/sample_library_editor_plugin.cpp b/editor/plugins/sample_library_editor_plugin.cpp index 5b3f8380e77..084397efeec 100644 --- a/editor/plugins/sample_library_editor_plugin.cpp +++ b/editor/plugins/sample_library_editor_plugin.cpp @@ -238,7 +238,7 @@ void SampleLibraryEditor::_update_library() { ti->set_cell_mode(2, TreeItem::CELL_MODE_STRING); ti->set_editable(2, false); ti->set_selectable(2, false); - ti->set_text(2, String() + (smp->get_format() == Sample::FORMAT_PCM16 ? TTR("16 Bits") + ", " : (smp->get_format() == Sample::FORMAT_PCM8 ? TTR("8 Bits") + ", " : "IMA-ADPCM,")) + (smp->is_stereo() ? TTR("Stereo") : TTR("Mono"))); + ti->set_text(2, String() + (smp != NULL ? (smp->get_format() == Sample::FORMAT_PCM16 ? TTR("16 Bits") + ", " : (smp->get_format() == Sample::FORMAT_PCM8 ? TTR("8 Bits") + ", " : "IMA-ADPCM,")) + (smp->is_stereo() ? TTR("Stereo") : TTR("Mono")) : TTR("Invalid"))); // Volume dB ti->set_cell_mode(3, TreeItem::CELL_MODE_RANGE);