C++

Convert *.pro to *.vcxproj (qmake to Visual Studio-project)

Written by  on April 5, 2018

0. Change this particualar line inside the *.pro:

1. run qmake against that pro-file
2. load the vcxproj with Visual Studio

edit: or do it with the original pro-file just like the wiki.qt.io suggests:

Cullendula

Written by  on April 3, 2018

Small program to pick out the best shots of the vast amount of taken pictures per session (excursion). The name itself is a wordplay of the plant Calendula and the activity “to cull” (slang for sorting the photos).

url for the repository: https://github.com/marcelpetrick/Cullendula/
development time for fully usable version 0.1: one day
used technologies: C++ and Qt – my favorite ones <3

VisualStudio-Addin for Qt

Written by  on March 22, 2018

The source for the current downloads: https://download.qt.io/official_releases/vsaddin/ (for MSVC 2013, 2015 and 2017), because I had to (again) search for the installation-files.

Tracing memory-leaks* under Windows

Written by  on March 2, 2018

For a long time I am searching for a useable profiler for windows,
which does not only track the time (like VerySleepy) but memory-usage.
I was used to Instruments under OSX and – boy – I was surprised there
is nothing comparable under Windows.
Visual Studio newer than 2013 is not useable – I know there are profilers integrated.
Dr. Memory crashes at start.
AppVerifier does not work (crash).
http://wiki.qt.io/Profiling_and_Memory_Checking_Tools has some more
hints, but let me present the two tools which finally gave me some
insight:


MTuner (https://github.com/milostosic/MTuner) from Milos Tosic (2017)


Pro: works out of the box without any reconfiguration of the app;
captures data which can be evaluated later; fancy looking; actively
maintained at github (answers error-reports fast); does not need much
explanation
Con: crashes currently while evaluating the bigger traces (400 MiByte+)


And then one Microsoft tool: UMDH

Con: much trouble to acquire and getting it to work (long explanation)
Pro: but the diff of the allocations as stacktraces can be helpful

0. install windows SDK
1. set the gflags correctly: means allow stacktraces for the process
2. capture two snapshots of current image of the process
C:\Program Files (x86)\Windows Kits\10\Debuggers\x86>umdh.exe -p:8480
-f:c:\alloc0.txt
and some moments/actions later
C:\Program Files (x86)\Windows Kits\10\Debuggers\x86>umdh.exe -p:8480
-f:c:\alloc1.txt
3. compare and get starting line 300-400 some descending view of the
biggest allocation-changes:
C:\Program Files (x86)\Windows Kits\10\Debuggers\x86>umdh.exe -d
c:\alloc0.txt c:\alloc1.txt > c:\alloc_diff10o1.txt

at *: I know, sometimes it is not a leak, but “by design” ๐Ÿ˜‰

“un-optimize” a VisualStudio-solution

Written by  on March 2, 2018

By default after generating the solution from mpc-files for each vcxproj the optimization-level is set to maximum (O2), which can lead to trouble while debugging. Variables not “visible”, content of containers not readable, .. and then you can stop debugging, reset manually the optimization, restart and go to the breakpoint/crash. Which is a total waste of time.
I’ve also found no way to convince the mpc-buildsystem of building un-optimized.

Ok, then we build us a sed-oneliner which replaces in all project-files the line about optimization and run it under cygwin:

banner generator: figlet (online)

Written by  on February 11, 2018

Ok, most of the times your classes and functions shall be commented.
So, let us decorate a bit: your wish shall be my command ๐Ÿ˜‰
I had just remembered the good old toolkit to generate banners!

url: http://patorjk.com/software/taag/

proCreator version 0.1 is ready!

Written by  on October 22, 2017

url: https://github.com/marcelpetrick/proCreator

Clone, build (preferrably with QtCreator 4.x and Qt 5.9), run. A short howto in the readme describes how to use it.
After applying some restructuring, I got rid of some classes, simplified the code for reading the directory-content and for filtering. Kudos to the Qt-library!*

* Three slogans I like to stick to:
– Keep it simple (and stupid).
– Don’t re-invent the wheel.
– Functionality first.

Addendum: the proCreator was used now to revive two projects for which only source-code, but no “make-files” (pro, qbs, mpc, cmake ..) existed. It did its job ๐Ÿ™‚

proCreator: another helper for legacy Qt-projects

Written by  on October 21, 2017

Ok, today at work I ran into the problem that for a Qt-project we have the code, the binaries and an awkward buildsystem (mpc). But I don’t want to process first the mpc and then fire up Visual Studio and wait for hours until the whole solution has been build. I want to use QtCreator! <3 So, there was never a real pro-file. The project consists of about ten classes, some forms and one ressource-file. Not much, possible to tinker it manually into a self-generated pro-file. Which can be processed then by QtCreator or qmake. (Hint "ls -X" is helpful for sorting by filetype.) But: why not delegate this to a small tool? First I thought about bash, then ... "maybe something better, like Python" ... and then ... why not Qt itself? So, please have a look at https://github.com/marcelpetrick/proCreator, which is half-way done. Outputting works. Just input-grabbing has to be implemented. Should be ready by sunday ๐Ÿ™‚

Will keep you updated.

Qt: find the sender (aka: invoking signal) for a slot

Written by  on August 27, 2017

Sometimes several signals lead to one single slot. Without any parameter. So you are stuck and can’t find out who was the ‘caller’.
But wait, there is a nasty hack to find it for those which are direct connections.

shell-script to clean a project

Written by  on June 14, 2017

I like to decorate the code with some debugging-messages, explicit variables, etc. while developing a feature or fixing a bug. Problem is that other team-members will not like that (or the amount ;)).
So, I commit the current state with Git and then remove all lines marked with the comment “// todoM”. Since this some non-creative work, why not automate it?

Code for the bash-script now on github: https://github.com/marcelpetrick/cleanMyCode ๐Ÿ™‚

Further improvements like massive parallelization planned!

edith 20170619:
The fourth version relies now on some exported bash-function, so that GNU parallel can be used to speed up the process by parallelizing the search&replace inside the file- (-list given by find).
This helps, just I/O is now the bottleneck. CPU-speed not.
But I’ve always wanted to experiment with “parallel” and see how to use this. I should improve the “contactSheet”-script as well. Or the cat-cam-script .. endless opportunities ..