Commit 6d3f81b0 authored by BogDan Vatra's avatar BogDan Vatra Committed by BogDan Vatra

Fix DockWidget

DockWidget keeps a pointer to the initial inner widget which might change/delete.

Ex:
    QWidget *w = new QWidget;
    w->setWindowTitle("title");
    QDockWidget *dock = addDockForWidget(w);
//...
    dock->setWidget(0); // we want to set another widget
    delete w;

Change-Id: I04e3d1075787092f3789f32442990aa76848d1b7
Reviewed-by: default avatarDaniel Teske <daniel.teske@theqtcompany.com>
Reviewed-by: default avatarhjk <hjk@theqtcompany.com>
Reviewed-by: default avatarBogDan Vatra <bogdan@kde.org>
parent 0171f5f6
......@@ -85,7 +85,6 @@ public:
private:
QPoint m_startPos;
QWidget *m_inner;
TitleBarWidget *m_titleBar;
QTimer m_timer;
};
......@@ -245,7 +244,7 @@ public:
};
DockWidget::DockWidget(QWidget *inner, FancyMainWindow *parent)
: QDockWidget(parent), q(parent), m_inner(inner)
: QDockWidget(parent), q(parent)
{
setWidget(inner);
setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetFloatable);
......@@ -288,7 +287,7 @@ bool DockWidget::eventFilter(QObject *, QEvent *event)
int y = me->pos().y();
int x = me->pos().x();
int h = m_titleBar->m_floatButton->height();
if (!isFloating() && 0 <= x && x < m_inner->width() && 0 <= y && y <= h) {
if (!isFloating() && widget() && 0 <= x && x < widget()->width() && 0 <= y && y <= h) {
m_timer.start();
m_startPos = mapToGlobal(me->pos());
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment