mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
Merge #13961: util: Replace boost::signals2 with std::function
ddddce0e46e73d4ca369f2ce9696231cc579e1f9 util: Replace boost::signals2 with std::function (MarcoFalke) Pull request description: This removes the `#include <boost/signals2/signal.hpp>` from `util.h` (hopefully speeding up the build time and reducing the memory usage further after #13634) The whole translation interface is replaced by a function `G_TRANSLATION_FUN` that is set to nullptr in units that don't need translation. (Thus only set in the gui) Tree-SHA512: 087c717358bbed8bdb409463e225239d667f1ced381abb10e7cd31a41dcdd2cebe20b43c2ee86f0f8e55d53301f75e963f07421a99a7ff4c0cad2c6a375c5ab1 # Conflicts: # src/bench/bench_dash.cpp # src/qt/dash.cpp # src/qt/splashscreen.cpp # src/qt/transactiontablemodel.cpp # src/test/test_dash.cpp # src/util/system.h # src/wallet/coinselection.cpp
This commit is contained in:
parent
3d05f2af99
commit
e86ea611d4
@ -16,6 +16,8 @@
|
||||
|
||||
#include <bls/bls.h>
|
||||
|
||||
const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
|
||||
|
||||
static const int64_t DEFAULT_BENCH_EVALUATIONS = 5;
|
||||
static const char* DEFAULT_BENCH_FILTER = ".*";
|
||||
static const char* DEFAULT_BENCH_SCALING = "1.0";
|
||||
|
@ -26,6 +26,8 @@
|
||||
|
||||
#include <univalue.h>
|
||||
|
||||
const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
|
||||
|
||||
static const char DEFAULT_RPCCONNECT[] = "127.0.0.1";
|
||||
static const int DEFAULT_HTTP_CLIENT_TIMEOUT=900;
|
||||
static const bool DEFAULT_NAMED=false;
|
||||
|
@ -32,6 +32,8 @@ static bool fCreateBlank;
|
||||
static std::map<std::string,UniValue> registers;
|
||||
static const int CONTINUE_EXECUTION=-1;
|
||||
|
||||
const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
|
||||
|
||||
static void SetupBitcoinTxArgs()
|
||||
{
|
||||
gArgs.AddArg("-?", "This help message", false, OptionsCategory::OPTIONS);
|
||||
|
@ -25,6 +25,8 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
|
||||
|
||||
/* Introduction text for doxygen: */
|
||||
|
||||
/*! \mainpage Developer documentation
|
||||
|
@ -13,6 +13,8 @@
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
|
||||
#include <boost/signals2/connection.hpp>
|
||||
|
||||
static bool noui_ThreadSafeMessageBox(const std::string& message, const std::string& caption, unsigned int style)
|
||||
{
|
||||
bool fSecure = style & CClientUIInterface::SECURE;
|
||||
|
@ -61,6 +61,8 @@
|
||||
#include <QUrlQuery>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
const std::string BitcoinGUI::DEFAULT_UIPLATFORM =
|
||||
#if defined(Q_OS_MAC)
|
||||
"macosx"
|
||||
|
@ -76,13 +76,10 @@ static void InitMessage(const std::string &message)
|
||||
LogPrintf("init message: %s\n", message);
|
||||
}
|
||||
|
||||
/*
|
||||
Translate string to current locale using Qt.
|
||||
*/
|
||||
static std::string Translate(const char* psz)
|
||||
{
|
||||
/** Translate string to current locale using Qt. */
|
||||
const std::function<std::string(const char*)> G_TRANSLATION_FUN = [](const char* psz) {
|
||||
return QCoreApplication::translate("dash-core", psz).toStdString();
|
||||
}
|
||||
};
|
||||
|
||||
static QString GetLangTerritory()
|
||||
{
|
||||
@ -628,7 +625,6 @@ int main(int argc, char *argv[])
|
||||
// Now that QSettings are accessible, initialize translations
|
||||
QTranslator qtTranslatorBase, qtTranslator, translatorBase, translator;
|
||||
initTranslations(qtTranslatorBase, qtTranslator, translatorBase, translator);
|
||||
translationInterface.Translate.connect(Translate);
|
||||
|
||||
if (gArgs.IsArgSet("-printcrashinfo")) {
|
||||
auto crashInfo = GetCrashInfoStrFromSerializedStr(gArgs.GetArg("-printcrashinfo", ""));
|
||||
|
@ -18,8 +18,8 @@
|
||||
#include <interfaces/handler.h>
|
||||
#include <interfaces/node.h>
|
||||
#include <interfaces/wallet.h>
|
||||
#include <util/system.h>
|
||||
#include <ui_interface.h>
|
||||
#include <util/system.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <QApplication>
|
||||
@ -27,6 +27,8 @@
|
||||
#include <QDesktopWidget>
|
||||
#include <QPainter>
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
SplashScreen::SplashScreen(interfaces::Node& node, Qt::WindowFlags f, const NetworkStyle *networkStyle) :
|
||||
QWidget(0, f), curAlignment(0), m_node(node)
|
||||
{
|
||||
|
@ -13,10 +13,10 @@
|
||||
#include <core_io.h>
|
||||
#include <interfaces/handler.h>
|
||||
#include <interfaces/node.h>
|
||||
#include <validation.h>
|
||||
#include <sync.h>
|
||||
#include <uint256.h>
|
||||
#include <util/system.h>
|
||||
#include <validation.h>
|
||||
|
||||
#include <QColor>
|
||||
#include <QDateTime>
|
||||
@ -24,6 +24,8 @@
|
||||
#include <QIcon>
|
||||
#include <QList>
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
// Amount column is right-aligned it contains numbers
|
||||
static int column_alignments[] = {
|
||||
Qt::AlignLeft|Qt::AlignVCenter, /* status */
|
||||
|
@ -9,15 +9,16 @@
|
||||
#include <consensus/validation.h>
|
||||
#include <crypto/sha256.h>
|
||||
#include <index/txindex.h>
|
||||
#include <validation.h>
|
||||
#include <miner.h>
|
||||
#include <net_processing.h>
|
||||
#include <pow.h>
|
||||
#include <ui_interface.h>
|
||||
#include <streams.h>
|
||||
#include <rpc/server.h>
|
||||
#include <rpc/register.h>
|
||||
#include <rpc/server.h>
|
||||
#include <script/sigcache.h>
|
||||
#include <streams.h>
|
||||
#include <ui_interface.h>
|
||||
#include <validation.h>
|
||||
|
||||
#include <util/validation.h>
|
||||
|
||||
#include <coinjoin/coinjoin.h>
|
||||
@ -26,6 +27,8 @@
|
||||
#include <evo/cbtx.h>
|
||||
#include <llmq/quorums_init.h>
|
||||
|
||||
const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
|
||||
|
||||
void CConnmanTest::AddNode(CNode& node)
|
||||
{
|
||||
LOCK(g_connman->cs_vNodes);
|
||||
|
@ -6,20 +6,20 @@
|
||||
#include <config/dash-config.h>
|
||||
#endif
|
||||
|
||||
#include <consensus/merkle.h>
|
||||
#include <primitives/block.h>
|
||||
#include <script/script.h>
|
||||
#include <addrman.h>
|
||||
#include <blockencodings.h>
|
||||
#include <chain.h>
|
||||
#include <coins.h>
|
||||
#include <compressor.h>
|
||||
#include <consensus/merkle.h>
|
||||
#include <net.h>
|
||||
#include <primitives/block.h>
|
||||
#include <protocol.h>
|
||||
#include <pubkey.h>
|
||||
#include <script/script.h>
|
||||
#include <streams.h>
|
||||
#include <undo.h>
|
||||
#include <version.h>
|
||||
#include <pubkey.h>
|
||||
#include <blockencodings.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
@ -28,6 +28,8 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
|
||||
|
||||
enum TEST_ID {
|
||||
CBLOCK_DESERIALIZE=0,
|
||||
CTRANSACTION_DESERIALIZE,
|
||||
|
@ -99,8 +99,6 @@ const char * const BITCOIN_PID_FILENAME = "dashd.pid";
|
||||
|
||||
ArgsManager gArgs;
|
||||
|
||||
CTranslationInterface translationInterface;
|
||||
|
||||
/** Init OpenSSL library multithreading support */
|
||||
static std::unique_ptr<CCriticalSection[]> ppmutexOpenSSL;
|
||||
void locking_callback(int mode, int i, const char* file, int line) NO_THREAD_SAFETY_ANALYSIS
|
||||
|
@ -22,8 +22,8 @@
|
||||
#include <sync.h>
|
||||
#include <util/threadnames.h>
|
||||
#include <tinyformat.h>
|
||||
#include <util/time.h>
|
||||
#include <util/memory.h>
|
||||
#include <util/time.h>
|
||||
#include <amount.h>
|
||||
|
||||
#include <atomic>
|
||||
@ -36,7 +36,6 @@
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/signals2/signal.hpp>
|
||||
#include <boost/thread/condition_variable.hpp> // for boost::thread_interrupted
|
||||
|
||||
// Debugging macros
|
||||
@ -59,27 +58,19 @@ extern int nWalletBackups;
|
||||
// Application startup time (used for uptime calculation)
|
||||
int64_t GetStartupTime();
|
||||
|
||||
/** Signals for translation. */
|
||||
class CTranslationInterface
|
||||
{
|
||||
public:
|
||||
/** Translate a message to the native language of the user. */
|
||||
boost::signals2::signal<std::string (const char* psz)> Translate;
|
||||
};
|
||||
|
||||
extern CTranslationInterface translationInterface;
|
||||
|
||||
extern const char * const BITCOIN_CONF_FILENAME;
|
||||
extern const char * const BITCOIN_PID_FILENAME;
|
||||
|
||||
/** Translate a message to the native language of the user. */
|
||||
const extern std::function<std::string(const char*)> G_TRANSLATION_FUN;
|
||||
|
||||
/**
|
||||
* Translation function: Call Translate signal on UI interface, which returns a boost::optional result.
|
||||
* If no translation slot is registered, nothing is returned, and simply return the input.
|
||||
* Translation function.
|
||||
* If no translation function is set, simply return the input.
|
||||
*/
|
||||
inline std::string _(const char* psz)
|
||||
{
|
||||
boost::optional<std::string> rv = translationInterface.Translate(psz);
|
||||
return rv ? (*rv) : psz;
|
||||
return G_TRANSLATION_FUN ? (G_TRANSLATION_FUN)(psz) : psz;
|
||||
}
|
||||
|
||||
void SetupEnvironment();
|
||||
|
@ -3,6 +3,7 @@
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <wallet/coinselection.h>
|
||||
|
||||
#include <util/system.h>
|
||||
#include <util/moneystr.h>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user