Archive for the ‘KDE’ Category

How to find where an exception is emited with Qt ?

24 February, 2010 Leave a comment

When an exception is thrown and not catched in a Qt application, it get catched by Qt’s event loop, and the following message is displayed in the console:

Qt has caught an exception thrown from an event handler. Throwing exceptions from an event handler is not supported in Qt. You must reimplement QApplication::notify() and catch all exceptions there. terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc

In other situations, std::bad_alloc is replaced by the name of the exception. The problem is that if you now want to know where it happens in your program, the backtrace points to where the exception is rethrown by Qt’s event loop, which is not where the error happens.

I first had this problem a few days ago when implementing multi-layers support in EXR, since the exception name was specific to OpenEXR, I just grepped the code and deduce where the error occurred. But this is not very convenient when the error is generic, like std::bad_alloc which can be thrown just anywhere. And as it turned out by Qt itself in ‘qBadAlloc()’. The solution suggested by Maelcum on IRC is simply to set a breakpoint in the function __cxa_throw, which is a function of the C++ standard library that is actually doing the job when the keyword throw is used (at least with the GNU stdlib++, no idea if it is valid with other standard library implementation). And then you get a backtrace that point to the problem.

I thought I would share this tip in case, in some day, you find yourself with an uncaught exception in a Qt application.

Categories: KDE, Open Source Tags: , , ,

Inserting shapes/images in KOffice

21 October, 2009 Leave a comment

A while ago, in a praise of karbon 2.0 I wrote, someone commented on the “lack” of tools in karbon, as opposed to inkscape. And from forum posts, or, it seems to cause some confusions. For instance, there is no rectangle or circle tool in karbon. And there will never be. The reason is that for KOffice 2, the tools are meant for user interraction, and for manipulating object in the canvas. Inserting shapes is done through the “Add shape” docker, which allow to manager your collection of customs shapes, as well as standard shapes, you can then just drag and drop the shape, or select a shape and then by clicking and dragging on the canvas you can select the size of the shape like with a tool. Once the shape is on the canvas you can go to the toolbox and start having fun with your shape.

video of karbon adding shapes

And of course, since the technology is shared, you add shapes to other KOffice application in the same way. To add a text in Krita ? Go to the add shape docker, drag and drop, and enjoy ! To add an image to your presentation in KPresenter ? Go to the add shape docker, drag and drop, and enjoy ! To add a smiley to KWord… you get it !

OpenGTL 0.9.5 and Darkroom 1.3

2 September, 2008 1 comment

Today I am making a joint release of OpenGTL and Darkroom, for the main reason that I have made quiet a lot of bug fixes in OpenGTL that are needed to get a fully working Darkroom.

OpenGTL 0.9.5

Among the bug fixes, there are two major changes in this release

  • Start using llvm optimization, there is one thing that OpenGTL does very poorly, it is emitting assembly code, for instance, if you need to access three time a value, it will load it three time from memory… So enabling optimization give a significant boost in execution speed, unfortunately, I haven’t had the time to do some benchmarking, but I have noticed a siginificant improvement in applications (Krita and Darkroom) that use OpenGTL.
  • The second change, which took me longer to do correctly, is that conversion are now handled by the parser and inserted in the AST tree, instead of being assumed to be possible in the parser and triggering asserts in the code generation (previously MyStruct a; int b = 2 + a; would have aborted the program instead of reporting an error to the user). The other benefit of that change is that it makes possible to automatically convert from Shiva’s pixel structure to a vector.

    Before that change, the Blur kernel was looking like this:

    kernel Blur
    void evaluatePixel(image img, out pixel result)
    pixel v1 = img.sampleNearest( result.coord );
    pixel v2 = img.sampleNearest( result.coord - 1.0 );
    pixel v3 = img.sampleNearest( result.coord + 1.0 );
    for(int i = 0; i < 3; ++i)
    result[i] = (v1[i] + v2[i] + v3[i]) / 3;

    And now it is down to:

    kernel Blur
    void evaluatePixel(image img, out pixel result)
    result = ( img.sampleNearest( result.coord ) + img.sampleNearest( result.coord - 1.0 ) + img.sampleNearest( result.coord + 1.0 ) ) / 3.0;

Darkroom 1.3

The two main changes (yes I like to limit myself to the number 2) of Darkroom are:

  • This release introduce a levels widget, if you wonder how it is useful, I suggest reading Unai Garro’s Levels adjust tutorial.

  • Darkroom can now export to jpeg, when I first started Darkroom I considered that the only interesting export format would be Png, only to realize later that if one wants to export to a web gallery, jpeg is better suited
  • Bookmarks (yes that’s a third change, but I only remember about it when I did the screenshots for the levels widget), it’s now possible to save bookmarks of your favorite processing settings