diff options
author | Hein-Pieter van Braam <hp@tmm.cx> | 2017-08-24 22:58:51 +0200 |
---|---|---|
committer | Hein-Pieter van Braam <hp@tmm.cx> | 2017-08-24 23:08:24 +0200 |
commit | cacced7e507f7603bacc03ae2616e58f0ede122a (patch) | |
tree | 7af89373e86cd1a7af6ea04e10280084cabb7144 /editor/plugins/sample_library_editor_plugin.cpp | |
parent | 4aa2c18cb428ffde05c67987926736a9ca62703b (diff) | |
download | redot-engine-cacced7e507f7603bacc03ae2616e58f0ede122a.tar.gz |
Convert Object::cast_to() to the static version
Currently we rely on some undefined behavior when Object->cast_to() gets
called with a Null pointer. This used to work fine with GCC < 6 but
newer versions of GCC remove all codepaths in which the this pointer is
Null. However, the non-static cast_to() was supposed to be null safe.
This patch makes cast_to() Null safe and removes the now redundant Null
checks where they existed.
It is explained in this article: https://www.viva64.com/en/b/0226/
Diffstat (limited to 'editor/plugins/sample_library_editor_plugin.cpp')
-rw-r--r-- | editor/plugins/sample_library_editor_plugin.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/editor/plugins/sample_library_editor_plugin.cpp b/editor/plugins/sample_library_editor_plugin.cpp index 3deb634491..761301610e 100644 --- a/editor/plugins/sample_library_editor_plugin.cpp +++ b/editor/plugins/sample_library_editor_plugin.cpp @@ -47,7 +47,7 @@ void SampleLibraryEditor::_notification(int p_what) { if (p_what==NOTIFICATION_PROCESS) { if (is_playing && !player->is_active()) { - TreeItem *tl=last_sample_playing->cast_to<TreeItem>(); + TreeItem *tl=Object::cast_to<TreeItem>(last_sample_playing); tl->set_button(0,0,get_icon("Play","EditorIcons")); is_playing = false; set_process(false); @@ -109,7 +109,7 @@ void SampleLibraryEditor::_load_pressed() { void SampleLibraryEditor::_button_pressed(Object *p_item,int p_column, int p_id) { - TreeItem *ti=p_item->cast_to<TreeItem>(); + TreeItem *ti=Object::cast_to<TreeItem>(p_item); String name = ti->get_text(0); if (p_column==0) { // Play/Stop @@ -124,7 +124,7 @@ void SampleLibraryEditor::_button_pressed(Object *p_item,int p_column, int p_id) } else { player->stop_all(); if(last_sample_playing != p_item){ - TreeItem *tl=last_sample_playing->cast_to<TreeItem>(); + TreeItem *tl=Object::cast_to<TreeItem>(last_sample_playing); tl->set_button(p_column,0,get_icon("Play","EditorIcons")); btn_type = TTR("Stop"); player->play(name,true); @@ -491,7 +491,7 @@ SampleLibraryEditor::SampleLibraryEditor() { void SampleLibraryEditorPlugin::edit(Object *p_object) { sample_library_editor->set_undo_redo(&get_undo_redo()); - SampleLibrary * s = p_object->cast_to<SampleLibrary>(); + SampleLibrary * s = Object::cast_to<SampleLibrary>(p_object); if (!s) return; |