From b5f7e3047140db693d0fe8f25712945511ce51b6 Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Thu, 10 Nov 2016 23:26:41 +0100 Subject: [PATCH] Update description for the bug fixed in the previous commit. --- docs/wrong_virtual_call.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/wrong_virtual_call.md b/docs/wrong_virtual_call.md index b20c991..4ebc06a 100644 --- a/docs/wrong_virtual_call.md +++ b/docs/wrong_virtual_call.md @@ -1,3 +1,4 @@ +## Bug description ## 1) SizeNotifiable, defined as the following: class SizeNotifiable : private RegisterBehaviour, public SizeNotifiableBase { ... }; @@ -23,3 +24,7 @@ note that parNotifiable is received from SizeNotifiable's constructor, so it's a parNotif is, again, the partly constructed object pointed by this in SizeNotifiable's constructor. NotifyResChanged() is a virtual method, thus the bug. Objects being registered need to be notified straight away since they have no clue about the current size held by SDLMain. + + +## Solution ## +Fixed at commit 5e76b49cae954accd1533d6b6431af7cb5f770ef doing something that I call *deferred virtual call*. A temporary object is passed down in the SizeNotifiable's hierarchy. This object's destructor calls the Register() method *if the stack is not being unwinded due to an exception*. Since the object is passed from the top (from outside the topmost constructor), its destructor gets called after the end of the scope of the topmost constructor in the SizeNotifiable's hierarchy. By that point all virtual tables should be set to their final state.