Class inheritance method override does not work in 4.8 beta 1

Cerrado
#2,083 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
45/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
cpp, godot
Área
backend

Línea de trabajo

Start with the reproduction in addons/test/cTest.h and main.gd, then compile it with addons/test/compite_debug.sh using Godot 4.8 beta and the listed godot-cpp commits. Compare the inherited test method behavior with versions before 4.8; done when b.test(im) accepts the Image argument while a.test(ba) still works.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug
Godot version

4.8.beta1

godot-cpp version

1b089f20a959e67e79e32e352a57065b3058dbfd

System information

Ubuntu 24.04

Issue description

We have two classes, see reproduction project (addons/test/cTest.h):

class cTestA : public RefCounted {
	GDCLASS(cTestA, RefCounted)

    public: 
        cTestA(){}
        ~cTestA(){}
        void test(PackedByteArray byte_array){
            UtilityFunctions::print("cTestA: test function call: PackedByteArray");
        }
    protected:
        static void _bind_methods(){
            ClassDB::bind_method(D_METHOD("test", "byte_array"), &cTestA::test);
        };
};

class cTestB : public cTestA {
	GDCLASS(cTestB, cTestA)
   
    public:
        cTestB(){}
        ~cTestB(){}
        void test(Ref<Image> image){
            UtilityFunctions::print("cTestB: test function call: Ref<Image>");
        }
    protected:
        static void _bind_methods(){
            ClassDB::bind_method(D_METHOD("test", "image2d"), &cTestB::test);
        };
};

But in GDScript (main.gd):

func _ready() -> void:
	var a := cTestA.new()
	var b := cTestB.new()
	var ba := PackedByteArray([0,0,0])
	var im := Image.create_empty(128, 128, false, Image.FORMAT_RF)
	a.test(ba)
	b.test(im)

I get an error: "Error at (8, 12): Invalid argument for "test()" function: argument 1 should be "PackedByteArray" but is "Image"."
This problem did not exist in any version <4.8.
Tested with:

  1. godot-cpp commit 1b089f20a959e67e79e32e352a57065b3058dbfd
  2. godot-cpp commit 507ed9d840c01a3c5b2a39af8bb4000bfac30bf5
Steps to reproduce

See reproduction project. Compile script: addons/test/compite_debug.sh
To compile:

cd addons/test
git clone [email protected]:godotengine/godot-cpp.git
chmod +x compite_debug.sh
./compite_debug.sh

then open this project in Godot 4.8 beta.

Minimal reproduction project

InheritanceTest.zip

Lenguaje dominante
C++
Estrellas
2.8k
Forks
825
Merge medio
3 d 23 h
PR fusionados (30 d)
19

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de godotengine/godot-cpp

Todos los issues de godotengine/godot-cpp

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.