mirror of https://github.com/mgba-emu/mgba.git
Qt: Fix horrific memory leak
This commit is contained in:
parent
87d4dad893
commit
c0689783da
|
@ -71,7 +71,6 @@ Window::Window(ConfigController* config, int playerId, QWidget* parent)
|
||||||
#endif
|
#endif
|
||||||
, m_mruMenu(nullptr)
|
, m_mruMenu(nullptr)
|
||||||
, m_shortcutController(new ShortcutController(this))
|
, m_shortcutController(new ShortcutController(this))
|
||||||
, m_playerId(playerId)
|
|
||||||
, m_fullscreenOnStart(false)
|
, m_fullscreenOnStart(false)
|
||||||
, m_autoresume(false)
|
, m_autoresume(false)
|
||||||
{
|
{
|
||||||
|
@ -380,14 +379,10 @@ void Window::selectSave(bool temporary) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::multiplayerChanged() {
|
void Window::multiplayerChanged() {
|
||||||
disconnect(nullptr, this, SLOT(multiplayerChanged()));
|
|
||||||
int attached = 1;
|
int attached = 1;
|
||||||
MultiplayerController* multiplayer = m_controller->multiplayerController();
|
MultiplayerController* multiplayer = m_controller->multiplayerController();
|
||||||
if (multiplayer) {
|
if (multiplayer) {
|
||||||
attached = multiplayer->attached();
|
attached = multiplayer->attached();
|
||||||
connect(multiplayer, SIGNAL(gameAttached()), this, SLOT(multiplayerChanged()));
|
|
||||||
connect(multiplayer, SIGNAL(gameDetached()), this, SLOT(multiplayerChanged()));
|
|
||||||
m_playerId = multiplayer->playerId(m_controller);
|
|
||||||
}
|
}
|
||||||
if (m_controller->isLoaded()) {
|
if (m_controller->isLoaded()) {
|
||||||
for (QAction* action : m_nonMpActions) {
|
for (QAction* action : m_nonMpActions) {
|
||||||
|
@ -842,7 +837,14 @@ void Window::updateTitle(float fps) {
|
||||||
}
|
}
|
||||||
MultiplayerController* multiplayer = m_controller->multiplayerController();
|
MultiplayerController* multiplayer = m_controller->multiplayerController();
|
||||||
if (multiplayer && multiplayer->attached() > 1) {
|
if (multiplayer && multiplayer->attached() > 1) {
|
||||||
title += tr(" - Player %1 of %2").arg(m_playerId + 1).arg(multiplayer->attached());
|
title += tr(" - Player %1 of %2").arg(multiplayer->playerId(m_controller) + 1).arg(multiplayer->attached());
|
||||||
|
for (QAction* action : m_nonMpActions) {
|
||||||
|
action->setDisabled(true);
|
||||||
|
}
|
||||||
|
} else if (m_controller->isLoaded()) {
|
||||||
|
for (QAction* action : m_nonMpActions) {
|
||||||
|
action->setDisabled(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
m_controller->threadContinue();
|
m_controller->threadContinue();
|
||||||
if (title.isNull()) {
|
if (title.isNull()) {
|
||||||
|
@ -1055,7 +1057,6 @@ void Window::setupMenu(QMenuBar* menubar) {
|
||||||
frameAdvance->setShortcut(tr("Ctrl+N"));
|
frameAdvance->setShortcut(tr("Ctrl+N"));
|
||||||
connect(frameAdvance, SIGNAL(triggered()), m_controller, SLOT(frameAdvance()));
|
connect(frameAdvance, SIGNAL(triggered()), m_controller, SLOT(frameAdvance()));
|
||||||
m_gameActions.append(frameAdvance);
|
m_gameActions.append(frameAdvance);
|
||||||
m_nonMpActions.append(frameAdvance);
|
|
||||||
addControlledAction(emulationMenu, frameAdvance, "frameAdvance");
|
addControlledAction(emulationMenu, frameAdvance, "frameAdvance");
|
||||||
|
|
||||||
emulationMenu->addSeparator();
|
emulationMenu->addSeparator();
|
||||||
|
@ -1511,6 +1512,9 @@ void Window::updateMRU() {
|
||||||
if (!m_mruMenu) {
|
if (!m_mruMenu) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
for (QAction* action : m_mruMenu->actions()) {
|
||||||
|
delete action;
|
||||||
|
}
|
||||||
m_mruMenu->clear();
|
m_mruMenu->clear();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (const QString& file : m_mruFiles) {
|
for (const QString& file : m_mruFiles) {
|
||||||
|
|
|
@ -173,7 +173,6 @@ private:
|
||||||
QMenu* m_mruMenu;
|
QMenu* m_mruMenu;
|
||||||
ShortcutController* m_shortcutController;
|
ShortcutController* m_shortcutController;
|
||||||
ShaderSelector* m_shaderView;
|
ShaderSelector* m_shaderView;
|
||||||
int m_playerId;
|
|
||||||
bool m_fullscreenOnStart;
|
bool m_fullscreenOnStart;
|
||||||
QTimer m_focusCheck;
|
QTimer m_focusCheck;
|
||||||
bool m_autoresume;
|
bool m_autoresume;
|
||||||
|
|
Loading…
Reference in New Issue