Qt: Fix regression with sensor view not getting attached

This commit is contained in:
Vicki Pfau 2017-07-29 21:59:30 -07:00
parent a330df2f1f
commit 1dc4790e20
3 changed files with 20 additions and 5 deletions

View File

@ -68,6 +68,7 @@ void SensorView::setController(std::shared_ptr<CoreController> controller) {
connect(m_ui.timeFakeEpoch, &QRadioButton::clicked, [controller, this] () { connect(m_ui.timeFakeEpoch, &QRadioButton::clicked, [controller, this] () {
controller->setFakeEpoch(m_ui.time->dateTime()); controller->setFakeEpoch(m_ui.time->dateTime());
}); });
m_ui.timeButtons->checkedButton()->clicked();
connect(controller.get(), &CoreController::stopping, [this]() { connect(controller.get(), &CoreController::stopping, [this]() {
m_controller.reset(); m_controller.reset();

View File

@ -147,7 +147,6 @@ Window::Window(CoreManager* manager, ConfigController* config, int playerId, QWi
Window::~Window() { Window::~Window() {
delete m_logView; delete m_logView;
delete m_overrideView;
#ifdef USE_FFMPEG #ifdef USE_FFMPEG
delete m_videoView; delete m_videoView;
@ -1414,18 +1413,27 @@ void Window::setupMenu(QMenuBar* menubar) {
QAction* overrides = new QAction(tr("Game &overrides..."), toolsMenu); QAction* overrides = new QAction(tr("Game &overrides..."), toolsMenu);
connect(overrides, &QAction::triggered, [this]() { connect(overrides, &QAction::triggered, [this]() {
if (!m_overrideView) { if (!m_overrideView) {
m_overrideView = new OverrideView(m_config); m_overrideView = std::move(std::make_unique<OverrideView>(m_config));
if (m_controller) { if (m_controller) {
m_overrideView->setController(m_controller); m_overrideView->setController(m_controller);
} }
connect(this, &Window::shutdown, m_overrideView, &QWidget::close); connect(this, &Window::shutdown, m_overrideView.get(), &QWidget::close);
} }
m_overrideView->show(); m_overrideView->show();
}); });
addControlledAction(toolsMenu, overrides, "overrideWindow"); addControlledAction(toolsMenu, overrides, "overrideWindow");
QAction* sensors = new QAction(tr("Game &Pak sensors..."), toolsMenu); QAction* sensors = new QAction(tr("Game &Pak sensors..."), toolsMenu);
connect(sensors, &QAction::triggered, openTView<SensorView, InputController*>(&m_inputController)); connect(sensors, &QAction::triggered, [this]() {
if (!m_sensorView) {
m_sensorView = std::move(std::make_unique<SensorView>(&m_inputController));
if (m_controller) {
m_sensorView->setController(m_controller);
}
connect(this, &Window::shutdown, m_sensorView.get(), &QWidget::close);
}
m_sensorView->show();
});
addControlledAction(toolsMenu, sensors, "sensorWindow"); addControlledAction(toolsMenu, sensors, "sensorWindow");
QAction* cheats = new QAction(tr("&Cheats..."), toolsMenu); QAction* cheats = new QAction(tr("&Cheats..."), toolsMenu);
@ -1785,6 +1793,10 @@ void Window::setController(CoreController* controller, const QString& fname) {
} }
#endif #endif
if (m_sensorView) {
m_sensorView->setController(m_controller);
}
if (m_overrideView) { if (m_overrideView) {
m_overrideView->setController(m_controller); m_overrideView->setController(m_controller);
} }

View File

@ -34,6 +34,7 @@ class GIFView;
class LibraryController; class LibraryController;
class LogView; class LogView;
class OverrideView; class OverrideView;
class SensorView;
class ShaderSelector; class ShaderSelector;
class ShortcutController; class ShortcutController;
class VideoView; class VideoView;
@ -200,7 +201,8 @@ private:
bool m_hitUnimplementedBiosCall; bool m_hitUnimplementedBiosCall;
OverrideView* m_overrideView = nullptr; std::unique_ptr<OverrideView> m_overrideView;
std::unique_ptr<SensorView> m_sensorView;
#ifdef USE_FFMPEG #ifdef USE_FFMPEG
VideoView* m_videoView = nullptr; VideoView* m_videoView = nullptr;