Skip to content

Commit e9f5bd8

Browse files
committed
Merge pull request #107355 from beicause/fix-resource-script-property-save
Fix `script` property of custom resources inherited from scripts are not saved
2 parents f400e10 + 784823a commit e9f5bd8

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

core/io/resource_format_binary.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "core/io/missing_resource.h"
3737
#include "core/object/script_language.h"
3838
#include "core/version.h"
39+
#include "scene/property_utils.h"
3940
#include "scene/resources/packed_scene.h"
4041

4142
//#define print_bl(m_what) print_line(m_what)
@@ -2284,7 +2285,8 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const Ref<Re
22842285
}
22852286
}
22862287

2287-
Variant default_value = ClassDB::class_get_default_property_value(E->get_class(), F.name);
2288+
bool is_script = F.name == CoreStringName(script);
2289+
Variant default_value = is_script ? Variant() : PropertyUtils::get_property_default_value(E.ptr(), F.name);
22882290

22892291
if (default_value.get_type() != Variant::NIL && bool(Variant::evaluate(Variant::OP_EQUAL, p.value, default_value))) {
22902292
continue;

scene/resources/resource_format_text.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1931,7 +1931,8 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const Ref<Reso
19311931
}
19321932
}
19331933

1934-
Variant default_value = PropertyUtils::get_property_default_value(res.ptr(), name);
1934+
bool is_script = name == CoreStringName(script);
1935+
Variant default_value = is_script ? Variant() : PropertyUtils::get_property_default_value(res.ptr(), name);
19351936

19361937
if (default_value.get_type() != Variant::NIL && bool(Variant::evaluate(Variant::OP_EQUAL, value, default_value))) {
19371938
continue;

0 commit comments

Comments
 (0)