Skip to content

Powerful debugging tools

meeloo edited this page Oct 2, 2010 · 1 revision

DebuggingTools

NUI provides a set of very powerful debugging tools to help every programmer find and fix bugs fast and without going through hoops.

Accessing the NUI debugger.

Enabling the debugger in your application

To enable the debugger you have to call SetDebugMode(true) on your nuiMainWindow. We usually put this call in the constructor of the main window class. It is also a good idea to restrict this call to debug build and to disable it in release build:


#ifdef _DEBUG_
SetDebugMode(true);
#endif

Calling SetDebugMode(true) only enables the small piece of code that handle the debugger key stroke. It doesn’t change any thing more than that in your application. If you never hit the debugger key combination then your application will behave exactly as if this method was never called in the first place.

Launching the debugger window

The debugger for a window is be accessed by hitting the Ctrl + Shift + D keys. (your must enable the debugger in the main window, see the previous paragraph). You should then see a window very similar to this:

As you can see, above all, the mode tabs permits to change the current view. There are currently three modes for the debugger: Widget Tree, Threads and Fonts. We’ll detail these three views in the following paragraphs.

GUI debugging

Widget tree

This is the default view when to summon the debugger window. On the left part you can see and manipulate the current Widget Tree of the main window from which the debug window was called. You can select any widget to inspect it on the right side of the view, or open containers to see their children. Selecting a widget will make it appear with a blue filled rectangle in the main window to help you make sure you’re looking at what you wanted to. This sometime create strange views because of the way partial redraw is working in NUI. You can cancel your current selection by clicking anywhere besides the widgets.

Widget inspector

The widget inspector is displayed when you select a widget in the tree on the left. Here is another typical view:

You can scroll through this description of the selected widget.

  • The Standard part shows all the basic info available about your widget. Its cobject name, its class and inheritance list, the C++ type if available, the rectangles, its invalidation state and its current matrix (most of the time it’s just the identity matrix.
  • The Properties part show the properties currently stored on the widget. The properties being just a dictionary of strings there is not much you can interact with here.
  • The attributes part is very interesting as it show the state of the attributes stored on this object. If the attributes provide a custom editor you can even interactively change the values in the objets. For example, in the picture above we can change the borders of the widget, the mouse cursor of the fact that it renders to a surface. Some attributes are read only. others are write only, but the vast majority of read/write. However, not all complete editors are written yet so some of then just cant be changed by hand.
  • Last but not leat the Rendering part shows you the actual rendering of the widget.

Threads and locks

The second mode of the debugger displays a list of the threads running in application.

Fonts

This view displays all the currently loaded fonts, their logical name and their main properties as well as a text sample.