Mercurial > hg > svgui
diff layer/ImageLayer.cpp @ 1471:f2525e6cbdf1 by-id
More layer updates
author | Chris Cannam |
---|---|
date | Mon, 01 Jul 2019 14:17:13 +0100 |
parents | 696e569ff21b |
children | e540aa5d89cd |
line wrap: on
line diff
--- a/layer/ImageLayer.cpp Fri Jun 28 17:37:22 2019 +0100 +++ b/layer/ImageLayer.cpp Mon Jul 01 14:17:13 2019 +0100 @@ -67,14 +67,18 @@ void ImageLayer::setModel(ModelId modelId) { + auto newModel = ModelById::getAs<ImageModel>(modelId); + + if (!modelId.isNone() && !newModel) { + throw std::logic_error("Not an ImageModel"); + } + if (m_model == modelId) return; - - auto model = ModelById::getAs<ImageModel>(modelId); - if (!model) throw std::logic_error("Not an ImageModel"); - m_model = modelId; - connectSignals(m_model); + if (newModel) { + connectSignals(m_model); + } emit modelReplaced(); } @@ -355,6 +359,11 @@ likelyWidth = availableWidth; } + // Qt 5.13 deprecates QFontMetrics::width(), but its suggested + // replacement (horizontalAdvance) was only added in Qt 5.11 + // which is too new for us +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + int singleWidth = paint.fontMetrics().width(label); if (singleWidth < availableWidth && singleWidth < likelyWidth * 2) { likelyWidth = singleWidth + 4;