mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-14 14:32:15 -07:00
Fix segfault from status bar
Pass just the relevant data through the signals to the status bar, instead of passing the entire Work object. That way the data is detached from the Work object and we won't segfault when Work self-deletes before status bar tries to use that data.
This commit is contained in:
parent
18cbf520e3
commit
0ce1281eca
6 changed files with 24 additions and 24 deletions
|
|
@ -2,23 +2,22 @@
|
|||
|
||||
PictureLoaderRequestStatusDisplayWidget::PictureLoaderRequestStatusDisplayWidget(QWidget *parent,
|
||||
const QUrl &_url,
|
||||
PictureLoaderWorkerWork *worker)
|
||||
const CardInfoPtr &card,
|
||||
const QString &setName)
|
||||
: QWidget(parent)
|
||||
{
|
||||
layout = new QHBoxLayout(this);
|
||||
|
||||
if (worker->cardToDownload.getCard()) {
|
||||
name = new QLabel(this);
|
||||
name->setText(worker->cardToDownload.getCard()->getName());
|
||||
setShortname = new QLabel(this);
|
||||
setShortname->setText(worker->cardToDownload.getSetName());
|
||||
providerId = new QLabel(this);
|
||||
providerId->setText(worker->cardToDownload.getCard()->getProperty("uuid"));
|
||||
name = new QLabel(this);
|
||||
name->setText(card->getName());
|
||||
setShortname = new QLabel(this);
|
||||
setShortname->setText(setName);
|
||||
providerId = new QLabel(this);
|
||||
providerId->setText(card->getProperty("uuid"));
|
||||
|
||||
layout->addWidget(name);
|
||||
layout->addWidget(setShortname);
|
||||
layout->addWidget(providerId);
|
||||
}
|
||||
layout->addWidget(name);
|
||||
layout->addWidget(setShortname);
|
||||
layout->addWidget(providerId);
|
||||
|
||||
startTime = new QLabel(QDateTime::currentDateTime().toString(), this);
|
||||
elapsedTime = new QLabel("0", this);
|
||||
|
|
|
|||
|
|
@ -10,8 +10,10 @@ class PictureLoaderRequestStatusDisplayWidget : public QWidget
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PictureLoaderRequestStatusDisplayWidget(QWidget *parent, const QUrl &url, PictureLoaderWorkerWork *worker);
|
||||
PictureLoaderWorkerWork *worker;
|
||||
PictureLoaderRequestStatusDisplayWidget(QWidget *parent,
|
||||
const QUrl &url,
|
||||
const CardInfoPtr &card,
|
||||
const QString &setName);
|
||||
|
||||
void setFinished()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -38,15 +38,14 @@ void PictureLoaderStatusBar::cleanOldEntries()
|
|||
}
|
||||
}
|
||||
|
||||
void PictureLoaderStatusBar::addQueuedImageLoad(const QUrl &url, PictureLoaderWorkerWork *worker)
|
||||
void PictureLoaderStatusBar::addQueuedImageLoad(const QUrl &url, const CardInfoPtr &card, const QString &setName)
|
||||
{
|
||||
loadLog->addSettingsWidget(new PictureLoaderRequestStatusDisplayWidget(loadLog, url, worker));
|
||||
loadLog->addSettingsWidget(new PictureLoaderRequestStatusDisplayWidget(loadLog, url, card, setName));
|
||||
progressBar->setMaximum(progressBar->maximum() + 1);
|
||||
}
|
||||
|
||||
void PictureLoaderStatusBar::addSuccessfulImageLoad(const QUrl &url, PictureLoaderWorkerWork *worker)
|
||||
void PictureLoaderStatusBar::addSuccessfulImageLoad(const QUrl &url)
|
||||
{
|
||||
Q_UNUSED(worker)
|
||||
progressBar->setValue(progressBar->value() + 1);
|
||||
for (PictureLoaderRequestStatusDisplayWidget *statusDisplayWidget :
|
||||
loadLog->popup->findChildren<PictureLoaderRequestStatusDisplayWidget *>()) {
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ public:
|
|||
explicit PictureLoaderStatusBar(QWidget *parent);
|
||||
|
||||
public slots:
|
||||
void addQueuedImageLoad(const QUrl &url, PictureLoaderWorkerWork *worker);
|
||||
void addSuccessfulImageLoad(const QUrl &url, PictureLoaderWorkerWork *worker);
|
||||
void addQueuedImageLoad(const QUrl &url, const CardInfoPtr &card, const QString &setName);
|
||||
void addSuccessfulImageLoad(const QUrl &url);
|
||||
void cleanOldEntries();
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ void PictureLoaderWorker::queueRequest(const QUrl &url, PictureLoaderWorkerWork
|
|||
makeRequest(url, worker);
|
||||
} else {
|
||||
requestLoadQueue.append(qMakePair(url, worker));
|
||||
emit imageLoadQueued(url, worker);
|
||||
emit imageLoadQueued(url, worker->cardToDownload.getCard(), worker->cardToDownload.getSetName());
|
||||
processQueuedRequests();
|
||||
}
|
||||
}
|
||||
|
|
@ -82,7 +82,7 @@ QNetworkReply *PictureLoaderWorker::makeRequest(const QUrl &url, PictureLoaderWo
|
|||
// Check for cached redirects
|
||||
QUrl cachedRedirect = getCachedRedirect(url);
|
||||
if (!cachedRedirect.isEmpty()) {
|
||||
emit imageLoadSuccessful(url, worker);
|
||||
emit imageLoadSuccessful(url);
|
||||
return makeRequest(cachedRedirect, worker);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -71,8 +71,8 @@ private slots:
|
|||
signals:
|
||||
void imageLoadEnqueued(const CardInfoPtr &card);
|
||||
void imageLoaded(CardInfoPtr card, const QImage &image);
|
||||
void imageLoadQueued(const QUrl &url, PictureLoaderWorkerWork *worker);
|
||||
void imageLoadSuccessful(const QUrl &url, PictureLoaderWorkerWork *worker);
|
||||
void imageLoadQueued(const QUrl &url, const CardInfoPtr &card, const QString &setName);
|
||||
void imageLoadSuccessful(const QUrl &url);
|
||||
};
|
||||
|
||||
#endif // PICTURE_LOADER_WORKER_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue