Posts tagged with ‘c++’

Contributing to Krita

kinow @ Jan 03, 2017 11:40:03

As I mentioned in the last post, I have been learning Qt and using C and C++ again. Since I used C and C++ more during university (about 10 years ago, phew), decided to read real code.

I used Photoshop, Illustrator, and Fireworks a lot when I was younger and had more time to spend drawing. But some time ago I switched to Inkscape for vector graphics, which I use at work for presentations. So it was only natural to try Krita now.

Since I was going to try Krita, I thought why not check out and build from source, and then in case I found any bugs, contribute back? Or maybe from time to time triage issues, find low hanging ones, and send a patch?

Well, turns out the Krita project has a great community, and it is super easy to send contributions. So far I submitted three patches, some were included in 3.x releases.

While the patches are rather small, they are suggestions on how to fix memory segmentation faults, or strange behaviours in the interface. For these issues, I had to learn more about Qt components, signals and emitting events, and, of course, work with pointers, arrays, Qt data structures, etc. In other words, lots of (geek) fun!

In other words, by contributing to Krita, I am not only helping the project and giving a little back to the community, but also refreshing my memory on C and C++, and slowly learning Qt - which is not very hard if you worked with Swing/AWT, Delphi, Visual Basic, Gtk, etc.

What are you waiting to contribute to Krita? The developers that maintain the project answer tickets and questions posted to reddit in a good time, and are extremely easy to work with.

Read more here how to build from source, and here on how to submit patches.

Happy hacking!

Debugging an application that freezes the X server

kinow @ Jan 02, 2017 00:39:03

Some time ago, I decided to start writing C++ again, and picked Krita for that. Krita is written in C++ and Qt. The bug I was working on involved a memory issue when changing the UI.

The problem was that this UI change would result in, not only Krita, but the whole X server freezing. My set up was basically Ubuntu 16.04.1 LTS, with Eclipse, Qt5, and the latest version of Krita checked out via git.

Initially I spent some time looking at the logs, tracing the binary, even downloaded some Qt utility tools to look at the events and what was happening with the application when it froze.

However, eventually I realized I was going to spend more time on this part of the issue, rather than on the memory bug. So decided to look for a work-around.

Thankfully someone else blogged about a similar issue and saved me a lot of time :-) Here’s how I did it, following the instructions in this blog post.

$ sudo apt-get install xnest -y
$ cd krita_install/
$ Xnest :10
$ twm -display :10
$ export DISPLAY=:10
$ ./krita

That’s it. You should have Krita running in a separate window, with Xnest, and within this window the twm window manager running. So when it freezes, at least you can still debug your application in Eclipse or whatever IDE you prefer.

Happy hacking!

Adding coverage reports in Jenkins to GoogleTest with gcovr

kinow @ Oct 16, 2012 16:09:33

After the last post about GoogleTest and TestLink using Jenkins TestLink Plug-in, I received an e-mail asking about coverage with GoogleTest and Jenkins. I’ve just updated the Makefile in the samples directory, of the GoogleTest TAP listener project, to output coverage data.

Basically, you have to add the compiler flags -fprofile-arcs -ftest-coverage and link the executable with -lgcov. Take a look at the project’s Makefile and you’ll notice how simple it is. In order to have Jenkins interpreting your coverage report, you’ll have to convert it to cobertura XML. There is a Python utility that can be used for this: gcovr. Download it and copy it to somewhere where Jenkins can execute it (e.g.: /usr/local/bin).

Now, if you’ve followed the instructions from the previous post, you should have a job that reports your GoogleTest tests from Jenkins to TestLink using the plug-in, and is downloading the source code from GitHub. Add an extra build step (Shell) to execute gcovr.

( Read more … )

Jenkins, TestLink and GTest in 5 minutes (or so)

kinow @ Oct 11, 2012 23:44:59

This is a 5 minutes guide on creating a job for a C++ project in Jenkins with GoogleTest and reporting the test results back to TestLink, with testlink-plugin.

The test project with GoogleTest

For this simple guide we will use the samples that come with GTest TAP Listener. You can get the code from GitHub with git clone git:// Take a look at gtest-tap-listener/samples/src/, there you will find two C++ files: and has the main function, and executes the test suite. And has the test cases and tests. Take note of the test case and tests names.

( Read more … )

Code to change your message in MSN messenger

kinow @ Mar 22, 2009 14:31:18

I’ve always wanted to know how does the code to show what was I listening to looked like. I found it after installing XMPlay and XMPlay MSN Plug-in. The plug-in zip had the plug-in itself and its source code. And what a neat source code (-:.

Basically, you just send a message to the MSN UI API with a defined data structure. And to remove the message, just send again with an empty string.

Bruno de Paula Kinoshita
original src code:
XMPlay MSN Plugin (c) 2005-2006 Elliott Sales de Andrade

#include <cstdlib>
#include <iostream>
#include <windows.h>

using namespace std;

typedef struct {
BOOL showCues;
BOOL keepOnClose;
} MSNStuff;
static MSNStuff msnConf;

void setNowPlaying( char *title)
    wchar_t *lpMsn;
    int strLen = 20;
    HWND xmpwin;
    HWND msnui=0;

    lpMsn = (wchar_t*)calloc(1024,1024);
    // stuff for MSN before...
    memcpy(lpMsn, L"\\0Music\\01\\0{0}\\0", 17*2);
    // actual title...
    strLen=MultiByteToWideChar(false?CP_UTF8:CP_ACP,0,title,-1,lpMsn+17,492)-1;  /* 1024/2 - 20 */
    // stuff for MSN after...
    memcpy(lpMsn + 17 + strLen, L"\\0", 3*2);
    strLen += 20;

    msndata.dwData = 0x547;
    msndata.lpData = (void*)lpMsn;
    msndata.cbData = strLen * 2;

    while ( msnui = FindWindowEx(NULL, msnui, "MsnMsgrUIManager", NULL) )
        SendMessage(msnui, WM_COPYDATA, (WPARAM)xmpwin, (LPARAM)&msndata);

int main(int argc, char *argv[])
    char *title;

    if ( argc == 1 )
        title = "";
        title = argv[1];

    setNowPlaying ( title );

    return EXIT_SUCCESS;
<p class="postmetadata">



    <small>posted in 
        title="View all posts in blog"
        rel="category tag">blog</a>&nbsp;]&nbsp;
    category </small>