Skip to content

Commit 46f83c1

Browse files
committed
Ensure replay loop is cancelled before window is hidden
* See also f56a989 - we don't want to make the replay loop always on top though
1 parent 31d29fc commit 46f83c1

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

qrenderdoc/Code/QRDUtils.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -2533,6 +2533,18 @@ QString RDDialog::getSaveFileName(QWidget *parent, const QString &caption, const
25332533
return QString();
25342534
}
25352535

2536+
void RDDialog::closeEvent(QCloseEvent *e)
2537+
{
2538+
emit(aboutToClose(e));
2539+
QDialog::closeEvent(e);
2540+
}
2541+
2542+
void RDDialog::keyPressEvent(QKeyEvent *e)
2543+
{
2544+
emit(keyPress(e));
2545+
QDialog::keyPressEvent(e);
2546+
}
2547+
25362548
bool QFileFilterModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
25372549
{
25382550
QModelIndex idx = sourceModel()->index(source_row, 0, source_parent);

qrenderdoc/Code/QRDUtils.h

+13-1
Original file line numberDiff line numberDiff line change
@@ -917,8 +917,12 @@ class RDSpinBox64 : public QDoubleSpinBox
917917
class QMenu;
918918

919919
// helper for doing a manual blocking invoke of a dialog
920-
struct RDDialog
920+
class RDDialog : public QDialog
921921
{
922+
private:
923+
Q_OBJECT
924+
925+
public:
922926
static const QMessageBox::StandardButtons YesNoCancel;
923927

924928
static QString DefaultBrowsePath;
@@ -995,6 +999,14 @@ struct RDDialog
995999
const QString &dir = QString(), const QString &filter = QString(),
9961000
QString *selectedFilter = NULL,
9971001
QFileDialog::Options options = QFileDialog::Options());
1002+
1003+
signals:
1004+
void aboutToClose(QCloseEvent *);
1005+
void keyPress(QKeyEvent *e);
1006+
1007+
private:
1008+
void closeEvent(QCloseEvent *) override;
1009+
void keyPressEvent(QKeyEvent *e) override;
9981010
};
9991011

10001012
class QGridLayout;

qrenderdoc/Windows/MainWindow.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -2588,7 +2588,7 @@ void MainWindow::on_action_Start_Replay_Loop_triggered()
25882588
if(!m_Ctx.IsCaptureLoaded())
25892589
return;
25902590

2591-
QDialog popup;
2591+
RDDialog popup;
25922592
popup.setWindowFlags(popup.windowFlags() & ~Qt::WindowContextHelpButtonHint);
25932593
popup.setWindowIcon(windowIcon());
25942594

@@ -2651,6 +2651,13 @@ void MainWindow::on_action_Start_Replay_Loop_triggered()
26512651

26522652
m_Ctx.Replay().AsyncInvoke([winData, id](IReplayController *r) { r->ReplayLoop(winData, id); });
26532653

2654+
QObject::connect(&popup, &RDDialog::aboutToClose,
2655+
[this](QCloseEvent *) { m_Ctx.Replay().CancelReplayLoop(); });
2656+
QObject::connect(&popup, &RDDialog::keyPress, [this](QKeyEvent *e) {
2657+
if(e->matches(QKeySequence::Cancel))
2658+
m_Ctx.Replay().CancelReplayLoop();
2659+
});
2660+
26542661
RDDialog::show(&popup);
26552662

26562663
m_Ctx.Replay().CancelReplayLoop();

0 commit comments

Comments
 (0)