mirror of https://github.com/mgba-emu/mgba.git
Qt: Fix linking after some windows have been closed
This commit is contained in:
parent
f026c90089
commit
be3e884ba5
1
CHANGES
1
CHANGES
|
@ -26,6 +26,7 @@ Bugfixes:
|
||||||
- Tools: Fix recurring multiple times over the same library
|
- Tools: Fix recurring multiple times over the same library
|
||||||
- GBA I/O: Handle audio registers specially when deserializing
|
- GBA I/O: Handle audio registers specially when deserializing
|
||||||
- Util: Fix highest-fd socket not being returned by SocketAccept
|
- Util: Fix highest-fd socket not being returned by SocketAccept
|
||||||
|
- Qt: Fix linking after some windows have been closed
|
||||||
Misc:
|
Misc:
|
||||||
- SDL: Remove scancode key input
|
- SDL: Remove scancode key input
|
||||||
- GBA Video: Clean up unused timers
|
- GBA Video: Clean up unused timers
|
||||||
|
|
|
@ -33,7 +33,6 @@ mLOG_DEFINE_CATEGORY(QT, "Qt");
|
||||||
|
|
||||||
GBAApp::GBAApp(int& argc, char* argv[])
|
GBAApp::GBAApp(int& argc, char* argv[])
|
||||||
: QApplication(argc, argv)
|
: QApplication(argc, argv)
|
||||||
, m_windows{}
|
|
||||||
, m_db(nullptr)
|
, m_db(nullptr)
|
||||||
{
|
{
|
||||||
g_app = this;
|
g_app = this;
|
||||||
|
@ -80,10 +79,10 @@ GBAApp::GBAApp(int& argc, char* argv[])
|
||||||
AudioProcessor::setDriver(static_cast<AudioProcessor::Driver>(m_configController.getQtOption("audioDriver").toInt()));
|
AudioProcessor::setDriver(static_cast<AudioProcessor::Driver>(m_configController.getQtOption("audioDriver").toInt()));
|
||||||
}
|
}
|
||||||
Window* w = new Window(&m_configController);
|
Window* w = new Window(&m_configController);
|
||||||
connect(w, &Window::destroyed, [this]() {
|
connect(w, &Window::destroyed, [this, w]() {
|
||||||
m_windows[0] = nullptr;
|
m_windows.removeAll(w);
|
||||||
});
|
});
|
||||||
m_windows[0] = w;
|
m_windows.append(w);
|
||||||
|
|
||||||
if (loaded) {
|
if (loaded) {
|
||||||
w->argumentsPassed(&args);
|
w->argumentsPassed(&args);
|
||||||
|
@ -121,15 +120,15 @@ bool GBAApp::event(QEvent* event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Window* GBAApp::newWindow() {
|
Window* GBAApp::newWindow() {
|
||||||
if (m_multiplayer.attached() >= MAX_GBAS) {
|
if (m_windows.count() >= MAX_GBAS) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
Window* w = new Window(&m_configController, m_multiplayer.attached());
|
Window* w = new Window(&m_configController, m_multiplayer.attached());
|
||||||
int windowId = m_multiplayer.attached();
|
int windowId = m_multiplayer.attached();
|
||||||
connect(w, &Window::destroyed, [this, windowId]() {
|
connect(w, &Window::destroyed, [this, w]() {
|
||||||
m_windows[windowId] = nullptr;
|
m_windows.removeAll(w);
|
||||||
});
|
});
|
||||||
m_windows[windowId] = w;
|
m_windows.append(w);
|
||||||
w->setAttribute(Qt::WA_DeleteOnClose);
|
w->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
w->loadConfig();
|
w->loadConfig();
|
||||||
w->show();
|
w->show();
|
||||||
|
@ -142,27 +141,27 @@ GBAApp* GBAApp::app() {
|
||||||
return g_app;
|
return g_app;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GBAApp::pauseAll(QList<int>* paused) {
|
void GBAApp::pauseAll(QList<Window*>* paused) {
|
||||||
for (int i = 0; i < MAX_GBAS; ++i) {
|
for (auto& window : m_windows) {
|
||||||
if (!m_windows[i] || !m_windows[i]->controller()->isLoaded() || m_windows[i]->controller()->isPaused()) {
|
if (!window->controller()->isLoaded() || window->controller()->isPaused()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
m_windows[i]->controller()->setPaused(true);
|
window->controller()->setPaused(true);
|
||||||
paused->append(i);
|
paused->append(window);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GBAApp::continueAll(const QList<int>* paused) {
|
void GBAApp::continueAll(const QList<Window*>& paused) {
|
||||||
for (int i : *paused) {
|
for (auto& window : paused) {
|
||||||
m_windows[i]->controller()->setPaused(false);
|
window->controller()->setPaused(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GBAApp::getOpenFileName(QWidget* owner, const QString& title, const QString& filter) {
|
QString GBAApp::getOpenFileName(QWidget* owner, const QString& title, const QString& filter) {
|
||||||
QList<int> paused;
|
QList<Window*> paused;
|
||||||
pauseAll(&paused);
|
pauseAll(&paused);
|
||||||
QString filename = QFileDialog::getOpenFileName(owner, title, m_configController.getOption("lastDirectory"), filter);
|
QString filename = QFileDialog::getOpenFileName(owner, title, m_configController.getOption("lastDirectory"), filter);
|
||||||
continueAll(&paused);
|
continueAll(paused);
|
||||||
if (!filename.isEmpty()) {
|
if (!filename.isEmpty()) {
|
||||||
m_configController.setOption("lastDirectory", QFileInfo(filename).dir().path());
|
m_configController.setOption("lastDirectory", QFileInfo(filename).dir().path());
|
||||||
}
|
}
|
||||||
|
@ -170,10 +169,10 @@ QString GBAApp::getOpenFileName(QWidget* owner, const QString& title, const QStr
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GBAApp::getSaveFileName(QWidget* owner, const QString& title, const QString& filter) {
|
QString GBAApp::getSaveFileName(QWidget* owner, const QString& title, const QString& filter) {
|
||||||
QList<int> paused;
|
QList<Window*> paused;
|
||||||
pauseAll(&paused);
|
pauseAll(&paused);
|
||||||
QString filename = QFileDialog::getSaveFileName(owner, title, m_configController.getOption("lastDirectory"), filter);
|
QString filename = QFileDialog::getSaveFileName(owner, title, m_configController.getOption("lastDirectory"), filter);
|
||||||
continueAll(&paused);
|
continueAll(paused);
|
||||||
if (!filename.isEmpty()) {
|
if (!filename.isEmpty()) {
|
||||||
m_configController.setOption("lastDirectory", QFileInfo(filename).dir().path());
|
m_configController.setOption("lastDirectory", QFileInfo(filename).dir().path());
|
||||||
}
|
}
|
||||||
|
@ -181,10 +180,10 @@ QString GBAApp::getSaveFileName(QWidget* owner, const QString& title, const QStr
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GBAApp::getOpenDirectoryName(QWidget* owner, const QString& title) {
|
QString GBAApp::getOpenDirectoryName(QWidget* owner, const QString& title) {
|
||||||
QList<int> paused;
|
QList<Window*> paused;
|
||||||
pauseAll(&paused);
|
pauseAll(&paused);
|
||||||
QString filename = QFileDialog::getExistingDirectory(owner, title, m_configController.getOption("lastDirectory"));
|
QString filename = QFileDialog::getExistingDirectory(owner, title, m_configController.getOption("lastDirectory"));
|
||||||
continueAll(&paused);
|
continueAll(paused);
|
||||||
if (!filename.isEmpty()) {
|
if (!filename.isEmpty()) {
|
||||||
m_configController.setOption("lastDirectory", QFileInfo(filename).dir().path());
|
m_configController.setOption("lastDirectory", QFileInfo(filename).dir().path());
|
||||||
}
|
}
|
||||||
|
@ -249,14 +248,14 @@ GBAApp::FileDialog::FileDialog(GBAApp* app, QWidget* parent, const QString& capt
|
||||||
}
|
}
|
||||||
|
|
||||||
int GBAApp::FileDialog::exec() {
|
int GBAApp::FileDialog::exec() {
|
||||||
QList<int> paused;
|
QList<Window*> paused;
|
||||||
m_app->pauseAll(&paused);
|
m_app->pauseAll(&paused);
|
||||||
bool didAccept = QFileDialog::exec() == QDialog::Accepted;
|
bool didAccept = QFileDialog::exec() == QDialog::Accepted;
|
||||||
QStringList filenames = selectedFiles();
|
QStringList filenames = selectedFiles();
|
||||||
if (!filenames.isEmpty()) {
|
if (!filenames.isEmpty()) {
|
||||||
m_app->m_configController.setOption("lastDirectory", QFileInfo(filenames[0]).dir().path());
|
m_app->m_configController.setOption("lastDirectory", QFileInfo(filenames[0]).dir().path());
|
||||||
}
|
}
|
||||||
m_app->continueAll(&paused);
|
m_app->continueAll(paused);
|
||||||
return didAccept;
|
return didAccept;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,6 @@ private:
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
class GBAApp : public QApplication {
|
class GBAApp : public QApplication {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -78,11 +77,11 @@ private:
|
||||||
|
|
||||||
Window* newWindowInternal();
|
Window* newWindowInternal();
|
||||||
|
|
||||||
void pauseAll(QList<int>* paused);
|
void pauseAll(QList<Window*>* paused);
|
||||||
void continueAll(const QList<int>* paused);
|
void continueAll(const QList<Window*>& paused);
|
||||||
|
|
||||||
ConfigController m_configController;
|
ConfigController m_configController;
|
||||||
Window* m_windows[MAX_GBAS];
|
QList<Window*> m_windows;
|
||||||
MultiplayerController m_multiplayer;
|
MultiplayerController m_multiplayer;
|
||||||
|
|
||||||
NoIntroDB* m_db;
|
NoIntroDB* m_db;
|
||||||
|
|
Loading…
Reference in New Issue