Skip to content

Commit

Permalink
fix deadlock dragging multiple files to timeline
Browse files Browse the repository at this point in the history
A mutex is not needed because this is UI code that must be called on
the same thread. Secondly, the LongUiTask cancel invoked itself instead
of QProgressDialog::cancel(). And third, the long task progress dialog
was always canceled by the AvFormatProducerWidget and not only when a
dialog would be displayed.
  • Loading branch information
ddennedy committed Oct 23, 2020
1 parent 6e6ce43 commit ac32155
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
6 changes: 1 addition & 5 deletions src/dialogs/longuitask.cpp
Expand Up @@ -17,7 +17,6 @@

#include "longuitask.h"
#include "mainwindow.h"
#include <QMutexLocker>

static const char* kLongUiTask = "LongUiTask";
static QMutex g_mutex;
Expand All @@ -31,13 +30,11 @@ LongUiTask::LongUiTask(QString title)
setWindowModality(Qt::ApplicationModal);
setMinimumDuration(2000);
setRange(0, 0);
QMutexLocker locker(&g_mutex);
g_instance = this;
}

LongUiTask::~LongUiTask()
{
QMutexLocker locker(&g_mutex);
g_instance = nullptr;
}

Expand All @@ -51,8 +48,7 @@ void LongUiTask::reportProgress(QString text, int value, int max)

void LongUiTask::cancel()
{
QMutexLocker locker(&g_mutex);
if (g_instance) {
g_instance->cancel();
g_instance->QProgressDialog::cancel();
}
}
6 changes: 4 additions & 2 deletions src/widgets/avformatproducerwidget.cpp
Expand Up @@ -518,9 +518,9 @@ void AvformatProducerWidget::onFrameDecoded()
ui->syncSlider->setValue(qRound(m_producer->get_double("video_delay") * 1000.0));

if (Settings.showConvertClipDialog() && !m_producer->get_int(kShotcutSkipConvertProperty)) {
LongUiTask::cancel();
m_producer->set(kShotcutSkipConvertProperty, true);
if (isVariableFrameRate) {
m_producer->set(kShotcutSkipConvertProperty, true);
LongUiTask::cancel();
MLT.pause();
LOG_INFO() << resource << "is variable frame rate";
TranscodeDialog dialog(tr("This file is variable frame rate, which is not reliable for editing. "
Expand All @@ -534,6 +534,8 @@ void AvformatProducerWidget::onFrameDecoded()
convert(dialog);
}
if (QFile::exists(resource) && !MLT.isSeekable(m_producer.data())) {
m_producer->set(kShotcutSkipConvertProperty, true);
LongUiTask::cancel();
MLT.pause();
LOG_INFO() << resource << "is not seekable";
TranscodeDialog dialog(tr("This file does not support seeking and cannot be used for editing. "
Expand Down

0 comments on commit ac32155

Please sign in to comment.