168 | @@ -169,8 +169,11 @@ void BitcoinCore::shutdown()
169 | }
170 | }
171 |
172 | -BitcoinApplication::BitcoinApplication(interfaces::Node& node, int &argc, char **argv):
173 | - QApplication(argc, argv),
174 | +static int qt_argc = 1;
175 | +static const char* qt_argv = "bitcoin-qt";
- these can be inside the function scope
- if you remove the
const here, you don't need to const_cast below (which is dangerous, as now this will be put in a .rodata section and Qt might try to write it)
these can be inside the function scope
What function? Constructor?
My suggestion is to make the constructor private and add a static BitcoinApplication::create() where you could declare a temporary static argc and argv and the app.
Please note:
Warning: The data referred to by argc and argv must stay valid for the entire lifetime of the QCoreApplication object.
* if you remove the `const` here, you don't need to `const_cast` below (which is dangerous, as now this will be put in a `.rodata` section and Qt might try to write it)
GCC complains if it is non const.
warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
My suggestion is to make the constructor private and add a static BitcoinApplication::create() where you could declare a ~temporary~ static argc and argv and the app.
That requires a copy constructor, and QApplication does not have one. Qt explicitly does not want things to be copied.
GCC complains if it is non const.
Could be:
static char qt_arg[] = "bitcoin-qt";
static char* qt_argv = qt_arg;
?
That requires a copy constructor, and QApplication does not have one. Qt explicitly does not want things to be copied.
Eh, whatever you do, please don't copy around QApplication objects, even if you could. It's a singleton.
It's also definitely not necessary to solve this.