mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-06-12 05:07:46 +02:00
fix: use after free begone!
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
@ -81,10 +81,15 @@ void ShaderPackPage::downloadShaderPack()
|
||||
if (m_instance->typeName() != "Minecraft")
|
||||
return; // this is a null instance or a legacy instance
|
||||
|
||||
auto mdownload = new ResourceDownload::ShaderPackDownloadDialog(this, m_model, m_instance);
|
||||
mdownload->setAttribute(Qt::WA_DeleteOnClose);
|
||||
connect(this, &QObject::destroyed, mdownload, &QDialog::close);
|
||||
if (mdownload->exec()) {
|
||||
m_downloadDialog = new ResourceDownload::ShaderPackDownloadDialog(this, m_model, m_instance);
|
||||
m_downloadDialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||
connect(this, &QObject::destroyed, m_downloadDialog, &QDialog::close);
|
||||
connect(m_downloadDialog, &QDialog::finished, this, &ShaderPackPage::downloadDialogFinished);
|
||||
m_downloadDialog->open();
|
||||
}
|
||||
|
||||
void ShaderPackPage::downloadDialogFinished(int result) {
|
||||
if (result) {
|
||||
auto tasks = new ConcurrentTask("Download Shader Packs", APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
|
||||
connect(tasks, &Task::failed, [this, tasks](QString reason) {
|
||||
CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
|
||||
@ -102,8 +107,12 @@ void ShaderPackPage::downloadShaderPack()
|
||||
tasks->deleteLater();
|
||||
});
|
||||
|
||||
for (auto& task : mdownload->getTasks()) {
|
||||
tasks->addTask(task);
|
||||
if (m_downloadDialog) {
|
||||
for (auto& task : m_downloadDialog->getTasks()) {
|
||||
tasks->addTask(task);
|
||||
}
|
||||
} else {
|
||||
qWarning() << "ResourceDownloadDialog vanished before we could collect tasks!";
|
||||
}
|
||||
|
||||
ProgressDialog loadDialog(this);
|
||||
|
Reference in New Issue
Block a user