summaryrefslogtreecommitdiff
path: root/src/mainwin.cc
diff options
context:
space:
mode:
authorJan Huwald <jh@sotun.de>2014-02-16 19:56:04 (GMT)
committerJan Huwald <jh@sotun.de>2014-02-16 19:56:04 (GMT)
commit7de7b1618c85d21d3f737d0981f8ae3784ac1036 (patch)
tree6a1cdfe882f7ff764a78c27ac4a18a9cf4865c0d /src/mainwin.cc
parent8f87168174e6c883260d613494082ffe791c767e (diff)
allow writing to standard output from command line, update output handler to lambda
- cmdline can output to a file or cout - output handler uses lambda instead of function pointer - this allows removing Echostream with a one-liner
Diffstat (limited to 'src/mainwin.cc')
-rw-r--r--src/mainwin.cc12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/mainwin.cc b/src/mainwin.cc
index 90db4c8..645d313 100644
--- a/src/mainwin.cc
+++ b/src/mainwin.cc
@@ -2115,23 +2115,21 @@ void MainWindow::quit()
#endif
}
-void MainWindow::consoleOutput(const std::string &msg, void *userdata)
+void MainWindow::consoleOutput(const std::string &msg)
{
// Invoke the append function in the main thread in case the output
- // originates in a worker thread.
- MainWindow *thisp = static_cast<MainWindow*>(userdata);
- QMetaObject::invokeMethod(thisp->console, "append", Qt::QueuedConnection,
- Q_ARG(QString, QString::fromLocal8Bit(msg.c_str())));
+ // originates in a worker thread.
+ QMetaObject::invokeMethod(console, "append", Qt::QueuedConnection, Q_ARG(QString, QString::fromLocal8Bit(msg.c_str())));
}
void MainWindow::setCurrentOutput()
{
- set_output_handler(&MainWindow::consoleOutput, this);
+ set_output_handler([&](std::string msg) { this->consoleOutput(msg); });
}
void MainWindow::clearCurrentOutput()
{
- set_output_handler(NULL, NULL);
+ set_output_handler(default_outputhandler);
}
void MainWindow::openCSGSettingsChanged()
contact: Jan Huwald // Impressum