libreoffice: fix build on 32 bit platform

This commit is contained in:
Đoàn Trần Công Danh 2024-09-01 18:10:44 +07:00
parent 464419dde9
commit ae40b2f223
1 changed files with 53 additions and 0 deletions

View File

@ -0,0 +1,53 @@
From 82b648edd78ade6051d35657ac8e143946ce1254 Mon Sep 17 00:00:00 2001
Message-ID: <82b648edd78ade6051d35657ac8e143946ce1254.1725189001.git.congdanhqx@gmail.com>
From: Michael Weghorn <m.weghorn@posteo.de>
Date: Mon, 12 Aug 2024 07:01:29 +0200
Subject: [PATCH] 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.weghorn@posteo.de>
Tested-by: Jenkins
---
vcl/unx/gtk4/gtkaccessibletext.cxx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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,
--
2.46.0.rc2