Hacking:Tools

hg-git Extension
For export to github and launchpad we use hg-git extension. Please read these two articles for more details: the Hg-Git mercurial plugin and hg-git Extension.

Warning! Because service Launchpad doesn't use git repository directly and converts to Bazaar we can't use hg-git version higher than 0.6.1.

For our work we use code from repository http://bitbucket.org/durin42/hg-git/

Usage: For working extension need to create a bookmark. Command will set a bookmark for current branch. Most actively we export 'develop' and 'default'.

Before pushing create path 'github' in .hgrc file.

Run for pushing changes to github.

Note the command can hang. You can wait finish or close terminal without losing data.

Qt Creator
When you use Qt you have two IDE to choose: Qt Creator and Visual Studio. Yes, last information what i have says that Eclipse doesn't have support for Qt5.

First look better begin from the official website.

For effective using Qt Creator you will need know some stuff.
 * Qt Creator supports Mercurial, 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. Valentina'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 support two release mode: 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.

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 Valentina already use this flags, so no need set them manually.

How to use it?
Just run Valentina! 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 Valentina/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 Valentina without Address Sanitizer. For this run qmake with argument CONFIG+=noAddressSanitizer.

Have fun hunting down memory issues.

Mercurial
Better place to start to get acquainted with the tool is the official guide. Also read A Guide to Branching in Mercurial.

Some people love to use only command line other will prefer GUI. For the second group we highly recommend TortoiseHG.

Below we will show several useful commands you will need to know for begin work with mercurial.


 * - update to develop branch.
 * - to see what branch is current.
 * - say to commit to feature branch.
 * - say to commit to feature branch even it is already exists. Reopen the branch in another place.
 * - make a commit with message.
 * - push your changes from branch feature.
 * - push all your changes.
 * - create a bookmark.