From 3bc0af149b50056babc2aca6ad9864092688ffda Mon Sep 17 00:00:00 2001 From: mjbudd77 Date: Tue, 8 Mar 2022 20:08:03 -0500 Subject: [PATCH] Changed family keyboard key map dialog logic to prevent premature deletion of object during close. --- src/drivers/Qt/FamilyKeyboard.cpp | 25 +++++++++++++++++++------ src/drivers/Qt/FamilyKeyboard.h | 1 + 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/drivers/Qt/FamilyKeyboard.cpp b/src/drivers/Qt/FamilyKeyboard.cpp index 8bed5704..95d85157 100644 --- a/src/drivers/Qt/FamilyKeyboard.cpp +++ b/src/drivers/Qt/FamilyKeyboard.cpp @@ -1449,6 +1449,7 @@ FKBKeyMapDialog::FKBKeyMapDialog( int idx, QWidget *parent ) keyIdx = idx; buttonConfigStatus = 0; + waitingForButton = false; mainLayout = new QVBoxLayout(); hbox = new QHBoxLayout(); @@ -1499,6 +1500,8 @@ void FKBKeyMapDialog::enterButtonLoop(void) { buttonConfigStatus = 2; + waitingForButton = true; + ButtonConfigBegin(); DWaitButton(NULL, &fkbmap[ keyIdx ], &buttonConfigStatus); @@ -1507,25 +1510,35 @@ void FKBKeyMapDialog::enterButtonLoop(void) buttonConfigStatus = 1; + waitingForButton = false; + done(0); deleteLater(); } //********************************************************************************* void FKBKeyMapDialog::closeEvent(QCloseEvent *event) { - printf("FKB Key Map Close Window Event\n"); + //printf("FKB Key Map Close Window Event\n"); buttonConfigStatus = 0; - done(0); - deleteLater(); + + if ( !waitingForButton ) + { + done(0); + deleteLater(); + } event->accept(); } //********************************************************************************* void FKBKeyMapDialog::closeWindow(void) { - printf("Close Window\n"); + //printf("Close Window\n"); buttonConfigStatus = 0; - done(0); - deleteLater(); + + if ( !waitingForButton ) + { + done(0); + deleteLater(); + } } //********************************************************************************* void FKBKeyMapDialog::keyPressEvent(QKeyEvent *event) diff --git a/src/drivers/Qt/FamilyKeyboard.h b/src/drivers/Qt/FamilyKeyboard.h index c0946907..2e006efb 100644 --- a/src/drivers/Qt/FamilyKeyboard.h +++ b/src/drivers/Qt/FamilyKeyboard.h @@ -124,6 +124,7 @@ protected: QLabel *msgLbl; QLabel *curMapLbl; + bool waitingForButton; public slots: void closeWindow(void);