Skip to content

Commit 417dca9

Browse files
committed
- Adjusted zapping behavior to avoid displaying the "could not find" dialog
- Added a "Refresh" button to refresh the current list of processes
1 parent 3fc77a3 commit 417dca9

3 files changed

Lines changed: 44 additions & 3 deletions

File tree

mainwindow.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ MainWindow::MainWindow(QWidget *parent)
1919
this, &MainWindow::slot_set_control_states);
2020
connect(m_ui->button_CrashIt, &QPushButton::clicked, this, &MainWindow::slot_crash_it);
2121
connect(m_ui->button_Cancel, &QPushButton::clicked, qApp, &QApplication::quit);
22+
connect(m_ui->button_Refresh, &QPushButton::clicked, this, &MainWindow::slot_manual_refresh);
2223

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

@@ -36,6 +37,12 @@ MainWindow::~MainWindow()
3637
delete m_ui;
3738
}
3839

40+
void MainWindow::slot_manual_refresh()
41+
{
42+
m_refresh_button = true;
43+
QTimer::singleShot(0, this, &MainWindow::slot_enumerate_processes);
44+
}
45+
3946
void MainWindow::slot_process_changed(int index)
4047
{
4148
auto data = m_ui->combo_Processes->itemData(index).value<process_data_t>();
@@ -139,6 +146,8 @@ void MainWindow::slot_crash_it()
139146
}
140147
}
141148

149+
m_thunderbold_just_ran = true;
150+
142151
slot_set_control_states();
143152
}
144153

@@ -316,16 +325,20 @@ void MainWindow::slot_enumerate_processes()
316325
}
317326
}
318327

319-
if(parent_index == -1)
328+
if(parent_index == -1 && !m_thunderbold_just_ran)
320329
{
321330
QMessageBox::critical(this, m_title, tr("Could not identify the Firefox process!"));
322-
QTimer::singleShot(0, qApp, &QApplication::quit);
331+
if(!m_refresh_button)
332+
QTimer::singleShot(0, qApp, &QApplication::quit);
323333
}
324334
else
325335
{
326336
m_ui->combo_Processes->setCurrentIndex(parent_index);
327337
slot_process_changed(parent_index);
328338
}
339+
340+
m_thunderbold_just_ran = false;
341+
m_refresh_button = false;
329342
}
330343

331344
slot_set_control_states();

mainwindow.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ private slots:
2828
void slot_set_control_states();
2929
void slot_crash_it();
3030
void slot_enumerate_processes();
31+
void slot_manual_refresh();
3132

3233
void slot_thunderbolt_finished();
3334
void slot_process_changed(int index);
@@ -50,6 +51,20 @@ private slots:
5051
from the same thread (main).
5152
*/
5253
int m_thunderbolt_thread_count{0};
54+
55+
/*!
56+
Make note of the fact that we just launched the Thunderbolt
57+
process to produce a crash. If we haven't, then the lack
58+
of a Firefox process will be noted to the user by a warning
59+
dialog.
60+
*/
61+
bool m_thunderbold_just_ran{false};
62+
63+
/*!
64+
If we are enumerating process on demand by the user, then
65+
don't automatically exit the application.
66+
*/
67+
bool m_refresh_button{false};
5368
};
5469

5570
using process_data_t = QPair<DWORD, QString>;

mainwindow.ui

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<x>0</x>
88
<y>0</y>
99
<width>604</width>
10-
<height>248</height>
10+
<height>289</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -73,6 +73,19 @@
7373
</property>
7474
</widget>
7575
</item>
76+
<item>
77+
<widget class="QPushButton" name="button_Refresh">
78+
<property name="maximumSize">
79+
<size>
80+
<width>80</width>
81+
<height>16777215</height>
82+
</size>
83+
</property>
84+
<property name="text">
85+
<string>Refresh</string>
86+
</property>
87+
</widget>
88+
</item>
7689
</layout>
7790
</item>
7891
<item>

0 commit comments

Comments
 (0)