Class inheritance method override does not work in 4.8 beta 1

Chiusa
#2,083 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
cpp, godot
Ambito
backend

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
C++
Stelle
2.8k
Fork
825
Merge medio
3g 23h
PR unite (30g)
19

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di godotengine/godot-cpp

Tutte le issue di godotengine/godot-cpp

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.