I have built a small application that shows the main problem. There are 2 QDockWidgets and both contain only a QTextEdit. They also have as only DockWidgetFeature the QDockWidget::DockWidgetClosable option. So the dock widgets should not be able to be undocked.  On the first dockwidget‘s inner QTextWidget, i call winId(), on the other not.  (see source code)
if you start it, it looks like this:

The „Text2“-Widget works great. You can close it, and that’s all. But the first one has problems. If you double click on it on the left corner on the header like this:

The dock widget gets undocked and looks strange:

Anyway, you can redock the widget without problems and close it. But if I not call „winId()“, there is no problem with it.

The problem occurs with both Qt 5.0.2 and 5.1 Beta, also with XCode 4.2 and 4.6 and on Mac OSX 10.7.  and 10.8.
On Windows, since Qt 5.0.2. in general it seems to work well, but we have not tested it very carefully yet, because the mac version has priority at the moment.