aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Baptiste Mardelle <[email protected]>2015-05-11 22:05:33 +0200
committerJean-Baptiste Mardelle <[email protected]>2015-05-11 22:05:33 +0200
commita09fe55258be04f77a9886e580533d2009d07943 (patch)
tree700e91b4ea629c870cfd8bbeba07277d14ef152e
parent0b35f140a5a53eb48172a623eb888ca511f89ddf (diff)
Fix various crashes when switching monitor qml
-rw-r--r--src/monitor/glwidget.cpp19
-rw-r--r--src/monitor/monitor.cpp21
2 files changed, 30 insertions, 10 deletions
diff --git a/src/monitor/glwidget.cpp b/src/monitor/glwidget.cpp
index 3002a22..cab2288 100644
--- a/src/monitor/glwidget.cpp
+++ b/src/monitor/glwidget.cpp
@@ -160,6 +160,7 @@ void GLWidget::initializeGL()
void GLWidget::effectRectChanged()
{
+ if (!rootObject()) return;
const QRect rect = rootObject()->property("framesize").toRect();
emit effectChanged(rect);
}
@@ -198,8 +199,10 @@ void GLWidget::resizeGL(int width, int height)
m_rect.setRect(x, y, w, h);
double scale = (double) m_rect.width() / m_consumer->profile()->width() * m_zoom;
QPoint center = m_rect.center();
- rootObject()->setProperty("center", center);
- rootObject()->setProperty("scale", scale);
+ if (rootObject()) {
+ rootObject()->setProperty("center", center);
+ rootObject()->setProperty("scale", scale);
+ }
emit rectChanged();
}
@@ -418,7 +421,7 @@ void GLWidget::wheelEvent(QWheelEvent * event)
void GLWidget::mousePressEvent(QMouseEvent* event)
{
QQuickView::mousePressEvent(event);
- if (rootObject()->objectName() != "root") {
+ if (!rootObject() || rootObject()->objectName() != "root") {
event->ignore();
return;
}
@@ -435,7 +438,7 @@ void GLWidget::mousePressEvent(QMouseEvent* event)
void GLWidget::mouseMoveEvent(QMouseEvent* event)
{
QQuickView::mouseMoveEvent(event);
- if (rootObject()->objectName() != "root") {
+ if (!rootObject() || rootObject()->objectName() != "root") {
event->ignore();
return;
}
@@ -779,6 +782,7 @@ int GLWidget::reconfigure(bool isMulti)
void GLWidget::slotShowEffectScene()
{
QObject *item = rootObject();
+ if (!item) return;
QObject::connect(item, SIGNAL(effectChanged()), this, SLOT(effectRectChanged()), Qt::UniqueConnection);
item->setProperty("profile", QPoint(m_consumer->profile()->width(), m_consumer->profile()->height()));
item->setProperty("framesize", QRect(0, 0, m_consumer->profile()->width(), m_consumer->profile()->height()));
@@ -789,6 +793,7 @@ void GLWidget::slotShowEffectScene()
void GLWidget::slotShowRootScene()
{
QObject *item = rootObject();
+ if (!item) return;
item->setProperty("scale", (double) m_rect.width() / m_consumer->profile()->width() * m_zoom);
item->setProperty("center", m_rect.center());
}
@@ -814,8 +819,10 @@ void GLWidget::setZoom(float zoom)
double zoomRatio = zoom / m_zoom;
m_zoom = zoom;
emit zoomChanged();
- double scale = rootObject()->property("scale").toDouble() * zoomRatio;
- rootObject()->setProperty("scale", scale);
+ if (rootObject()) {
+ double scale = rootObject()->property("scale").toDouble() * zoomRatio;
+ rootObject()->setProperty("scale", scale);
+ }
update();
}
diff --git a/src/monitor/monitor.cpp b/src/monitor/monitor.cpp
index 990b061..0375b6f 100644
--- a/src/monitor/monitor.cpp
+++ b/src/monitor/monitor.cpp
@@ -994,8 +994,11 @@ void Monitor::updateClipProducer(Mlt::Producer *prod)
void Monitor::openClip(ClipController *controller)
{
if (render == NULL) return;
+ bool sameClip = controller == m_controller && controller != NULL;
m_controller = controller;
- if (m_rootItem && m_rootItem->objectName() != "root") loadMasterQml();
+ if (m_rootItem && m_rootItem->objectName() != "root" && !sameClip) {
+ loadMasterQml();
+ }
if (controller) {
updateMarkers();
render->setProducer(m_controller->masterProducer(), -1, isActive());
@@ -1216,7 +1219,7 @@ void Monitor::slotSetSelectedClip(Transition* item)
void Monitor::slotEnableEffectScene(bool enable)
{
KdenliveSettings::setShowOnMonitorScene(enable);
- bool isDisplayed = m_rootItem && m_rootItem->objectName() == "rooteffectscene";
+ bool isDisplayed = enable && m_rootItem && m_rootItem->objectName() == "rooteffectscene";
if (enable == isDisplayed) return;
slotShowEffectScene(enable);
}
@@ -1229,7 +1232,9 @@ void Monitor::slotShowEffectScene(bool show, bool manuallyTriggered)
QObject::connect(m_rootItem, SIGNAL(addKeyframe()), this, SIGNAL(addKeyframe()), Qt::UniqueConnection);
m_glMonitor->slotShowEffectScene();
}
- else loadMasterQml();
+ else if (m_rootItem && m_rootItem->objectName() == "rooteffectscene") {
+ loadMasterQml();
+ }
}
void Monitor::setUpEffectGeometry(QRect r, QVariantList list)
@@ -1388,10 +1393,18 @@ void Monitor::slotSwitchCompare(bool enable)
void Monitor::loadMasterQml()
{
- if (m_rootItem->objectName() == "root") {
+ if ((m_rootItem && m_rootItem->objectName() == "root")) {
// Root scene is already active
return;
}
+ if (!KdenliveSettings::displayMonitorInfo()) {
+ // We don't want info overlay
+ if (m_rootItem) {
+ m_glMonitor->setSource(QUrl());
+ m_rootItem = NULL;
+ }
+ return;
+ }
m_glMonitor->setSource(QUrl::fromLocalFile(QStandardPaths::locate(QStandardPaths::DataLocation, QStringLiteral("kdenlivemonitor.qml"))));
m_glMonitor->slotShowRootScene();
m_rootItem = m_glMonitor->rootObject();