Fix import and saving related crashes
* Don't add empty mesh to result when importing obj files * Check for null resources in `ResourceSaver`
This commit is contained in:
parent
4a0160241f
commit
49ae632b7d
|
@ -152,12 +152,10 @@ void ResourceLoader::_bind_methods() {
|
||||||
////// ResourceSaver //////
|
////// ResourceSaver //////
|
||||||
|
|
||||||
Error ResourceSaver::save(const Ref<Resource> &p_resource, const String &p_path, BitField<SaverFlags> p_flags) {
|
Error ResourceSaver::save(const Ref<Resource> &p_resource, const String &p_path, BitField<SaverFlags> p_flags) {
|
||||||
ERR_FAIL_COND_V_MSG(p_resource.is_null(), ERR_INVALID_PARAMETER, "Can't save empty resource to path '" + p_path + "'.");
|
|
||||||
return ::ResourceSaver::save(p_resource, p_path, p_flags);
|
return ::ResourceSaver::save(p_resource, p_path, p_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<String> ResourceSaver::get_recognized_extensions(const Ref<Resource> &p_resource) {
|
Vector<String> ResourceSaver::get_recognized_extensions(const Ref<Resource> &p_resource) {
|
||||||
ERR_FAIL_COND_V_MSG(p_resource.is_null(), Vector<String>(), "It's not a reference to a valid Resource object.");
|
|
||||||
List<String> exts;
|
List<String> exts;
|
||||||
::ResourceSaver::get_recognized_extensions(p_resource, &exts);
|
::ResourceSaver::get_recognized_extensions(p_resource, &exts);
|
||||||
Vector<String> ret;
|
Vector<String> ret;
|
||||||
|
|
|
@ -98,6 +98,7 @@ void ResourceFormatSaver::_bind_methods() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Error ResourceSaver::save(const Ref<Resource> &p_resource, const String &p_path, uint32_t p_flags) {
|
Error ResourceSaver::save(const Ref<Resource> &p_resource, const String &p_path, uint32_t p_flags) {
|
||||||
|
ERR_FAIL_COND_V_MSG(p_resource.is_null(), ERR_INVALID_PARAMETER, "Can't save empty resource to path '" + p_path + "'.");
|
||||||
String path = p_path;
|
String path = p_path;
|
||||||
if (path.is_empty()) {
|
if (path.is_empty()) {
|
||||||
path = p_resource->get_path();
|
path = p_resource->get_path();
|
||||||
|
@ -174,6 +175,7 @@ void ResourceSaver::set_save_callback(ResourceSavedCallback p_callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResourceSaver::get_recognized_extensions(const Ref<Resource> &p_resource, List<String> *p_extensions) {
|
void ResourceSaver::get_recognized_extensions(const Ref<Resource> &p_resource, List<String> *p_extensions) {
|
||||||
|
ERR_FAIL_COND_MSG(p_resource.is_null(), "It's not a reference to a valid Resource object.");
|
||||||
for (int i = 0; i < saver_count; i++) {
|
for (int i = 0; i < saver_count; i++) {
|
||||||
saver[i]->get_recognized_extensions(p_resource, p_extensions);
|
saver[i]->get_recognized_extensions(p_resource, p_extensions);
|
||||||
}
|
}
|
||||||
|
|
|
@ -497,7 +497,7 @@ static Error _parse_obj(const String &p_path, List<Ref<ImporterMesh>> &r_meshes,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_single_mesh) {
|
if (p_single_mesh && mesh->get_surface_count() > 0) {
|
||||||
r_meshes.push_back(mesh);
|
r_meshes.push_back(mesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue