Fix transcoding crashes caused by old code

parent 87d9a5a2
Pipeline #3080 passed with stage
in 16 minutes and 16 seconds
...@@ -899,32 +899,6 @@ Monitor *Bin::monitor() ...@@ -899,32 +899,6 @@ Monitor *Bin::monitor()
return m_monitor; return m_monitor;
} }
const QStringList Bin::getFolderInfo(const QModelIndex &selectedIx)
{
QModelIndexList indexes;
if (selectedIx.isValid()) {
indexes << selectedIx;
} else {
indexes = m_proxyModel->selectionModel()->selectedIndexes();
}
if (indexes.isEmpty()) {
// return root folder info
QStringList folderInfo;
folderInfo << QString::number(-1);
folderInfo << QString();
return folderInfo;
}
QModelIndex ix = indexes.constFirst();
if (ix.isValid() && (m_proxyModel->selectionModel()->isSelected(ix) || selectedIx.isValid())) {
return m_itemModel->getEnclosingFolderInfo(m_proxyModel->mapToSource(ix));
}
// return root folder info
QStringList folderInfo;
folderInfo << QString::number(-1);
folderInfo << QString();
return folderInfo;
}
void Bin::slotAddClip() void Bin::slotAddClip()
{ {
// Check if we are in a folder // Check if we are in a folder
...@@ -2055,7 +2029,6 @@ void Bin::slotCreateProjectClip() ...@@ -2055,7 +2029,6 @@ void Bin::slotCreateProjectClip()
return; return;
} }
ClipType::ProducerType type = (ClipType::ProducerType)act->data().toInt(); ClipType::ProducerType type = (ClipType::ProducerType)act->data().toInt();
QStringList folderInfo = getFolderInfo();
QString parentFolder = getCurrentFolder(); QString parentFolder = getCurrentFolder();
switch (type) { switch (type) {
case ClipType::Color: case ClipType::Color:
...@@ -2231,14 +2204,18 @@ void Bin::doMoveFolder(const QString &id, const QString &newParentId) ...@@ -2231,14 +2204,18 @@ void Bin::doMoveFolder(const QString &id, const QString &newParentId)
currentItem->changeParent(newParent); currentItem->changeParent(newParent);
} }
void Bin::droppedUrls(const QList<QUrl> &urls, const QStringList &folderInfo) void Bin::droppedUrls(const QList<QUrl> &urls, const QString &folderInfo)
{ {
QModelIndex current; QModelIndex current;
if (folderInfo.isEmpty()) { if (folderInfo.isEmpty()) {
current = m_proxyModel->mapToSource(m_proxyModel->selectionModel()->currentIndex()); current = m_proxyModel->mapToSource(m_proxyModel->selectionModel()->currentIndex());
} else { } else {
// get index for folder // get index for folder
current = getIndexForId(folderInfo.constFirst(), true); std::shared_ptr<ProjectFolder> folder = m_itemModel->getFolderByBinId(folderInfo);
if (!folder) {
folder = m_itemModel->getRootFolder();
}
current = m_itemModel->getIndexFromItem(folder);
} }
slotItemDropped(urls, current); slotItemDropped(urls, current);
} }
......
...@@ -258,8 +258,6 @@ public: ...@@ -258,8 +258,6 @@ public:
void rebuildProxies(); void rebuildProxies();
/** @brief Return a list of all clips hashes used in this project */ /** @brief Return a list of all clips hashes used in this project */
QStringList getProxyHashList(); QStringList getProxyHashList();
/** @brief Get info (id, name) of a folder (or the currently selected one) */
const QStringList getFolderInfo(const QModelIndex &selectedIx = QModelIndex());
/** @brief Get binId of the current selected folder */ /** @brief Get binId of the current selected folder */
QString getCurrentFolder(); QString getCurrentFolder();
/** @brief Save a clip zone as MLT playlist */ /** @brief Save a clip zone as MLT playlist */
...@@ -356,7 +354,7 @@ public slots: ...@@ -356,7 +354,7 @@ public slots:
/** @brief Select a clip in the Bin from its id. */ /** @brief Select a clip in the Bin from its id. */
void selectClipById(const QString &id, int frame = -1, const QPoint &zone = QPoint()); void selectClipById(const QString &id, int frame = -1, const QPoint &zone = QPoint());
void slotAddClipToProject(const QUrl &url); void slotAddClipToProject(const QUrl &url);
void droppedUrls(const QList<QUrl> &urls, const QStringList &folderInfo = QStringList()); void droppedUrls(const QList<QUrl> &urls, const QString &folderInfo = QString());
/** @brief Returns the effectstack of a given clip. */ /** @brief Returns the effectstack of a given clip. */
std::shared_ptr<EffectStackModel> getClipEffectStack(int itemId); std::shared_ptr<EffectStackModel> getClipEffectStack(int itemId);
/** @brief Returns the duration of a given clip. */ /** @brief Returns the duration of a given clip. */
......
...@@ -2543,7 +2543,7 @@ void MainWindow::slotEditItemDuration() ...@@ -2543,7 +2543,7 @@ void MainWindow::slotEditItemDuration()
*/ */
} }
void MainWindow::slotAddProjectClip(const QUrl &url, const QStringList &folderInfo) void MainWindow::slotAddProjectClip(const QUrl &url, const QString &folderInfo)
{ {
pCore->bin()->droppedUrls(QList<QUrl>() << url, folderInfo); pCore->bin()->droppedUrls(QList<QUrl>() << url, folderInfo);
} }
...@@ -3180,8 +3180,7 @@ void MainWindow::slotTranscode(const QStringList &urls) ...@@ -3180,8 +3180,7 @@ void MainWindow::slotTranscode(const QStringList &urls)
Q_ASSERT(!urls.isEmpty()); Q_ASSERT(!urls.isEmpty());
QString params; QString params;
QString desc; QString desc;
qCDebug(KDENLIVE_LOG) << "// TRANSODING FOLDER: " << pCore->bin()->getFolderInfo(); ClipTranscode *d = new ClipTranscode(urls, params, QStringList(), desc, pCore->bin()->getCurrentFolder());
ClipTranscode *d = new ClipTranscode(urls, params, QStringList(), desc, pCore->bin()->getFolderInfo());
connect(d, &ClipTranscode::addClip, this, &MainWindow::slotAddProjectClip); connect(d, &ClipTranscode::addClip, this, &MainWindow::slotAddProjectClip);
d->show(); d->show();
} }
......
...@@ -346,7 +346,7 @@ private slots: ...@@ -346,7 +346,7 @@ private slots:
void slotSelectAddTimelineTransition(); void slotSelectAddTimelineTransition();
void slotAddEffect(QAction *result); void slotAddEffect(QAction *result);
void slotAddTransition(QAction *result); void slotAddTransition(QAction *result);
void slotAddProjectClip(const QUrl &url, const QStringList &folderInfo); void slotAddProjectClip(const QUrl &url, const QString &folderInfo);
void slotAddProjectClipList(const QList<QUrl> &urls); void slotAddProjectClipList(const QList<QUrl> &urls);
void slotChangeTool(QAction *action); void slotChangeTool(QAction *action);
void slotChangeEdit(QAction *action); void slotChangeEdit(QAction *action);
......
...@@ -1076,7 +1076,7 @@ void Monitor::slotExtractCurrentFrame(QString frameName, bool addToProject) ...@@ -1076,7 +1076,7 @@ void Monitor::slotExtractCurrentFrame(QString frameName, bool addToProject)
KRecentDirs::add(QStringLiteral(":KdenliveFramesFolder"), QUrl::fromLocalFile(selectedFile).adjusted(QUrl::RemoveFilename).toLocalFile()); KRecentDirs::add(QStringLiteral(":KdenliveFramesFolder"), QUrl::fromLocalFile(selectedFile).adjusted(QUrl::RemoveFilename).toLocalFile());
if (addToProject) { if (addToProject) {
QStringList folderInfo = pCore->bin()->getFolderInfo(); QString folderInfo = pCore->bin()->getCurrentFolder();
pCore->bin()->droppedUrls(QList<QUrl>() << QUrl::fromLocalFile(selectedFile), folderInfo); pCore->bin()->droppedUrls(QList<QUrl>() << QUrl::fromLocalFile(selectedFile), folderInfo);
} }
} }
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include <KMessageBox> #include <KMessageBox>
#include <klocalizedstring.h> #include <klocalizedstring.h>
ClipTranscode::ClipTranscode(QStringList urls, const QString &params, QStringList postParams, const QString &description, QStringList folderInfo, ClipTranscode::ClipTranscode(QStringList urls, const QString &params, QStringList postParams, const QString &description, QString folderInfo,
bool automaticMode, QWidget *parent) bool automaticMode, QWidget *parent)
: QDialog(parent) : QDialog(parent)
, m_urls(std::move(urls)) , m_urls(std::move(urls))
......
...@@ -32,7 +32,7 @@ class ClipTranscode : public QDialog, public Ui::ClipTranscode_UI ...@@ -32,7 +32,7 @@ class ClipTranscode : public QDialog, public Ui::ClipTranscode_UI
Q_OBJECT Q_OBJECT
public: public:
ClipTranscode(QStringList urls, const QString &params, QStringList postParams, const QString &description, QStringList folderInfo = QStringList(), ClipTranscode(QStringList urls, const QString &params, QStringList postParams, const QString &description, QString folderInfo = QString(),
bool automaticMode = false, QWidget *parent = nullptr); bool automaticMode = false, QWidget *parent = nullptr);
~ClipTranscode() override; ~ClipTranscode() override;
...@@ -47,7 +47,7 @@ private slots: ...@@ -47,7 +47,7 @@ private slots:
private: private:
QProcess m_transcodeProcess; QProcess m_transcodeProcess;
QStringList m_urls; QStringList m_urls;
QStringList m_folderInfo; QString m_folderInfo;
int m_duration; int m_duration;
bool m_automaticMode; bool m_automaticMode;
/** @brief The path for destination transcoded file. */ /** @brief The path for destination transcoded file. */
...@@ -56,7 +56,7 @@ private: ...@@ -56,7 +56,7 @@ private:
KMessageWidget *m_infoMessage; KMessageWidget *m_infoMessage;
signals: signals:
void addClip(const QUrl &url, const QStringList &folderInfo = QStringList()); void addClip(const QUrl &url, const QString &folderInfo = QString());
void transcodedClip(const QUrl &source, const QUrl &result); void transcodedClip(const QUrl &source, const QUrl &result);
}; };
......
...@@ -498,7 +498,7 @@ void ResourceWidget::slotGotFile(KJob *job) ...@@ -498,7 +498,7 @@ void ResourceWidget::slotGotFile(KJob *job)
const QUrl filePath = copyJob->destUrl(); const QUrl filePath = copyJob->destUrl();
KMessageBox::information(this, i18n("Resource saved to %1", filePath.toLocalFile()), i18n("Data Imported")); KMessageBox::information(this, i18n("Resource saved to %1", filePath.toLocalFile()), i18n("Data Imported"));
emit addClip(filePath, QStringList()); emit addClip(filePath, QString());
} }
/** /**
...@@ -835,7 +835,7 @@ void ResourceWidget::DownloadRequestFinished(QNetworkReply *reply) ...@@ -835,7 +835,7 @@ void ResourceWidget::DownloadRequestFinished(QNetworkReply *reply)
file.close(); file.close();
KMessageBox::information(this, i18n("Resource saved to %1", m_saveLocation), i18n("Data Imported")); KMessageBox::information(this, i18n("Resource saved to %1", m_saveLocation), i18n("Data Imported"));
emit addClip(QUrl(m_saveLocation), QStringList()); // MainWindow::slotDownloadResources() links this signal to MainWindow::slotAddProjectClip emit addClip(QUrl(m_saveLocation), QString()); // MainWindow::slotDownloadResources() links this signal to MainWindow::slotAddProjectClip
m_desc.append(QStringLiteral("<br>") + i18n("Saved file to") + QStringLiteral("<br>")); m_desc.append(QStringLiteral("<br>") + i18n("Saved file to") + QStringLiteral("<br>"));
m_desc.append(m_saveLocation); m_desc.append(m_saveLocation);
......
...@@ -110,7 +110,7 @@ private: ...@@ -110,7 +110,7 @@ private:
void DoFileDownload(const QUrl &srcUrl, const QUrl &saveUrl); void DoFileDownload(const QUrl &srcUrl, const QUrl &saveUrl);
signals: signals:
void addClip(const QUrl &, const QStringList &); void addClip(const QUrl &, const QString &);
}; };
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment