Skip to content

Commit 5c1f8f5

Browse files
committed
Add ImString support for "null" values
Set with "null" as a value will work in the same way String#valueOf does.
1 parent 74cfec5 commit 5c1f8f5

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

imgui-binding/src/main/java/imgui/type/ImString.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public void set(final String value, final boolean resize) {
9090
}
9191

9292
public void set(final String value, final boolean resize, final int resizeValue) {
93-
final byte[] valueBuff = value.getBytes();
93+
final byte[] valueBuff = (value == null ? "null" : value).getBytes();
9494
final int currentLen = data == null ? 0 : data.length;
9595
byte[] newBuff = null;
9696

imgui-binding/src/test/java/imgui/ImStringTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,8 @@ public void testSet() {
5252
assertEquals("0123456789", str.get());
5353
assertEquals(10, str.getLength());
5454
assertEquals(10 + str.inputData.resizeFactor + 1, str.getBufferSize());
55+
56+
str.set(null);
57+
assertEquals("null", str.get());
5558
}
5659
}

0 commit comments

Comments
 (0)