[office/kile] src: Silence various warnings with GCC 16.1

Simon Martin <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 95ba35e53a2dddfc93a3c330ecc31fba5fb1a67a by Simon Martin.
Committed on 15/08/2026 at 05:49.
Pushed by simartin into branch 'master'.

Silence various warnings with GCC 16.1

This patch removes the following warnings that I get when building with
a recent GCC:
   warning: implicit capture of ‘this’ via ‘[=]’ is deprecated in C++20
   note: add explicit ‘this’ or ‘*this’ capture

Signed-off-by: Simon Martin <[email protected]>

M  +3    -3    src/dialogs/configurationdialog.cpp
M  +3    -3    src/dialogs/statisticsdialog.cpp
M  +3    -3    src/dialogs/usermenu/usermenudialog.cpp
M  +1    -1    src/kiledocmanager.cpp
M  +10   -10   src/kileviewmanager.cpp
M  +1    -1    src/widgets/commandview.cpp

https://invent.kde.org/office/kile/-/commit/95ba35e53a2dddfc93a3c330ecc31fba5fb1a67a

diff --git a/src/dialogs/configurationdialog.cpp b/src/dialogs/configurationdialog.cpp
index 9acbb57d..12f2e0df 100644
--- a/src/dialogs/configurationdialog.cpp
+++ b/src/dialogs/configurationdialog.cpp
@@ -117,14 +117,14 @@ Config::Config(KConfig *config, KileInfo *ki, QWidget* parent)
 
     resize(sizeHint());
     // as of October 2016, 'restoreWindowSize' has no effect when called directly from here
