Hacking:Tools

Git
The Seamly2D code repository is on Github: https://github.com/FashionFreedom/Seamly2D

Please learn Git and workflow guidelines:
 * 1) Basic Git: https://zaiste.net/git_for_busy_people/
 * 2) The Git Flow method: https://datasift.github.io/gitflow/IntroducingGitFlow.html/
 * 3) Using semantic commit messages: https://seesparkbox.com/foundry/semantic_commit_messages/

Canonical/Ubuntu Launchpad and Bazaar
Launchpad automatically mirrors the Seamly2D git repo here: https://launchpad.net/~susan-spencer/+archive/ubuntu/seamly2d

Qt Creator
When you use Qt you have two IDE to choose: Qt Creator and Visual Studio.

from the official website.

For effective use of Qt Creator you will need know some stuff.
 * Qt Creator supports Git so creating and deleting files better to do from the IDE. Be sure to to choose appropriate .pri file.
 * Qt Creator's file wizard allow you to select correct file where it add files.
 * Keyboard Shortcuts.
 * Refactoring.
 * Specifying Code Style Settings. Seamly2D's code style file for Qt Creator you can find in  /share directory.
 * Set path to License template. Tools->Options->C++->File Naming. Example of license template for project you can find in  /share directory. Move it to another directory outside of the project directory and then change name of an author.
 * Set max length of source code line equal 120 characters. Tools->Options->Text Editor->Display.
 * Compile faster. For this use -j key for make. Projects->Build Steps->Make add -jX - where X number of cpu in your system.
 * Don't forget Qt Creator supports two release modes: Release and Debug. Project will be compile with different keys in different modes. Qt team recommended developing to do in debug mode. Also debugging works only in debug mode. Plus Qt will show additional warning information if something happened.

See Hacking:Tools:QtCreator:Ubuntu for description of installing and configuring Qt on 64-bit Ubuntu 14.04.

See Hacking:Tools:QtCreator:Windows10 for description of installing and configuring Qt on 64-bit Windows 10.

Address Sanitizer
See original article Using gcc’s 4.8.0 Address Sanitizer with Qt.

One of the cool new features since release of gcc 4.8 is the built in “Address Sanitizer”: a memory error detector for C/C++ that will tell you instantly when you e.g. access already deleted memory. This is actually a Google project from Clang/LLVM.

How does it work?
It basically overwrites malloc and free, and does check the memory before every access. Apparently it does that in a very efficient manner, since the slow down is only about 2x compared to uninstrumented execution! This allow us more effective seek bugs.

Be warned though that it only works so far on Linux and Mac.

How to enable it?
Since it is part of the compiler suite enabling it is easy: just add -fsanitize=address -fno-omit-frame-pointer to the compiler calls, and -fsanitize=address to the linker calls.

All you need it set QMAKE_CXXFLAGS, QMAKE_CFLAGS, and QMAKE_LFLAGS manually in each subproject:

In debug mode Seamly2D already use this flags, so no need set them manually.

How to use it?
Just run Seamly2D! If you happen to hit a memory issue program will abort immediately, and show you a stack trace with module names and addresses. You will need a separate tool called asan_symbolize.py to get the symbols, and then maybe c++filt to de-mangle the C++ symbols.

asan_symbolize.py also awailible in Seamly2D/scripts/asan_symbolize.py folder.

Example of use
After program abort we will get a stack trace.

Save this stack trace in file error.txt.

Run:

Result will looks like:

Known issue
For debug creation a layout need allocate big size of memory for images. Address Sanitizer doesn't support this. For avoiding this bug we recommend build Seamly2D without Address Sanitizer. For this run qmake with argument CONFIG+=noAddressSanitizer.

Have fun hunting down memory issues.