Mercurial > hg > svgui
diff layer/TextLayer.cpp @ 1471:f2525e6cbdf1 by-id
More layer updates
author | Chris Cannam |
---|---|
date | Mon, 01 Jul 2019 14:17:13 +0100 |
parents | 696e569ff21b |
children | 36ad3cdabf55 |
line wrap: on
line diff
--- a/layer/TextLayer.cpp Fri Jun 28 17:37:22 2019 +0100 +++ b/layer/TextLayer.cpp Mon Jul 01 14:17:13 2019 +0100 @@ -52,14 +52,20 @@ } void -TextLayer::setModel(ModelId model) +TextLayer::setModel(ModelId modelId) { - if (m_model == model) return; - m_model = model; + auto newModel = ModelById::getAs<TextModel>(modelId); + + if (!modelId.isNone() && !newModel) { + throw std::logic_error("Not a TextModel"); + } + + if (m_model == modelId) return; + m_model = modelId; - connectSignals(m_model); - -// SVDEBUG << "TextLayer::setModel(" << model << ")" << endl; + if (newModel) { + connectSignals(m_model); + } emit modelReplaced(); }