瀏覽代碼

Added a check in sort_custom thats test wether the given method exists.

Added a check in sort_custom thats test wether the given method exists.
DualMatrix 7 年之前
父節點
當前提交
6415454581
共有 1 個文件被更改,包括 1 次插入0 次删除
  1. 1 0
      core/array.cpp

+ 1 - 0
core/array.cpp

@@ -258,6 +258,7 @@ struct _ArrayVariantSortCustom {
 Array &Array::sort_custom(Object *p_obj, const StringName &p_function) {
 Array &Array::sort_custom(Object *p_obj, const StringName &p_function) {
 
 
 	ERR_FAIL_NULL_V(p_obj, *this);
 	ERR_FAIL_NULL_V(p_obj, *this);
+	ERR_FAIL_COND_V(!p_obj->has_method(p_function), *this);
 
 
 	SortArray<Variant, _ArrayVariantSortCustom, true> avs;
 	SortArray<Variant, _ArrayVariantSortCustom, true> avs;
 	avs.compare.obj = p_obj;
 	avs.compare.obj = p_obj;