Skip to content

Commit

Permalink
Fix close behavior and Chatterino process handling
Browse files Browse the repository at this point in the history
  • Loading branch information
dewcked authored Feb 19, 2022
1 parent 66b5aca commit 9d2554c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,23 +113,24 @@ void MainWindow::quitChatterino()
qDebug2() << "MainWindow::quitChatterino()";
_lChatterinoLock = true;
_wChatterinowindow->hide();
QTimer::singleShot(1000, this,
[=]()
{
_wChatterinowindow->setParent(nullptr);
system("taskkill /IM \"chatterino.exe\"");
_lChatterinoLock = false;
});
_wChatterinowindow->setParent(nullptr);
QString command = QString("taskkill /pid " + QString::number(_pChatterinoProcess->processId(), 10));
QByteArray ba = command.toLocal8Bit();
const char *c_str = ba.data();
system(c_str);
_lChatterinoLock = false;
}

void MainWindow::closeEvent(QCloseEvent *event)
{
MainWindow::quit();
event->ignore();
}

void MainWindow::quit()
{
// Add graceful quit
_lChatterinoLock = true;
_wChatterinowindow->hide();
_wChatterinowindow->setParent(nullptr);
system("taskkill /IM \"chatterino.exe\"");
_lChatterinoLock = false;
MainWindow::quitChatterino();
_pStreamlinkProcess.at(0)->kill(); // terminate doesn't work properly on Windows
_pStreamlinkProcess.at(1)->kill(); // terminate doesn't work properly on Windows
QApplication::quit();
Expand Down Expand Up @@ -434,6 +435,7 @@ void MainWindow::loadStream()
MainWindow::quitChatterino();
// Load channel if new channel exists
QTimer *loadStream = new QTimer(this);
_lChatterinoLock = true;
connect(loadStream, &QTimer::timeout, this,
[=]()
{
Expand Down
1 change: 1 addition & 0 deletions src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ private slots:
protected:
void resizeEvent(QResizeEvent *event) override;
bool eventFilter(QObject *obj, QEvent *event);
void closeEvent(QCloseEvent *event);

private:
Ui::MainWindow *ui;
Expand Down

0 comments on commit 9d2554c

Please sign in to comment.