From 367d40d31b71ccd978cfd7127651e348ec7144e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 18 Aug 2022 21:34:41 +0200 Subject: [PATCH] appDisplay: Don't have goToPage clamp to negative page index The nPages property can be 0, which is the case in a stripped down CI image without a single app to be listed, which means we can't clamp to `nPages - 1`, since that'll give us a negative index and the following error: (gnome-shell:266): Gjs-CRITICAL **: 16:48:56.633: JS ERROR: Error: Page -2 does not exist at IconGrid getItemsAtPage@resource:///org/gnome/shell/ui/iconGrid.js:1383:19 _translatePreviousPageIcons@resource:///org/gnome/shell/ui/appDisplay.js:323:34 _syncPageIndicators@resource:///org/gnome/shell/ui/appDisplay.js:396:14 goToPage@resource:///org/gnome/shell/ui/appDisplay.js:445:14 goToPage@resource:///org/gnome/shell/ui/appDisplay.js:1236:29 goToPage@resource:///org/gnome/shell/ui/appDisplay.js:1582:15 _init/<@resource:///org/gnome/shell/ui/appDisplay.js:499:18 _init/pagesChangedId<@resource:///org/gnome/shell/ui/iconGrid.js:1137:24 _removePage@resource:///org/gnome/shell/ui/iconGrid.js:454:14 _removeItemData@resource:///org/gnome/shell/ui/iconGrid.js:495:18 moveItem@resource:///org/gnome/shell/ui/iconGrid.js:854:14 moveItem@resource:///org/gnome/shell/ui/iconGrid.js:1277:29 _moveItem@resource:///org/gnome/shell/ui/appDisplay.js:1194:20 _redisplay/<@resource:///org/gnome/shell/ui/appDisplay.js:1085:22 _redisplay@resource:///org/gnome/shell/ui/appDisplay.js:1080:17 _redisplay@resource:///org/gnome/shell/ui/appDisplay.js:1370:15 _init/<@resource:///org/gnome/shell/ui/appDisplay.js:633:24 _initializeManager@resource:///org/gnome/shell/misc/parentalControlsManager.js:95:14 async*_init@resource:///org/gnome/shell/misc/parentalControlsManager.js:63:14 ParentalControlsManager@resource:///org/gnome/shell/misc/parentalControlsManager.js:55:4 getDefault@resource:///org/gnome/shell/misc/parentalControlsManager.js:42:22 start@resource:///org/gnome/shell/ui/main.js:184:29 @resource:///org/gnome/shell/ui/init.js:6:17 Part-of: --- js/ui/appDisplay.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js index d85526d55..8972ff33c 100644 --- a/js/ui/appDisplay.js +++ b/js/ui/appDisplay.js @@ -1228,7 +1228,7 @@ var BaseAppView = GObject.registerClass({ } goToPage(pageNumber, animate = true) { - pageNumber = Math.clamp(pageNumber, 0, this._grid.nPages - 1); + pageNumber = Math.clamp(pageNumber, 0, Math.max(this._grid.nPages - 1, 0)); if (this._grid.currentPage === pageNumber) return; @@ -1573,7 +1573,7 @@ class AppDisplay extends BaseAppView { } goToPage(pageNumber, animate = true) { - pageNumber = Math.clamp(pageNumber, 0, this._grid.nPages - 1); + pageNumber = Math.clamp(pageNumber, 0, Math.max(this._grid.nPages - 1, 0)); if (this._grid.currentPage === pageNumber && this._displayingDialog &&