From c8b57dbd0bc792d0ce326db0ad7e2be9e014c13a Mon Sep 17 00:00:00 2001 From: Craig Watson Date: Tue, 1 Mar 2016 15:24:53 +0100 Subject: [PATCH] Moved mediaItem Delegate initialization to the mediaItem subclasses That function requires access to variables that are initialized in videoItem and audioItem constructors, so it can sometimes fail when called from the superclass's constructor. It might be an idea to avoid those calls altogether though --- src/domain/UBGraphicsMediaItem.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/domain/UBGraphicsMediaItem.cpp b/src/domain/UBGraphicsMediaItem.cpp index daa5e84d..34c24ba4 100644 --- a/src/domain/UBGraphicsMediaItem.cpp +++ b/src/domain/UBGraphicsMediaItem.cpp @@ -74,7 +74,6 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte mMediaObject->setMedia(pMediaFileUrl); setDelegate(new UBGraphicsMediaItemDelegate(this)); - Delegate()->createControls(); setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::ObjectItem)); setFlag(ItemIsMovable, true); @@ -105,19 +104,24 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte UBGraphicsAudioItem::UBGraphicsAudioItem(const QUrl &pMediaFileUrl, QGraphicsItem *parent) :UBGraphicsMediaItem(pMediaFileUrl, parent) { + haveLinkedImage = false; + this->setSize(320, 26); this->setMinimumSize(QSize(150, 26)); + Delegate()->createControls(); Delegate()->frame()->setOperationMode(UBGraphicsDelegateFrame::ResizingHorizontally); mMediaObject->setNotifyInterval(1000); - haveLinkedImage = false; } UBGraphicsVideoItem::UBGraphicsVideoItem(const QUrl &pMediaFileUrl, QGraphicsItem *parent) :UBGraphicsMediaItem(pMediaFileUrl, parent) { + haveLinkedImage = true; + Delegate()->createControls(); + mVideoItem = new QGraphicsVideoItem(this); mVideoItem->setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object); @@ -132,7 +136,6 @@ UBGraphicsVideoItem::UBGraphicsVideoItem(const QUrl &pMediaFileUrl, QGraphicsIte connect(mVideoItem, SIGNAL(nativeSizeChanged(QSizeF)), this, SLOT(videoSizeChanged(QSizeF))); - haveLinkedImage = true; setAcceptHoverEvents(true);