Skip to content

Commit

Permalink
Merge pull request #7317 from spycrab/qt_fix_mpbtn_crash
Browse files Browse the repository at this point in the history
Qt/MappingButton: Fix crash when exiting during input detection
  • Loading branch information
spycrab committed Aug 12, 2018
2 parents 3d0ea98 + 159d5a6 commit 1c324c8
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Source/Core/DolphinQt/Config/Mapping/MappingButton.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// Refer to the license.txt file included. // Refer to the license.txt file included.


#include <future> #include <future>
#include <thread>
#include <utility> #include <utility>


#include <QApplication> #include <QApplication>
Expand All @@ -23,6 +22,7 @@
#include "DolphinQt/Config/Mapping/MappingWidget.h" #include "DolphinQt/Config/Mapping/MappingWidget.h"
#include "DolphinQt/Config/Mapping/MappingWindow.h" #include "DolphinQt/Config/Mapping/MappingWindow.h"
#include "DolphinQt/QtUtils/BlockUserInputFilter.h" #include "DolphinQt/QtUtils/BlockUserInputFilter.h"
#include "DolphinQt/QtUtils/QueueOnObject.h"
#include "DolphinQt/Settings.h" #include "DolphinQt/Settings.h"


#include "InputCommon/ControlReference/ControlReference.h" #include "InputCommon/ControlReference/ControlReference.h"
Expand Down Expand Up @@ -110,9 +110,12 @@ void MappingButton::Detect()
grabKeyboard(); grabKeyboard();


// Make sure that we don't block event handling // Make sure that we don't block event handling
std::thread thread([this] { QueueOnObject(this, [this] {
setText(QStringLiteral("...")); setText(QStringLiteral("..."));


// The button text won't be updated if we don't process events here
QApplication::processEvents();

// Avoid that the button press itself is registered as an event // Avoid that the button press itself is registered as an event
Common::SleepCurrentThread(100); Common::SleepCurrentThread(100);


Expand Down Expand Up @@ -188,8 +191,6 @@ void MappingButton::Detect()
OnButtonTimeout(); OnButtonTimeout();
} }
}); });

thread.detach();
} }


void MappingButton::OnButtonTimeout() void MappingButton::OnButtonTimeout()
Expand Down

0 comments on commit 1c324c8

Please sign in to comment.