diff --git a/interface/src/ui/overlays/Overlays.cpp b/interface/src/ui/overlays/Overlays.cpp index b65fe6d286..d208658e8b 100644 --- a/interface/src/ui/overlays/Overlays.cpp +++ b/interface/src/ui/overlays/Overlays.cpp @@ -358,18 +358,19 @@ bool Overlays::isLoaded(unsigned int id) { return overlay->isLoaded(); } -float Overlays::textWidth(unsigned int id, const QString& text) { - if (_overlays2D.contains(id)) { - Overlay* thisOverlay = _overlays2D[id]; +const float Overlays::textWidth(unsigned int id, const QString& text) { + Overlay* thisOverlay = _overlays2D[id]; + if (thisOverlay) { if (typeid(*thisOverlay) == typeid(TextOverlay)) { return static_cast(thisOverlay)->textWidth(text); } - } - if (_overlays3D.contains(id)) { - Overlay* thisOverlay = _overlays3D[id]; - if (typeid(*thisOverlay) == typeid(Text3DOverlay)) { - return static_cast(thisOverlay)->textWidth(text); + } else { + thisOverlay = _overlays3D[id]; + if (thisOverlay) { + if (typeid(*thisOverlay) == typeid(Text3DOverlay)) { + return static_cast(thisOverlay)->textWidth(text); + } } } - return 0.f; + return 0.0f; } diff --git a/interface/src/ui/overlays/Overlays.h b/interface/src/ui/overlays/Overlays.h index dcda9a8ed7..4e11526f23 100644 --- a/interface/src/ui/overlays/Overlays.h +++ b/interface/src/ui/overlays/Overlays.h @@ -67,7 +67,7 @@ public slots: /// returns the width of the given text in the specified overlay if it is a text overlay: in pixels if it is a 2D text /// overlay; in meters if it is a 3D text overlay - float textWidth(unsigned int id, const QString& text); + const float textWidth(unsigned int id, const QString& text); private: QMap _overlays2D;