Skip to content

Commit 2aef14c

Browse files
committed
gui: tidy & format
Signed-off-by: Matt Liberty <[email protected]>
1 parent e40030f commit 2aef14c

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

src/gui/src/pythonCmdInputWidget.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ static StreamCatcher* create_catcher(const bool is_stderr,
136136
}
137137

138138
// Redirect sys.stdout and sys.stderr
139-
bool redirect_python_output(stdout_write_type stdout_write,
140-
stdout_write_type stderr_write)
139+
static bool redirect_python_output(stdout_write_type stdout_write,
140+
stdout_write_type stderr_write)
141141
{
142142
PyObject* sysmod = PyImport_ImportModule("sys");
143143
if (!sysmod) {
@@ -149,8 +149,8 @@ bool redirect_python_output(stdout_write_type stdout_write,
149149
original_stderr = PyObject_GetAttrString(sysmod, "stderr");
150150

151151
// Create new catchers
152-
stdout_catcher = create_catcher(false, stdout_write);
153-
stderr_catcher = create_catcher(true, stderr_write);
152+
stdout_catcher = create_catcher(false, std::move(stdout_write));
153+
stderr_catcher = create_catcher(true, std::move(stderr_write));
154154

155155
if (!stdout_catcher || !stderr_catcher) {
156156
Py_DECREF(sysmod);
@@ -168,8 +168,10 @@ bool redirect_python_output(stdout_write_type stdout_write,
168168
return true;
169169
}
170170

171+
// TODO: Preserved for exiting the GUI back to text mode
172+
#if 0
171173
// Restore original sys.stdout/stderr
172-
void restore_python_output()
174+
static void restore_python_output()
173175
{
174176
PyObject* sysmod = PyImport_ImportModule("sys");
175177
if (!sysmod) {
@@ -195,6 +197,8 @@ void restore_python_output()
195197
Py_DECREF(sysmod);
196198
}
197199

200+
#endif
201+
198202
static PythonCmdInputWidget* widget = nullptr;
199203

200204
class PythonRef : public std::unique_ptr<PyObject>
@@ -325,13 +329,13 @@ void PythonCmdInputWidget::init()
325329
}
326330

327331
stdout_write_type stdout_write
328-
= [logger](std::string s) { logger->report("{}", s); };
329-
stdout_write_type stderr_write = [this](std::string s) {
332+
= [logger](const std::string& s) { logger->report("{}", s); };
333+
stdout_write_type stderr_write = [this](const std::string& s) {
330334
emit addResultToOutput(QString::fromStdString(s), false);
331335
};
332336

333337
if (!redirect_python_output(stdout_write, stderr_write)) {
334-
std::cerr << "Failed to redirect Python output" << std::endl;
338+
std::cerr << "Failed to redirect Python output\n";
335339
Py_Finalize();
336340
return;
337341
}

src/gui/src/pythonCmdInputWidget.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232

3333
#pragma once
3434

35+
#include <string>
36+
3537
#include "cmdInputWidget.h"
3638

3739
namespace gui {
@@ -47,9 +49,7 @@ class PythonCmdInputWidget : public CmdInputWidget
4749
void init();
4850

4951
public slots:
50-
void executeCommand(const QString& cmd,
51-
bool echo = true,
52-
bool silent = false) override;
52+
void executeCommand(const QString& cmd, bool echo, bool silent) override;
5353

5454
protected:
5555
void keyPressEvent(QKeyEvent* e) override;

src/gui/src/scriptWidget.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,8 @@ void ScriptWidget::setupInterpreterWidget()
9090

9191
input_->setWidgetFont(font());
9292

93-
connect(input_,
94-
&CmdInputWidget::textChanged,
95-
this,
96-
&ScriptWidget::outputChanged);
93+
connect(
94+
input_, &CmdInputWidget::textChanged, this, &ScriptWidget::outputChanged);
9795

9896
connect(input_, &CmdInputWidget::exiting, this, &ScriptWidget::exiting);
9997
connect(input_,

0 commit comments

Comments
 (0)