Review Request: Broken layout in KEditToolbar after restoring defaults

Parker Coates parker.coates at
Tue Aug 11 20:20:05 BST 2009

This is an automatically generated e-mail. To reply, visit:

(Updated 2009-08-11 19:20:05.810083)

Review request for kdelibs.


Switched to using a QPointer to keep track of the main widget inside of KDialog. Also fixed a crash that currently occurs when one calls "setMainWidget(0)".


The issue:
1. Open up any KDE app with a toolbar.
2. Settings > Configure Toolbars...
3. Click the Defaults button and confirm.
4. Notice that the dialog layout is (most likely, but not always) broken.

While trying to track down this issue, I made a rather small patch (below) to kedittoolbar.cpp. The patch fixed the issue, but I didn't understand why. After reverting the patch and doing some more digging, I learned the call to KDialog::setMainWidget(QWidget*) wasn't doing anything. So I looked into that code and found that the method was returning early if the new widget pointer was the same as the old. I slapped in a few kDebug lines and, low and behold, the new widget was being given the exact same address as the old one, so setMainWidget was convinced that the widget hadn't actually changed and didn't bother setting up the layout. Of course address assignment depends on the memory manager, so the issue isn't 100% repeatable as sometimes the new widget gets a different address.

The attached patch to KDialog removes this check. My understanding is that it's generally bad practice to use pointer addresses to establish identity. I also can't think of too many legitimate use cases that would require repeated calls to setMainWidget with the same widget and would need this check for performance reasons. But I could be wrong. Provided the patch is reasonable, I think it makes sense to backport to the 4.3 branch.

Another alternative would be to make KDialog's mMainWidget a QPointer, but that change seemed more invasive, and I'm still pretty terrified of breaking things in kdelibs. :)

The patch to KEditToolbar is no longer strictly necessary, but it does fix an somewhat annoying flicker that occurs when the main widget is replaced, so I'd still like to commit it. Of course, it would be a separate commit and probably doesn't need to be backported.

This addresses bug 180064.

Diffs (updated)

  trunk/KDE/kdelibs/kdeui/dialogs/kdialog.cpp 1008090 
  trunk/KDE/kdelibs/kdeui/dialogs/kdialog_p.h 1008090 
  trunk/KDE/kdelibs/kdeui/dialogs/kedittoolbar.cpp 1008090 





More information about the kde-core-devel mailing list