Skip to content

Commit

Permalink
- Adjusted zapping behavior to avoid displaying the "could not find" …
Browse files Browse the repository at this point in the history
…dialog

- Added a "Refresh" button to refresh the current list of processes
  • Loading branch information
b0bh00d committed Feb 7, 2024
1 parent 3fc77a3 commit 417dca9
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 3 deletions.
17 changes: 15 additions & 2 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ MainWindow::MainWindow(QWidget *parent)
this, &MainWindow::slot_set_control_states);
connect(m_ui->button_CrashIt, &QPushButton::clicked, this, &MainWindow::slot_crash_it);
connect(m_ui->button_Cancel, &QPushButton::clicked, qApp, &QApplication::quit);
connect(m_ui->button_Refresh, &QPushButton::clicked, this, &MainWindow::slot_manual_refresh);

connect(m_ui->combo_Processes, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &MainWindow::slot_process_changed);

Expand All @@ -36,6 +37,12 @@ MainWindow::~MainWindow()
delete m_ui;
}

void MainWindow::slot_manual_refresh()
{
m_refresh_button = true;
QTimer::singleShot(0, this, &MainWindow::slot_enumerate_processes);
}

void MainWindow::slot_process_changed(int index)
{
auto data = m_ui->combo_Processes->itemData(index).value<process_data_t>();
Expand Down Expand Up @@ -139,6 +146,8 @@ void MainWindow::slot_crash_it()
}
}

m_thunderbold_just_ran = true;

slot_set_control_states();
}

Expand Down Expand Up @@ -316,16 +325,20 @@ void MainWindow::slot_enumerate_processes()
}
}

if(parent_index == -1)
if(parent_index == -1 && !m_thunderbold_just_ran)
{
QMessageBox::critical(this, m_title, tr("Could not identify the Firefox process!"));
QTimer::singleShot(0, qApp, &QApplication::quit);
if(!m_refresh_button)
QTimer::singleShot(0, qApp, &QApplication::quit);
}
else
{
m_ui->combo_Processes->setCurrentIndex(parent_index);
slot_process_changed(parent_index);
}

m_thunderbold_just_ran = false;
m_refresh_button = false;
}

slot_set_control_states();
Expand Down
15 changes: 15 additions & 0 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ private slots:
void slot_set_control_states();
void slot_crash_it();
void slot_enumerate_processes();
void slot_manual_refresh();

void slot_thunderbolt_finished();
void slot_process_changed(int index);
Expand All @@ -50,6 +51,20 @@ private slots:
from the same thread (main).
*/
int m_thunderbolt_thread_count{0};

/*!
Make note of the fact that we just launched the Thunderbolt
process to produce a crash. If we haven't, then the lack
of a Firefox process will be noted to the user by a warning
dialog.
*/
bool m_thunderbold_just_ran{false};

/*!
If we are enumerating process on demand by the user, then
don't automatically exit the application.
*/
bool m_refresh_button{false};
};

using process_data_t = QPair<DWORD, QString>;
Expand Down
15 changes: 14 additions & 1 deletion mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>604</width>
<height>248</height>
<height>289</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -73,6 +73,19 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_Refresh">
<property name="maximumSize">
<size>
<width>80</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Refresh</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
Expand Down

0 comments on commit 417dca9

Please sign in to comment.