Fix drop from clip monitor when no zone selected

Fix crash on subclip drop
parent 064bcf58
......@@ -174,9 +174,9 @@ bool ProjectItemModel::dropMimeData(const QMimeData *data, Qt::DropAction action
if (data->hasFormat(QStringLiteral("kdenlive/producerslist"))) {
// Dropping an Bin item
const QStringList ids = QString(data->data(QStringLiteral("kdenlive/producerslist"))).split(QLatin1Char(';'));
if (ids.constFirst().contains(QLatin1Char('#'))) {
if (ids.constFirst().contains(QLatin1Char('/'))) {
// subclip zone
QStringList clipData = ids.constFirst().split(QLatin1Char('#'));
QStringList clipData = ids.constFirst().split(QLatin1Char('/'));
if (clipData.length() >= 3) {
QString id;
return requestAddBinSubClip(id, clipData.at(1).toInt(), clipData.at(2).toInt(), clipData.at(0));
......@@ -275,7 +275,7 @@ QMimeData *ProjectItemModel::mimeData(const QModelIndexList &indices) const
duration += (std::static_pointer_cast<ProjectClip>(item))->frameDuration();
} else if (type == AbstractProjectItem::SubClipItem) {
QPoint p = item->zone();
list << item->clipId() + QLatin1Char('/') + QString::number(p.x()) + QLatin1Char('/') + QString::number(p.y());
list << std::static_pointer_cast<ProjectSubClip>(item)->getMasterClip()->clipId() + QLatin1Char('/') + QString::number(p.x()) + QLatin1Char('/') + QString::number(p.y());
} else if (type == AbstractProjectItem::FolderItem) {
list << "#" + item->clipId();
}
......
......@@ -817,13 +817,17 @@ void Monitor::slotStartDrag()
auto *drag = new QDrag(this);
auto *mimeData = new QMimeData;
QStringList list;
list.append(m_controller->AbstractProjectItem::clipId());
QPoint p = m_glMonitor->getControllerProxy()->zone();
list.append(QString::number(p.x()));
list.append(QString::number(p.y()));
QByteArray prodData;
prodData.append(list.join(QLatin1Char('#')).toUtf8());
QPoint p = m_glMonitor->getControllerProxy()->zone();
if (p.x() == -1 || p.y() == -1) {
prodData = m_controller->AbstractProjectItem::clipId().toUtf8();
} else {
QStringList list;
list.append(m_controller->AbstractProjectItem::clipId());
list.append(QString::number(p.x()));
list.append(QString::number(p.y()));
prodData.append(list.join(QLatin1Char('/')).toUtf8());
}
mimeData->setData(QStringLiteral("kdenlive/producerslist"), prodData);
drag->setMimeData(mimeData);
/*QPixmap pix = m_currentClip->thumbnail();
......
......@@ -572,8 +572,8 @@ bool TimelineModel::requestClipCreation(const QString &binClipId, int &id, Playl
id = clipId;
Fun local_undo = deregisterClip_lambda(clipId);
QString bid = binClipId;
if (binClipId.contains(QLatin1Char('#'))) {
bid = binClipId.section(QLatin1Char('#'), 0, 0);
if (binClipId.contains(QLatin1Char('/'))) {
bid = binClipId.section(QLatin1Char('/'), 0, 0);
}
ClipModel::construct(shared_from_this(), bid, clipId, state);
auto clip = m_allClips[clipId];
......@@ -585,9 +585,9 @@ bool TimelineModel::requestClipCreation(const QString &binClipId, int &id, Playl
return true;
};
if (binClipId.contains(QLatin1Char('#'))) {
int in = binClipId.section(QLatin1Char('#'), 1, 1).toInt();
int out = binClipId.section(QLatin1Char('#'), 2, 2).toInt();
if (binClipId.contains(QLatin1Char('/'))) {
int in = binClipId.section(QLatin1Char('/'), 1, 1).toInt();
int out = binClipId.section(QLatin1Char('/'), 2, 2).toInt();
int initLength = m_allClips[clipId]->getPlaytime();
bool res = requestItemResize(clipId, initLength - in, false, true, local_undo, local_redo);
res = res && requestItemResize(clipId, out - in + 1, true, true, local_undo, local_redo);
......@@ -608,7 +608,7 @@ bool TimelineModel::requestClipInsertion(const QString &binClipId, int trackId,
bool res = false;
ClipType type = ClipType::Unknown;
if (KdenliveSettings::splitaudio()) {
std::shared_ptr<ProjectClip> master = pCore->projectItemModel()->getClipByBinID(binClipId.section(QLatin1Char('#'), 0, 0));
std::shared_ptr<ProjectClip> master = pCore->projectItemModel()->getClipByBinID(binClipId.section(QLatin1Char('/'), 0, 0));
type = master->clipType();
}
if (type == ClipType::AV) {
......
......@@ -225,6 +225,7 @@ Rectangle {
timeline.activeTrack = tracksRepeater.itemAt(track).trackId
//drag.acceptProposedAction()
clipBeingDroppedData = drag.getDataAsString('kdenlive/producerslist')
console.log('dropped data: ', clipBeingDroppedData)
clipBeingDroppedId = timeline.insertClip(timeline.activeTrack, frame, clipBeingDroppedData, false, true)
continuousScrolling(drag.x + scrollView.flickableItem.contentX)
} else {
......
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