Make sure there's a scene before using it
Fixes crash hovering links in quassel Task-number: QTBUG-44509 Change-Id: I77d8d9118ad185ed70a46e91445e2960200e562b Reviewed-by: Michael Brüning <michael.bruning@theqtcompany.com> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
This commit is contained in:
parent
732c994876
commit
8fccfef424
@ -12272,7 +12272,7 @@ QPoint QWidget::mapToGlobal(const QPoint &pos) const
|
||||
{
|
||||
#ifndef QT_NO_GRAPHICSVIEW
|
||||
Q_D(const QWidget);
|
||||
if (d->extra && d->extra->proxyWidget) {
|
||||
if (d->extra && d->extra->proxyWidget && d->extra->proxyWidget->scene()) {
|
||||
const QList <QGraphicsView *> views = d->extra->proxyWidget->scene()->views();
|
||||
if (!views.isEmpty()) {
|
||||
const QPointF scenePos = d->extra->proxyWidget->mapToScene(pos);
|
||||
@ -12307,7 +12307,7 @@ QPoint QWidget::mapFromGlobal(const QPoint &pos) const
|
||||
{
|
||||
#ifndef QT_NO_GRAPHICSVIEW
|
||||
Q_D(const QWidget);
|
||||
if (d->extra && d->extra->proxyWidget) {
|
||||
if (d->extra && d->extra->proxyWidget && d->extra->proxyWidget->scene()) {
|
||||
const QList <QGraphicsView *> views = d->extra->proxyWidget->scene()->views();
|
||||
if (!views.isEmpty()) {
|
||||
const QPoint viewPortPos = views.first()->viewport()->mapFromGlobal(pos);
|
||||
|
@ -175,6 +175,7 @@ private slots:
|
||||
void windowFrameMargins();
|
||||
void QTBUG_6986_sendMouseEventToAlienWidget();
|
||||
void mapToGlobal();
|
||||
void mapToGlobalWithoutScene();
|
||||
void QTBUG_43780_visibility();
|
||||
};
|
||||
|
||||
@ -3690,6 +3691,16 @@ void tst_QGraphicsProxyWidget::mapToGlobal() // QTBUG-41135
|
||||
.arg(embeddedCenterGlobal.x()).arg(embeddedCenterGlobal.y())));
|
||||
}
|
||||
|
||||
void tst_QGraphicsProxyWidget::mapToGlobalWithoutScene() // QTBUG-44509
|
||||
{
|
||||
QGraphicsProxyWidget proxyWidget;
|
||||
QWidget *embeddedWidget = new QWidget;
|
||||
proxyWidget.setWidget(embeddedWidget);
|
||||
const QPoint localPos(0, 0);
|
||||
const QPoint globalPos = embeddedWidget->mapToGlobal(localPos);
|
||||
QCOMPARE(embeddedWidget->mapFromGlobal(globalPos), localPos);
|
||||
}
|
||||
|
||||
// QTBUG_43780: Embedded widgets have isWindow()==true but showing them should not
|
||||
// trigger the top-level widget code path of show() that closes all popups
|
||||
// (for example combo popups).
|
||||
|
Loading…
Reference in New Issue
Block a user