1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

docs(CONTRIBUTING): add a guideline to not use dynamic casts/RTTI

And enforce it during compilation.
This commit is contained in:
Zetok Zalbavar 2016-09-24 12:25:09 +01:00
parent 8b0f3912b1
commit abaa41eaee
No known key found for this signature in database
GPG Key ID: C953D3880212068A
2 changed files with 15 additions and 1 deletions

View File

@ -310,6 +310,20 @@ QObject notToMentionThatWeUseCamelCase;
E.g. https://github.com/qTox/qTox/blob/master/src/misc/flowlayout.cpp
## Dynamic casts / RTTI
qTox is compiled without support for RTTI, as such PRs making use of
`dynamic_cast()` will fail to compile and may be rejected on this basis. For
manipulating Qt-based objects, use `qobject_cast()` instead.
Compiling qTox without RTTI support gives up to 5-6% size reductions on
compiled binary files. The usage of `dynamic_cast()` can also be completely
mitigated when dealing with Qt objects through use of `qobject_cast()` which
behaves very much like C++'s `dynamic_cast()` but without the RTTI overhead.
Enforced with `-fno-rtti`.
## Documentaion
If you added a new function, also add a doxygen comment before the

View File

@ -40,7 +40,7 @@ FORMS += \
CONFIG += c++11
CONFIG += link_pkgconfig
QMAKE_CXXFLAGS += -fno-exceptions
QMAKE_CXXFLAGS += -fno-exceptions -fno-rtti
QMAKE_RESOURCE_FLAGS += -compress 9 -threshold 0
# Rules for creating/updating {ts|qm}-files