Welcome,
Guest
. Please
login
or
register
. Did you miss your
activation email?
French forum
Home
Help
Search
Login
Register
SFML community forums
»
General
»
General discussions
»
SFML Game Development book - bug in the sources?
Print
Pages: [
1
]
Author
Topic: SFML Game Development book - bug in the sources? (Read 3074 times)
0 Members and 1 Guest are viewing this topic.
xqbt
Newbie
Posts: 30
SFML Game Development book - bug in the sources?
«
on:
March 20, 2016, 12:56:57 am »
So I am reading a book called
SFML Game Development
(and I really like it), but I think I might have found a major memory leak in the provided sources. If you go to the main repository and check this file:
https://github.com/SFML/SFML-Game-Development-Book/blob/master/10_Network/Include/Book/SceneNode.hpp
you will see that there is no virtual destructor declared. I suppose that's a bug.
Please, fix me if I am wrong.
Logged
Nexus
SFML Team
Hero Member
Posts: 6287
Thor Developer
Re: SFML Game Development book - bug in the sources?
«
Reply #1 on:
March 20, 2016, 09:25:17 am »
The base classes
sf::Transformable
and
sf::Drawable
have a virtual destructors.
Logged
Zloxx II
: action platformer
Thor Library
: particle systems, animations, dot products, ...
SFML Game Development
:
xqbt
Newbie
Posts: 30
Re: SFML Game Development book - bug in the sources?
«
Reply #2 on:
March 20, 2016, 10:03:39 am »
OK, got it, thank you. It was dumb of me not to think of that.
Logged
Laurent
Administrator
Hero Member
Posts: 32498
Re: SFML Game Development book - bug in the sources?
«
Reply #3 on:
March 20, 2016, 10:06:44 am »
Isn't it a good practice to explicitly declare a destructor virtual for an abstract base class, regardless of its own parents? It's clearer for users, and less prone to errors when the code evolves (the parent classes may change, or not be parents anymore). It's like not including a standard header, because you know that some other that you already include does it
«
Last Edit: March 20, 2016, 11:48:05 am by Laurent
»
Logged
Laurent Gomila - SFML developer
Nexus
SFML Team
Hero Member
Posts: 6287
Thor Developer
Re: SFML Game Development book - bug in the sources?
«
Reply #4 on:
March 20, 2016, 10:14:19 am »
It arguably is.
Declaring ABC destructors virtual can make sense, the same way that e.g. declaring constructors
explicit
by default or using
override
can. It's redundant, but helps prevent errors when migrating code.
Logged
Zloxx II
: action platformer
Thor Library
: particle systems, animations, dot products, ...
SFML Game Development
:
Print
Pages: [
1
]
SFML community forums
»
General
»
General discussions
»
SFML Game Development book - bug in the sources?
anything