From c4195defe61a73afbf67a9250abf9126c4432c11 Mon Sep 17 00:00:00 2001 From: Stephan Witt Date: Sun, 16 Jul 2023 17:11:38 +0200 Subject: [PATCH] #12818 amend last change b924db72c5 - use c++ 11 compiler compatible code --- src/frontends/qt/GuiAlert.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/frontends/qt/GuiAlert.cpp b/src/frontends/qt/GuiAlert.cpp index 85a5e22d6e..288289c05d 100644 --- a/src/frontends/qt/GuiAlert.cpp +++ b/src/frontends/qt/GuiAlert.cpp @@ -109,6 +109,7 @@ buttonid doPrompt(docstring const & title, docstring const & question, // FIXME replace that with guiApp->currentView() //LYXERR0("FOCUS: " << qApp->focusWidget()); QPushButton * b[4] = { nullptr, nullptr, nullptr, nullptr }; + const size_t numbuttons = sizeof(b)/sizeof(b[0]); QMessageBox msg_box(QMessageBox::Information, toqstr(title), toqstr(question), QMessageBox::NoButton, qApp->focusWidget()); @@ -120,9 +121,9 @@ buttonid doPrompt(docstring const & title, docstring const & question, b[2] = msg_box.addButton(toqstr(b3), QMessageBox::ActionRole); if (!b4.empty()) b[3] = msg_box.addButton(toqstr(b4), QMessageBox::ActionRole); - if (default_button < size(b) && nullptr != b[default_button]) + if (default_button < numbuttons && nullptr != b[default_button]) msg_box.setDefaultButton(b[default_button]); - if (cancel_button < size(b) && nullptr != b[cancel_button]) + if (cancel_button < numbuttons && nullptr != b[cancel_button]) msg_box.setEscapeButton(static_cast(b[cancel_button])); msg_box.exec(); const QAbstractButton * button = msg_box.clickedButton(); @@ -138,7 +139,7 @@ buttonid doPrompt(docstring const & title, docstring const & question, return res; else { // Convert selection of the button into an integer - for (size_t i = 0; i < size(b); i++) { + for (size_t i = 0; i < numbuttons; i++) { if (button == b[i]) { res = i; break; -- 2.39.2