vcl/unx/gtk4/gtkaccessibletext.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
New commits: commit 7b89f819be16fb14aa2e37c60af0b3a21e99c4ca Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Mon Aug 12 07:01:29 2024 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Mon Aug 12 13:10:34 2024 +0200 gtk4 a11y: Avoid explicit std::max template specialization Thanks to Mike Kaganski for pointing out this is the better way to do it in [1]: > In these cases, it's best to avoid the explicit template specialization, > but instead, do something like > > std::max(sal_Int32(0), xText->getCaretPosition()) > > because this latter form makes sure that it will not create problems > later at some unknown point in time, when we decide to change the > type of the returned value of the function. When that happens, your > form would silently continue to cast both its parameters to > sal_Int32, maybe overflowing. In the proposed form, this max would > break again, because the sal_Int32(0) would now not match the type > of getCaretPosition, and require us to revisit this code, and make > correct changes. > > It is indeed ~impossible in the specific case of the UNO API method; > but the best practice is that, and having inconsistency in the > codebase is sub-optimal ;-) [1] https://gerrit.libreoffice.org/c/core/+/171687/comment/35580611_5d9dfe85/ Change-Id: I489bf4fe5ca12833bc17849434822b984a8586a2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171744 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins (cherry picked from commit 82b648edd78ade6051d35657ac8e143946ce1254) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171684 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/vcl/unx/gtk4/gtkaccessibletext.cxx b/vcl/unx/gtk4/gtkaccessibletext.cxx index 6925b7ba6d56..66934708e529 100644 --- a/vcl/unx/gtk4/gtkaccessibletext.cxx +++ b/vcl/unx/gtk4/gtkaccessibletext.cxx @@ -102,7 +102,7 @@ static unsigned int lo_accessible_text_get_caret_position(GtkAccessibleText* sel if (!xText.is()) return 0; - return std::max<sal_Int32>(0, xText->getCaretPosition()); + return std::max(sal_Int32(0), xText->getCaretPosition()); } static gboolean lo_accessible_text_get_selection(GtkAccessibleText* self, gsize* n_ranges,