6262#include " shared/utils/static_block.h"
6363#include " shared/utils/thread.h"
6464#include " shared/utils/consolecapture.h"
65- #include " shared/utils/odsconsolecapture.h"
6665#include " shared/ui/visualisations/defaultgradients.h"
6766#include " shared/ui/visualisations/defaultpalettes.h"
6867
@@ -170,7 +169,7 @@ static void configureProxy()
170169
171170static QString qmlError;
172171
173- int start (int argc, char *argv[])
172+ int start (int argc, char *argv[], ConsoleOutputFiles& consoleOutputFiles )
174173{
175174 if (u::currentThreadName ().isEmpty ())
176175 u::setCurrentThreadName (QStringLiteral (PRODUCT_NAME));
@@ -206,29 +205,6 @@ int start(int argc, char *argv[])
206205 app.setActivationWindow (QApplication::focusWindow ());
207206 });
208207
209- QCoreApplication::setOrganizationName (QStringLiteral (" Graphia" ));
210- QCoreApplication::setOrganizationDomain (QStringLiteral (" graphia.app" ));
211- QCoreApplication::setApplicationName (QStringLiteral (PRODUCT_NAME));
212- QCoreApplication::setApplicationVersion (QStringLiteral (VERSION));
213-
214- std::vector<std::shared_ptr<IConsoleCapture>> consoleOutputFiles;
215-
216- if (!u::isDebuggerPresent ())
217- {
218- auto appDataLocation = QStandardPaths::writableLocation (QStandardPaths::AppLocalDataLocation);
219-
220- consoleOutputFiles =
221- {
222- std::make_shared<IoStreamCapture>(QStringLiteral (" %1/cout.txt" ).arg (appDataLocation), std::cout),
223- std::make_shared<IoStreamCapture>(QStringLiteral (" %1/cerr.txt" ).arg (appDataLocation), std::cerr),
224- std::make_shared<CStreamCapture>(QStringLiteral (" %1/stdout.txt" ).arg (appDataLocation), stdout),
225- std::make_shared<CStreamCapture>(QStringLiteral (" %1/stderr.txt" ).arg (appDataLocation), stderr),
226- #ifdef Q_OS_WIN
227- std::make_shared<ODSCapture>(QStringLiteral (" %1/outputdebugstring.txt" ).arg (appDataLocation)),
228- #endif
229- };
230- }
231-
232208 QCommandLineParser commandLineParser;
233209
234210 commandLineParser.setSingleDashWordOptionMode (QCommandLineParser::ParseAsLongOptions);
@@ -484,6 +460,8 @@ int start(int argc, char *argv[])
484460 if (!settingsFileName.isEmpty ())
485461 QFile::copy (settingsFileName, QDir (directory).filePath (" settings.txt" ));
486462 });
463+ #else
464+ Q_UNUSED (consoleOutputFiles);
487465#endif
488466
489467 auto exitCode = QCoreApplication::exec ();
@@ -494,9 +472,17 @@ int main(int argc, char *argv[])
494472{
495473 u::setAppPathName (argv[0 ]);
496474
475+ QCoreApplication::setOrganizationName (QStringLiteral (" Graphia" ));
476+ QCoreApplication::setOrganizationDomain (QStringLiteral (" graphia.app" ));
477+ QCoreApplication::setApplicationName (QStringLiteral (PRODUCT_NAME));
478+ QCoreApplication::setApplicationVersion (QStringLiteral (VERSION));
479+
480+ auto consoleOutputFiles = captureConsoleOutput (
481+ QStandardPaths::writableLocation (QStandardPaths::AppLocalDataLocation));
482+
497483 // The "real" main is separate to limit the scope of QtSingleApplication,
498484 // otherwise a restart causes the exiting instance to get activated
499- auto exitCode = start (argc, argv);
485+ auto exitCode = start (argc, argv, consoleOutputFiles );
500486
501487 if (static_cast <ExitType>(exitCode) == ExitType::Restart)
502488 {
0 commit comments