Core: Increase MAX_ID_NAME length from 66 to 258 (Blender 5.0)
Change the maximum data-block name from 64 to 256 bytes by increasing MAX_ID_NAME value. Also increase a few related non-ID data name max size, essentially the action slots identifiers, as these are the primary key used to match an Action's slot to an ID by name. Other sub-data (bones, modifiers, etc.) lengths are not modified here, as these can be made actual dynamic strings in the future, while keeping (a reasonable level of) forward compatibility, during the course of Blender 5 release cycles. Implements #137608. Co-authored-by: Bastien Montagne <bastien@blender.org> Pull Request: https://projects.blender.org/blender/blender/pulls/137196
This commit is contained in:
committed by
Bastien Montagne
parent
09af302457
commit
fdaaea6328
@@ -68,24 +68,36 @@ class ActionSlotCreationTest(unittest.TestCase):
|
||||
self.action.slots.new('UNSPECIFIED', "Bob")
|
||||
|
||||
def test_long_identifier(self):
|
||||
# Test a 65-character identifier, using a 63-character name. This is the
|
||||
# maximum length allowed (the DNA field is MAX_ID_NAME=66 long, which
|
||||
# Test a 257-character identifier, using a 255-character name. This is the
|
||||
# maximum length allowed (the DNA field is MAX_ID_NAME=258 long, which
|
||||
# includes the trailing zero byte).
|
||||
long_but_ok_name = "This name is so long! It might look long, but it is just right!"
|
||||
long_but_ok_name = (
|
||||
"This name is so long! It might look long, but it is just right! "
|
||||
"This name is so long! It might look long, but it is just right! "
|
||||
"This name is so long! It might look long, but it is just right! "
|
||||
"This name is so long! It might look long, but it is just right!"
|
||||
)
|
||||
assert (len(long_but_ok_name) == 255)
|
||||
slot_ok = self.action.slots.new('OBJECT', long_but_ok_name)
|
||||
self.assertEqual(long_but_ok_name, slot_ok.name_display, "this name should fit")
|
||||
self.assertEqual('OB' + long_but_ok_name, slot_ok.identifier, "this identifier should fit")
|
||||
|
||||
# Test one character more.
|
||||
too_long_name = "This name is so long! It might look long, and that it is indeed."
|
||||
too_long_name_truncated = too_long_name[:63]
|
||||
too_long_name = (
|
||||
"This name is so long! It might look long, and that it is indeed."
|
||||
"This name is so long! It might look long, and that it is indeed."
|
||||
"This name is so long! It might look long, and that it is indeed."
|
||||
"This name is so long! It might look long, and that it is indeed."
|
||||
)
|
||||
assert (len(too_long_name) == 256)
|
||||
too_long_name_truncated = too_long_name[:255]
|
||||
slot_long = self.action.slots.new('OBJECT', too_long_name)
|
||||
self.assertEqual(too_long_name_truncated, slot_long.name_display, "this name should be truncated")
|
||||
self.assertEqual('OB' + too_long_name_truncated, slot_long.identifier, "this identifier should be truncated")
|
||||
|
||||
# Test with different trailing character.
|
||||
other_long_name = "This name is so long! It might look long, and that it is indeed!"
|
||||
truncated_and_unique = other_long_name[:59] + ".001"
|
||||
other_long_name = too_long_name[:-1] + "!"
|
||||
truncated_and_unique = other_long_name[:251] + ".001"
|
||||
slot_long2 = self.action.slots.new('OBJECT', too_long_name)
|
||||
self.assertEqual(truncated_and_unique, slot_long2.name_display,
|
||||
"this name should be truncated and made unique")
|
||||
|
||||
Reference in New Issue
Block a user