You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-14 13:41:12 +00:00
Add logic to unregister the Godot plugins on engine termination
This commit is contained in:
@@ -112,19 +112,18 @@ public abstract class GodotPlugin {
|
||||
/**
|
||||
* Register the plugin with Godot native code.
|
||||
* <p>
|
||||
* This method is invoked by the Godot Engine on the render thread.
|
||||
* This method is invoked on the render thread to register the plugin on engine startup.
|
||||
*/
|
||||
public final void onRegisterPluginWithGodotNative() {
|
||||
registeredSignals.putAll(
|
||||
registerPluginWithGodotNative(this, getPluginName(), getPluginMethods(), getPluginSignals()));
|
||||
}
|
||||
final String pluginName = getPluginName();
|
||||
if (!nativeRegisterSingleton(pluginName, this)) {
|
||||
return;
|
||||
}
|
||||
|
||||
private static Map<String, SignalInfo> registerPluginWithGodotNative(Object pluginObject,
|
||||
String pluginName, List<String> pluginMethods, Set<SignalInfo> pluginSignals) {
|
||||
nativeRegisterSingleton(pluginName, pluginObject);
|
||||
List<String> pluginMethods = getPluginMethods();
|
||||
|
||||
Set<Method> filteredMethods = new HashSet<>();
|
||||
Class<?> clazz = pluginObject.getClass();
|
||||
Class<?> clazz = getClass();
|
||||
|
||||
Method[] methods = clazz.getDeclaredMethods();
|
||||
for (Method method : methods) {
|
||||
@@ -156,15 +155,14 @@ public abstract class GodotPlugin {
|
||||
nativeRegisterMethod(pluginName, method.getName(), method.getReturnType().getName(), pt);
|
||||
}
|
||||
|
||||
Set<SignalInfo> pluginSignals = getPluginSignals();
|
||||
|
||||
// Register the signals for this plugin.
|
||||
Map<String, SignalInfo> registeredSignals = new HashMap<>();
|
||||
for (SignalInfo signalInfo : pluginSignals) {
|
||||
String signalName = signalInfo.getName();
|
||||
nativeRegisterSignal(pluginName, signalName, signalInfo.getParamTypesNames());
|
||||
registeredSignals.put(signalName, signalInfo);
|
||||
}
|
||||
|
||||
return registeredSignals;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -408,7 +406,7 @@ public abstract class GodotPlugin {
|
||||
* Used to setup a {@link GodotPlugin} instance.
|
||||
* @param p_name Name of the instance.
|
||||
*/
|
||||
private static native void nativeRegisterSingleton(String p_name, Object object);
|
||||
private static native boolean nativeRegisterSingleton(String p_name, Object object);
|
||||
|
||||
/**
|
||||
* Used to complete registration of the {@link GodotPlugin} instance's methods.
|
||||
|
||||
@@ -7,6 +7,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
set(GODOT_ROOT_DIR ../../../..)
|
||||
set(ANDROID_ROOT_DIR "${GODOT_ROOT_DIR}/platform/android" CACHE STRING "")
|
||||
|
||||
# Get sources
|
||||
file(GLOB_RECURSE SOURCES ${GODOT_ROOT_DIR}/*.c**)
|
||||
@@ -15,6 +16,7 @@ file(GLOB_RECURSE HEADERS ${GODOT_ROOT_DIR}/*.h**)
|
||||
add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS})
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
SYSTEM PUBLIC
|
||||
${GODOT_ROOT_DIR})
|
||||
${GODOT_ROOT_DIR}
|
||||
${ANDROID_ROOT_DIR})
|
||||
|
||||
add_definitions(-DUNIX_ENABLED -DVULKAN_ENABLED -DANDROID_ENABLED -DGLES3_ENABLED -DTOOLS_ENABLED)
|
||||
|
||||
Reference in New Issue
Block a user