Skip to content

Commit

Permalink
[godot] Closes #2516, memdelete instead of memfree on Control
Browse files Browse the repository at this point in the history
  • Loading branch information
badlogic committed May 3, 2024
1 parent 77f48a3 commit 5a462e9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions spine-godot/build/debug.plist
@@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "https://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict><key>com.apple.security.get-task-allow</key><true/></dict></plist>
2 changes: 2 additions & 0 deletions spine-godot/build/sign.sh
@@ -0,0 +1,2 @@
#!/bin/bash
codesign -s - -v -f --entitlements build/debug.plist godot/bin/godot.macos.editor.dev.arm64
18 changes: 10 additions & 8 deletions spine-godot/spine_godot/SpineSprite.cpp
Expand Up @@ -33,6 +33,7 @@
#include "SpineSkeleton.h"
#include "SpineRendererObject.h"
#include "SpineSlotNode.h"
#include "core/os/memory.h"

#if VERSION_MAJOR > 3
#include "core/config/engine.h"
Expand Down Expand Up @@ -1047,14 +1048,6 @@ void SpineSprite::draw() {
}

#if TOOLS_ENABLED
Ref<Font> default_font;
auto control = memnew(Control);
#if VERSION_MAJOR > 3
default_font = control->get_theme_default_font();
#else
default_font = control->get_font(SNAME("font"), SNAME("Label"));
#endif
memfree(control);

float editor_scale = EditorInterface::get_singleton()->get_editor_scale();
float inverse_zoom = 1 / get_viewport()->get_global_canvas_transform().get_scale().x * editor_scale;
Expand All @@ -1074,6 +1067,15 @@ void SpineSprite::draw() {
auto global_scale = get_global_scale();
draw_set_transform(mouse_position + Vector2(20, 0), -get_global_rotation(), Vector2(inverse_zoom * (1 / global_scale.x), inverse_zoom * (1 / global_scale.y)));

Ref<Font> default_font;
auto control = memnew(Control);
#if VERSION_MAJOR > 3
default_font = control->get_theme_default_font();
#else
default_font = control->get_font(SNAME("font"), SNAME("Label"));
#endif
memdelete(control);

#if VERSION_MAJOR > 3
float line_height = default_font->get_height(Font::DEFAULT_FONT_SIZE) + default_font->get_descent(Font::DEFAULT_FONT_SIZE);
#else
Expand Down

0 comments on commit 5a462e9

Please sign in to comment.