From 9ccff74fcf5dac1abdcffa6c8b9bfbc7cd7094df Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 2 Mar 2020 10:55:46 +0900 Subject: [PATCH] [qfcc] Emit only one instance per protocol per module This is actually a double issue: when a class implementing a protocol used the protocol in @protocol(), not only would the protocol get emitted as part of the class data specifying that the class conforms to the protocol, a second instance would be emitted again when @protocol() was used. On top of that, only the instance referenced by @protocol() would be initialized. Now, both class emission and @protocol() get their protocol def from the same place and thus only one, properly initialized, protocol instance is emitted. --- tools/qfcc/source/class.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/qfcc/source/class.c b/tools/qfcc/source/class.c index 0b981d065..381b37e1e 100644 --- a/tools/qfcc/source/class.c +++ b/tools/qfcc/source/class.c @@ -1667,7 +1667,7 @@ emit_protocol_list_item (def_t *def, void *data, int index) internal_error (0, "%s: out of bounds index: %d %d", __FUNCTION__, index, protocols->count); } - EMIT_DEF (def->space, D_INT(def), emit_protocol (protocol)); + EMIT_DEF (def->space, D_INT(def), protocol_def (protocol)); } def_t *