From fef7baaf119f64f63cca542c72a7a80f91917dd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kai=20K=C3=B6hne?= Date: Thu, 4 Jan 2024 09:10:41 +0100 Subject: [PATCH] Remove foreach snippets from the documentation We don't recommend foreach anymore, and have in fact adapted two snippets already to use for(), but missed the documentation text. In any case, it feels a bit weird to give an example how to iterate over QStringList in each of these methods, so we might as well just remove this part. Pick-to: 6.6 Change-Id: If8744e48961661ad518f5f24781c38f371d981bc Reviewed-by: Jaishree Vyas Reviewed-by: Giuseppe D'Angelo (cherry picked from commit 3b9f6b54b1cda08079ae97956478a4af55133803) Reviewed-by: Qt Cherry-pick Bot --- .../src_corelib_kernel_qcoreapplication.cpp | 6 ----- src/corelib/kernel/qcoreapplication.cpp | 5 ----- .../code/src_gui_kernel_qguiapplication.cpp | 22 ------------------- src/gui/kernel/qsessionmanager.cpp | 8 ------- 4 files changed, 41 deletions(-) diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp index b1198924c8e..8087ff8f8ba 100644 --- a/src/corelib/doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp @@ -15,12 +15,6 @@ connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::Qu //! [1] -//! [2] -foreach (const QString &path, app.libraryPaths()) - do_something(path); -//! [2] - - //! [3] // Called once QCoreApplication exists static void preRoutineMyDebugTool() diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 2752697dbae..52d39508b43 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -2990,11 +2990,6 @@ Q_GLOBAL_STATIC(QRecursiveMutex, libraryPathMutex) directory (and its existence) may change when the directory of the application executable becomes known. - If you want to iterate over the list, you can use the \l foreach - pseudo-keyword: - - \snippet code/src_corelib_kernel_qcoreapplication.cpp 2 - \sa setLibraryPaths(), addLibraryPath(), removeLibraryPath(), QLibrary, {How to Create Qt Plugins} */ diff --git a/src/gui/doc/snippets/code/src_gui_kernel_qguiapplication.cpp b/src/gui/doc/snippets/code/src_gui_kernel_qguiapplication.cpp index e9a2446b916..347b47403e4 100644 --- a/src/gui/doc/snippets/code/src_gui_kernel_qguiapplication.cpp +++ b/src/gui/doc/snippets/code/src_gui_kernel_qguiapplication.cpp @@ -74,26 +74,4 @@ appname -session id */ // wrap snippet 2 - -void wrapper0() { - - -//! [3] -const QStringList commands = mySession.restartCommand(); -for (const QString &command : commands) - do_something(command); -//! [3] - -} // wrapper0 - - -void wrapper1() { -//! [4] -const QStringList commands = mySession.discardCommand(); -for (const QString &command : mySession.discardCommand()) - do_something(command); -//! [4] - - -} // wrapper1 } // src_gui_kernel_qguiapplication diff --git a/src/gui/kernel/qsessionmanager.cpp b/src/gui/kernel/qsessionmanager.cpp index 705866f9032..0a1ff956567 100644 --- a/src/gui/kernel/qsessionmanager.cpp +++ b/src/gui/kernel/qsessionmanager.cpp @@ -281,10 +281,6 @@ void QSessionManager::setRestartCommand(const QStringList &command) /*! Returns the currently set restart command. - To iterate over the list, you can use the \l foreach pseudo-keyword: - - \snippet code/src_gui_kernel_qguiapplication.cpp 3 - \sa setRestartCommand(), restartHint() */ QStringList QSessionManager::restartCommand() const @@ -307,10 +303,6 @@ void QSessionManager::setDiscardCommand(const QStringList &command) /*! Returns the currently set discard command. - To iterate over the list, you can use the \l foreach pseudo-keyword: - - \snippet code/src_gui_kernel_qguiapplication.cpp 4 - \sa setDiscardCommand(), restartCommand(), setRestartCommand() */ QStringList QSessionManager::discardCommand() const