-    QTimer::singleShot(0, this, [=] () {
+    QTimer::singleShot(0, this, [this] () {
         KWindowConfig::restoreWindowSize(windowHandle(), m_configDialogSize);
     });
     // setup connections
     //connect(m_manager, SIGNAL(widgetModified()), this, SLOT(slotWidgetModified()));
     connect(this, &KPageDialog::accepted, this, &Config::slotAcceptChanges);
     connect(this, &KPageDialog::accepted, m_manager, &KConfigDialogManager::updateSettings);
-    connect(this, &KPageDialog::rejected, this, [=] () {
+    connect(this, &KPageDialog::rejected, this, [this] () {
         m_config->markAsClean();
     });
 }
@@ -330,7 +330,7 @@ void Config::setupEditor(KPageWidgetItem* parent)
         KPageWidgetItem *pageWidgetItem = addConfigPage(parent, configPage, configPage->name(),
                                           configPage->icon(),
                                           configPage->fullName());
-        connect(configPage, &KTextEditor::ConfigPage::changed, this, [=] {
+        connect(configPage, &KTextEditor::ConfigPage::changed, this, [this] {
             m_editorSettingsChanged = true;
         });
         m_editorPages.insert(pageWidgetItem, configPage);
diff --git a/src/dialogs/statisticsdialog.cpp b/src/dialogs/statisticsdialog.cpp
index 496d3831..ee70f5e6 100644
--- a/src/dialogs/statisticsdialog.cpp
+++ b/src/dialogs/statisticsdialog.cpp
@@ -54,21 +54,21 @@ StatisticsDialog::StatisticsDialog(KileProject *project, KileDocument::TextInfo*
     buttonBox()->addButton(copyLatexButton, QDialogButtonBox::ActionRole);
     buttonBox()->button(QDialogButtonBox::Close)->setDefault(true);
 
-    connect(copyButton, &QPushButton::clicked, this, [=]() {
+    connect(copyButton, &QPushButton::clicked, this, [this]() {
         KILE_DEBUG_MAIN << "Open tab is" << currentPage()->name() << QLatin1Char(' ') + (m_pagetoname.contains(currentPage()) ?  m_pagetoname[currentPage()] : QStringLiteral("No such entry"));
         QClipboard *clip = QApplication::clipboard();
         QString text;
         convertText(&text, false);
         clip->setText(text, QClipboard::Selection); // the text will be available with the middle mouse button
     });
-    connect(copyLatexButton, &QPushButton::clicked, this, [=]() {
+    connect(copyLatexButton, &QPushButton::clicked, this, [this]() {
         KILE_DEBUG_MAIN << "Open tab is" << currentPage()->name() << QLatin1Char(' ') + (m_pagetoname.contains(currentPage()) ?  m_pagetoname[currentPage()] : QStringLiteral("No such entry"));
         QClipboard *clip = QApplication::clipboard();
         QString text;
         convertText(&text, true);
         clip->setText(text, QClipboard::Selection); // the text will be available with the middle mouse button
     });
-    connect(buttonBox(), &QDialogButtonBox::helpRequested, this, [=] () {
+    connect(buttonBox(), &QDialogButtonBox::helpRequested, this, [this] () {
         KHelpClient::invokeHelp(QStringLiteral("statistics"), QStringLiteral("kile"));
     });
 
diff --git a/src/dialogs/usermenu/usermenudialog.cpp b/src/dialogs/usermenu/usermenudialog.cpp
index dfb87cfb..1973144d 100644
--- a/src/dialogs/usermenu/usermenudialog.cpp
+++ b/src/dialogs/usermenu/usermenudialog.cpp
@@ -89,13 +89,13 @@ UserMenuDialog::UserMenuDialog(KConfig *config, KileInfo *ki, KileMenu::UserMenu
     connect(m_UserMenuDialog.m_pbMenuentryType, &QPushButton::clicked, this, &UserMenuDialog::slotMenuentryTypeClicked);
     connect(m_UserMenuDialog.m_leMenuEntry, &KLineEdit::textEdited, this, &UserMenuDialog::slotMenuentryTextChanged);
     connect(m_UserMenuDialog.m_urlRequester, &KUrlRequester::textChanged, this, &UserMenuDialog::slotUrlTextChanged);
-    connect(m_UserMenuDialog.m_urlRequester, &KUrlRequester::urlSelected, this, [=]() {
+    connect(m_UserMenuDialog.m_urlRequester, &KUrlRequester::urlSelected, this, [this]() {
         setModified();
     });
-    connect(m_UserMenuDialog.m_leParameter, &KLineEdit::textEdited, this, [=]() {
+    connect(m_UserMenuDialog.m_leParameter, &KLineEdit::textEdited, this, [this]() {
         setModified();
     });
-    connect(m_UserMenuDialog.m_teText, &QPlainTextEdit::textChanged, this, [=]() {
+    connect(m_UserMenuDialog.m_teText, &QPlainTextEdit::textChanged, this, [this]() {
         setModified();
     });
     connect(m_UserMenuDialog.m_pbIcon, &QPushButton::clicked, this, &UserMenuDialog::slotIconClicked);
diff --git a/src/kiledocmanager.cpp b/src/kiledocmanager.cpp
index f1598fed..a69d2d47 100644
--- a/src/kiledocmanager.cpp
+++ b/src/kiledocmanager.cpp
@@ -515,7 +515,7 @@ KTextEditor::Document* Manager::createDocument(const QUrl &url, TextInfo *docinf
     doc = m_editor->createDocument(nullptr);
     KILE_DEBUG_MAIN << "appending document " <<  doc;
 
-    connect(doc, &KTextEditor::Document::canceled, [=] (const QString &errMsg) {
+    connect(doc, &KTextEditor::Document::canceled, [this,url] (const QString &errMsg) {
         if(!errMsg.isEmpty()) {
             KMessageBox::error(m_ki->mainWindow(), i18n("The URL \"%1\" couldn't be opened.\n\n%2", url.toDisplayString(), errMsg),
                                i18n("Cannot open URL"));
diff --git a/src/kileviewmanager.cpp b/src/kileviewmanager.cpp
index aebd5cf1..ae72ec02 100644
--- a/src/kileviewmanager.cpp
+++ b/src/kileviewmanager.cpp
@@ -129,7 +129,7 @@ Manager::Manager(KileInfo *info, KActionCollection *actionCollection, QObject *p
     m_synchronizeViewWithCursorAction = new KToggleAction(i18n("Synchronize Cursor Position with Viewer"), this);
     connect(m_synchronizeViewWithCursorAction, &KToggleAction::toggled, this, &KileView::Manager::synchronizeViewWithCursorActionToggled);
     connect(m_synchronizeViewWithCursorAction, &KToggleAction::changed,
-    this, [=] () {
+    this, [this] () {
         m_showCursorPositionInViewerAction->setEnabled(!m_synchronizeViewWithCursorAction->isChecked());
     });
     actionCollection->addAction(QStringLiteral("synchronize_cursor_with_document_viewer"), m_synchronizeViewWithCursorAction);
@@ -238,7 +238,7 @@ QWidget * Manager::createTabs(QWidget *parent)
     m_widgetStack->insertWidget(0, emptyDropWidget);
     connect(emptyDropWidget, &KileView::DropWidget::testCanDecode, this, static_cast<void (Manager::*)(const QDragEnterEvent *, bool &)>(&Manager::testCanDecodeURLs));
     connect(emptyDropWidget, &KileView::DropWidget::receivedDropEvent, m_ki->docManager(), &KileDocument::Manager::openDroppedURLs);
-    connect(emptyDropWidget, &KileView::DropWidget::mouseDoubleClick, [=]() {
+    connect(emptyDropWidget, &KileView::DropWidget::mouseDoubleClick, [this]() {
         m_ki->docManager()->fileNew();
     });
     m_tabBar = new QTabBar(parent);
@@ -257,7 +257,7 @@ QWidget * Manager::createTabs(QWidget *parent)
     m_documentListButton->setToolTip(i18n("Show sorted list of opened documents"));
     m_documentListButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
     // lambda: update context menu
-    connect(m_documentListButton->menu(), &QMenu::aboutToShow, [=]() {
+    connect(m_documentListButton->menu(), &QMenu::aboutToShow, [this]() {
         qDeleteAll(m_documentListButton->menu()->actions());
         m_documentListButton->menu()->clear();
 
@@ -275,20 +275,20 @@ QWidget * Manager::createTabs(QWidget *parent)
         }
     });
     // lambda: handle context menu action triggers
-    connect(m_documentListButton->menu(), &QMenu::triggered, [=](QAction *action) {
+    connect(m_documentListButton->menu(), &QMenu::triggered, [this](QAction *action) {
         KTextEditor::View *view = action->data().value<KTextEditor::View*>();
         Q_ASSERT(view);
         m_tabBar->setCurrentIndex(tabIndexOf(view));
     });
     // lambda: menu button is enabled if and only if at least two documents are open
-    connect(this, &KileView::Manager::textViewCreated, [=]() {
+    connect(this, &KileView::Manager::textViewCreated, [this]() {
         m_documentListButton->setEnabled(m_tabBar->count() > 1);
     });
-    connect(this, &KileView::Manager::textViewClosed, [=]() {
+    connect(this, &KileView::Manager::textViewClosed, [this]() {
         m_documentListButton->setEnabled(m_tabBar->count() > 1);
         m_cursorPositionChangedTimer->stop();
     });
-    connect(this, &KileView::Manager::textViewClosed, [=]() {
+    connect(this, &KileView::Manager::textViewClosed, [this]() {
         m_documentListButton->setEnabled(m_tabBar->count() > 1);
     });
     tabBarWidget->layout()->addWidget(m_documentListButton);
@@ -420,7 +420,7 @@ KTextEditor::View * Manager::createTextView(KileDocument::TextInfo *info, int in
     if(action) {
         KILE_DEBUG_MAIN << "   reconnect action 'file_save'...";
         disconnect(action, &QAction::triggered, nullptr, nullptr);
-        connect(action, &QAction::triggered, [=]() {
+        connect(action, &QAction::triggered, [this]() {
             m_ki->docManager()->fileSave();
         });
     }
@@ -428,7 +428,7 @@ KTextEditor::View * Manager::createTextView(KileDocument::TextInfo *info, int in
     if(action) {
         KILE_DEBUG_MAIN << "   reconnect action 'file_save_as'...";
         disconnect(action, &QAction::triggered, nullptr, nullptr);
-        connect(action, &QAction::triggered, [=]() {
+        connect(action, &QAction::triggered, [this]() {
             m_ki->docManager()->fileSaveAs();
         });
     }
@@ -437,7 +437,7 @@ KTextEditor::View * Manager::createTextView(KileDocument::TextInfo *info, int in
     action = view->actionCollection()->action(QStringLiteral("smart_newline"));
     if(action) {
         disconnect(action, &QAction::triggered, nullptr, nullptr);
-        connect(action, &QAction::triggered, [=]() {
+        connect(action, &QAction::triggered, [this]() {
             m_ki->editorExtension()->insertIntelligentNewline();
         });
     }
diff --git a/src/widgets/commandview.cpp b/src/widgets/commandview.cpp
index b68b4edd..831f9051 100644
--- a/src/widgets/commandview.cpp
+++ b/src/widgets/commandview.cpp
@@ -67,7 +67,7 @@ CommandViewToolBox::CommandViewToolBox(KileInfo *ki, QWidget *parent)
     m_cwlFilesComboBox = new QComboBox(this);
     wrapperLayout->addWidget(m_cwlFilesComboBox);
     connect(m_cwlFilesComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
-    [=](int index) {
+    [this](int index) {
         populateCommands(m_cwlFilesComboBox->itemData(index).toString());
     });
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.