From 229afbc9a91ff13ffb4744ef057c64ca166266ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 31 May 2018 18:09:41 +0200 Subject: [PATCH] Fix crash caused by accessing the UI thread from a background thread. ComicVineDialog was calling close from background, plus accepted is emmited from a background thread, so it needs a QueuedConnection. --- YACReaderLibrary/comic_vine/comic_vine_dialog.cpp | 8 +++----- YACReaderLibrary/library_window.cpp | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/YACReaderLibrary/comic_vine/comic_vine_dialog.cpp b/YACReaderLibrary/comic_vine/comic_vine_dialog.cpp index bb963b06..33c639d8 100644 --- a/YACReaderLibrary/comic_vine/comic_vine_dialog.cpp +++ b/YACReaderLibrary/comic_vine/comic_vine_dialog.cpp @@ -111,6 +111,8 @@ void ComicVineDialog::doConnections() connect(selectVolumeWidget,SIGNAL(loadPage(QString,int)),this,SLOT(searchVolume(QString,int))); connect(selectComicWidget,SIGNAL(loadPage(QString,int)),this,SLOT(getVolumeComicsInfo(QString,int))); connect(sortVolumeComicsWidget,SIGNAL(loadPage(QString,int)),this,SLOT(getVolumeComicsInfo(QString,int))); + + connect(this, SIGNAL(accepted()), this, SLOT(close()), Qt::QueuedConnection); } void ComicVineDialog::goNext() @@ -456,7 +458,6 @@ void ComicVineDialog::getComicsInfo(QList > & matchingIn db.close(); QSqlDatabase::removeDatabase(db.connectionName()); - close(); emit accepted(); } @@ -472,8 +473,7 @@ void ComicVineDialog::getComicInfo(const QString &comicId, int count, const QStr //TODO if(mode == SingleComic || currentIndex == (comics.count()-1)) { - close(); - emit accepted(); + emit accepted(); } else { goToNextComic(); @@ -496,7 +496,6 @@ void ComicVineDialog::getComicInfo(const QString &comicId, int count, const QStr if(mode == SingleComic || currentIndex == (comics.count()-1)) { - close(); emit accepted(); } else { @@ -645,7 +644,6 @@ void ComicVineDialog::goToNextComic() { if(mode == SingleComic || currentIndex == (comics.count()-1)) { - close(); emit accepted(); return; } diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index b1d34487..6a156aee 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -1054,7 +1054,7 @@ void LibraryWindow::createConnections() connect(propertiesDialog,SIGNAL(accepted()),navigationController,SLOT(reselectCurrentSource())); //comic vine - connect(comicVineDialog,SIGNAL(accepted()),navigationController,SLOT(reselectCurrentSource())); + connect(comicVineDialog,SIGNAL(accepted()),navigationController,SLOT(reselectCurrentSource()), Qt::QueuedConnection); connect(updateLibraryAction,SIGNAL(triggered()),this,SLOT(updateLibrary())); connect(renameLibraryAction,SIGNAL(triggered()),this,SLOT(renameLibrary()));