mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-07-23 14:48:55 +02:00
qt: Fix -Wsfinae-incomplete warnings when building with GCC 16.x
According to the CMake documentation for `AUTOMOC`, all `moc` output files that are not included in a source file are aggregated into the CMake-generated `<AUTOGEN_BUILD_DIR>/mocs_compilation.cpp`, which is added to the target's sources. Within that single translation unit, `moc`-generated code checks the completeness of a signal or slot parameter type while it is still only forward-declared, and the type is completed later, when a subsequently included `moc_*.cpp` file pulls in the header that defines it. GCC 16.x diagnoses this pattern with the `-Wsfinae-incomplete` warning, which is enabled by default. Including the `moc` output files at the end of the corresponding source files excludes them from `mocs_compilation.cpp`, so each one is compiled in a translation unit where the relevant types are complete. Additionally: 1. Some of the `BitcoinGUI` class's private members are gated with `#ifdef ENABLE_WALLET` to prevent `-Wunused-private-field` warnings when building with `-DENABLE_WALLET=OFF`. 2. `test/lint/lint-includes.py` is adjusted to allow new `#include` statements.
This commit is contained in:
@@ -1721,3 +1721,5 @@ void UnitDisplayStatusBarControl::onMenuSelection(QAction* action)
|
||||
optionsModel->setDisplayUnit(action->data());
|
||||
}
|
||||
}
|
||||
|
||||
#include <moc_bitcoingui.cpp>
|
||||
|
||||
@@ -114,7 +114,9 @@ protected:
|
||||
|
||||
private:
|
||||
interfaces::Node& m_node;
|
||||
#ifdef ENABLE_WALLET
|
||||
WalletController* m_wallet_controller{nullptr};
|
||||
#endif // ENABLE_WALLET
|
||||
std::unique_ptr<interfaces::Handler> m_handler_message_box;
|
||||
std::unique_ptr<interfaces::Handler> m_handler_question;
|
||||
ClientModel* clientModel = nullptr;
|
||||
@@ -158,15 +160,17 @@ private:
|
||||
QAction* m_restore_wallet_action{nullptr};
|
||||
QAction* m_close_wallet_action{nullptr};
|
||||
QAction* m_close_all_wallets_action{nullptr};
|
||||
#ifdef ENABLE_WALLET
|
||||
QAction* m_wallet_selector_label_action = nullptr;
|
||||
QAction* m_wallet_selector_action = nullptr;
|
||||
#endif // ENABLE_WALLET
|
||||
QAction* m_mask_values_action{nullptr};
|
||||
QAction* m_migrate_wallet_action{nullptr};
|
||||
QMenu* m_migrate_wallet_menu{nullptr};
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
QLabel *m_wallet_selector_label = nullptr;
|
||||
QComboBox* m_wallet_selector = nullptr;
|
||||
|
||||
#endif // ENABLE_WALLET
|
||||
QSystemTrayIcon* trayIcon = nullptr;
|
||||
const std::unique_ptr<QMenu> trayIconMenu;
|
||||
Notificator* notificator = nullptr;
|
||||
|
||||
@@ -126,3 +126,5 @@ bool QValidatedLineEdit::isValid()
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
#include <moc_qvalidatedlineedit.cpp>
|
||||
|
||||
@@ -238,3 +238,5 @@ bool SendCoinsEntry::updateLabel(const QString &address)
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#include <moc_sendcoinsentry.cpp>
|
||||
|
||||
@@ -70,7 +70,11 @@ def find_included_cpps():
|
||||
if e.returncode > 1:
|
||||
raise e
|
||||
|
||||
return included_cpps
|
||||
# Exception: `#include <moc_*.cpp>` statements in src/qt source files are permitted.
|
||||
# See:
|
||||
# - https://doc.qt.io/qt-6/moc.html
|
||||
# - https://cmake.org/cmake/help/latest/prop_tgt/AUTOMOC.html
|
||||
return [i for i in included_cpps if not re.match(r"src/qt/[^:]+\.cpp:#include <moc_[^<>:]+\.cpp>$", i)]
|
||||
|
||||
|
||||
def find_extra_boosts():
|
||||
|
||||
Reference in New Issue
Block a user