From 4e49638a6c7f7f8e2521720d570e541c54bb499e Mon Sep 17 00:00:00 2001 From: Wacek Gocki Date: Tue, 3 Nov 2015 22:27:08 +0100 Subject: [PATCH] Handle wxELLIPSIZE_NONE gracefully in wxControl::Ellipsize() Since 44bcc3a723c082a825943953ee5f13c2fc6dff85 wxRendererGeneric::DrawItemText() could call Ellipsize() with wxELLIPSIZE_NONE mode, resulting in an assert. Fix this by just not doing anything in this case. Closes #125. --- interface/wx/control.h | 3 ++- src/common/ctrlcmn.cpp | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/interface/wx/control.h b/interface/wx/control.h index 785cbbf8bd..34d8a388a8 100644 --- a/interface/wx/control.h +++ b/interface/wx/control.h @@ -383,7 +383,8 @@ public: // static functions wxDC::GetPartialTextExtents() function. @param mode The ellipsization mode. This is the setting which determines - which part of the string should be replaced by the ellipsis. + which part of the string should be replaced by the ellipsis + (unless it is ::wxELLIPSIZE_NONE in which case nothing is done). See ::wxEllipsizeMode enumeration values for more info. @param maxWidth The maximum width of the returned string in pixels. diff --git a/src/common/ctrlcmn.cpp b/src/common/ctrlcmn.cpp index dbfbc9f700..425b947b66 100644 --- a/src/common/ctrlcmn.cpp +++ b/src/common/ctrlcmn.cpp @@ -520,6 +520,9 @@ wxString wxControlBase::Ellipsize(const wxString& label, const wxDC& dc, wxEllipsizeMode mode, int maxFinalWidth, int flags) { + if (mode == wxELLIPSIZE_NONE) + return label; + wxString ret; // these cannot be cached between different Ellipsize() calls as they can