Skip to content

Commit f0fd636

Browse files
committed
Fix crash on exit + minor improvements
1 parent 4b7aa17 commit f0fd636

File tree

7 files changed

+22
-26
lines changed

7 files changed

+22
-26
lines changed

gamepadForm.cpp

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,16 @@ GamepadForm::GamepadForm()
5353

5454
GamepadForm::~GamepadForm()
5555
{
56-
delete mUi;
56+
thread.quit();
57+
thread.wait();
5758

58-
// To prevent strange stack overflow crash on exit on Linux
59-
delete videoWidget;
59+
delete player;
60+
delete mUi;
6061
}
6162

6263
void GamepadForm::startControllerFromSysArgs(const QStringList &args)
6364
{
64-
const auto &gamepadIp = args.at(1);
65+
const auto &gamepadIp = args.at(1);
6566
const auto &gamepadPort = args.size() < 3 ? "4444" : args.at(2);
6667
const auto &cameraPort = args.size() < 4 ? "8080" : args.at(3);
6768
const auto &cameraIp = args.size() < 5 ? gamepadIp : args.at(4);
@@ -72,13 +73,6 @@ void GamepadForm::startControllerFromSysArgs(const QStringList &args)
7273
Q_EMIT newConnectionParameters();
7374
}
7475

75-
void GamepadForm::closeEvent(QCloseEvent *event)
76-
{
77-
thread.quit();
78-
thread.wait();
79-
QWidget::closeEvent(event);
80-
}
81-
8276
void GamepadForm::setUpGamepadForm()
8377
{
8478
createMenu();
@@ -470,7 +464,7 @@ void GamepadForm::sendCommand(const QString &command)
470464
}
471465

472466
void GamepadForm::changeMode(Strategies type)
473-
{
467+
{
474468
auto oldStratedy = strategy;
475469
strategy = Strategy::getStrategy(type, this);
476470
connect(strategy, &Strategy::commandPrepared, this, &GamepadForm::sendCommand);
@@ -532,9 +526,9 @@ void GamepadForm::saveImageToClipboard(QVideoFrame buffer)
532526
int g = y - int(0.39465 * (u - 128)) - int(0.58060 * (v - 128));
533527
int b = y + int(2.03211 * (u - 128));
534528

535-
r = r < 0 ? 0 : r > 255 ? 255 : r;
536-
g = g < 0 ? 0 : g > 255 ? 255 : g;
537-
b = b < 0 ? 0 : b > 255 ? 255 : b;
529+
r = qBound(0, r, 255);
530+
g = qBound(0, g, 255);
531+
b = qBound(0, b, 255);
538532

539533
img.setPixel(j, i, qRgb(r, g, b));
540534
}
@@ -551,7 +545,7 @@ void GamepadForm::requestImage()
551545
}
552546

553547
void GamepadForm::openConnectDialog()
554-
{
548+
{
555549
mMyNewConnectForm = new ConnectForm(connectionManager, &mSettings, this);
556550
connect(mMyNewConnectForm, &ConnectForm::newConnectionParameters, this, &GamepadForm::newConnectionParameters);
557551
mMyNewConnectForm->show();

gamepadForm.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,8 @@ class GamepadForm : public QWidget
6161
~GamepadForm() override;
6262
/// method that sets up connection manager and connect to host
6363
void startControllerFromSysArgs(const QStringList &args);
64-
virtual void closeEvent(QCloseEvent *event) override;
6564

66-
public slots:
65+
public Q_SLOTS:
6766

6867
/// Slot for opening connect dialog
6968
void openConnectDialog();
@@ -74,7 +73,7 @@ public slots:
7473
/// Slot for about menu item
7574
void about();
7675

77-
private slots:
76+
private Q_SLOTS:
7877

7978
/// Slots for pad buttons (Up, Down, Left, Right) and "magic" buttons, triggered when button is pressed.
8079
void handleButtonPress(QWidget*);
@@ -126,7 +125,7 @@ private slots:
126125
void saveImageToClipboard(QVideoFrame buffer);
127126
void requestImage();
128127

129-
signals:
128+
Q_SIGNALS:
130129
/// signal to send command
131130
void commandReceived(QString);
132131
/// signal to disconnect from host

languages/trikDesktopGamepad_de.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ Buttons enabled.</source>
171171
Buttons aktiviert.</translation>
172172
</message>
173173
<message>
174-
<location filename="../gamepadForm.cpp" line="+238"/>
174+
<location filename="../gamepadForm.cpp" line="+232"/>
175175
<source>Couldn&apos;t connect to robot</source>
176176
<translation>Fehler beim Roboter zu verbinden</translation>
177177
</message>

languages/trikDesktopGamepad_en.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ Buttons disabled.</source>
165165
Buttons disabled.</translation>
166166
</message>
167167
<message>
168-
<location filename="../gamepadForm.cpp" line="+238"/>
168+
<location filename="../gamepadForm.cpp" line="+232"/>
169169
<source>Couldn&apos;t connect to robot</source>
170170
<translation>Failed to connect to robot</translation>
171171
</message>

languages/trikDesktopGamepad_fr.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ Buttons enabled.</source>
171171
Boutons activés.</translation>
172172
</message>
173173
<message>
174-
<location filename="../gamepadForm.cpp" line="+238"/>
174+
<location filename="../gamepadForm.cpp" line="+232"/>
175175
<source>Couldn&apos;t connect to robot</source>
176176
<translation>Impossible de se connecter au robot de</translation>
177177
</message>

languages/trikDesktopGamepad_ru.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ Buttons disabled.</source>
169169
Кнопки выключены.</translation>
170170
</message>
171171
<message>
172-
<location filename="../gamepadForm.cpp" line="+238"/>
172+
<location filename="../gamepadForm.cpp" line="+232"/>
173173
<source>Couldn&apos;t connect to robot</source>
174174
<translation>Не удалось подключиться к роботу</translation>
175175
</message>

lsan.supp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
leak:*/libfontconfig.so.1*
2-
#leaks private object as of Qt5.12.7
2+
leak:g_quark_init
3+
#leaks private object as of Qt5.15.3
34
leak:QVideoProbe::QVideoProbe
45
leak:QVideoProbe::setSource(QMediaObject*)
56
leak:QVideoWidget::setMediaObject(QMediaObject*)
6-
leak:QXcbIntegration::createPlatformWindow
7+
8+
#leaks in Qt5.12
9+
#leak:QXcbIntegration::createPlatformWindow

0 commit comments

Comments
 (0)