diff --git a/src/ui/theme.cpp b/src/ui/theme.cpp
index 5e8104e9d..b9d735b7d 100644
--- a/src/ui/theme.cpp
+++ b/src/ui/theme.cpp
@@ -747,7 +747,7 @@ void Theme::drawSlices(Graphics* g, os::Surface* sheet,
 void Theme::drawTextBox(Graphics* g, Widget* widget,
                         int* w, int* h, gfx::Color bg, gfx::Color fg)
 {
-  View* view = View::getView(widget);
+  View* view = (g ? View::getView(widget): nullptr);
   char* text = const_cast<char*>(widget->text().c_str());
   char* beg, *end;
   int x1, y1;