diff --git a/src/plugins/coreplugin/manhattanstyle.cpp b/src/plugins/coreplugin/manhattanstyle.cpp
index 39c2615df7288a633764385f1e6dcb4d2f8625c0..995eee475f87ec6a0d83871b5c71d855cdb4781f 100644
--- a/src/plugins/coreplugin/manhattanstyle.cpp
+++ b/src/plugins/coreplugin/manhattanstyle.cpp
@@ -789,11 +789,12 @@ void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *opt
             bool horizontal = option->state & State_Horizontal;
 
             // Map offset for global window gradient
-            QPoint offset = widget->window()->mapToGlobal(option->rect.topLeft()) -
-                            widget->mapToGlobal(option->rect.topLeft());
             QRect gradientSpan;
-            if (widget)
+            if (widget) {
+                QPoint offset = widget->window()->mapToGlobal(option->rect.topLeft()) -
+                                widget->mapToGlobal(option->rect.topLeft());
                 gradientSpan = QRect(offset, widget->window()->size());
+            }
 
             bool drawLightColored = lightColored(widget);
             if (horizontal)