Mercurial > hg > svgui
comparison layer/LayerFactory.h @ 1484:b43ff1abdc02 by-id
Fix inability to set layer's model to None
author | Chris Cannam |
---|---|
date | Wed, 17 Jul 2019 11:20:08 +0100 |
parents | f2525e6cbdf1 |
children | 0fa155b84bac |
comparison
equal
deleted
inserted
replaced
1483:3943d0720167 | 1484:b43ff1abdc02 |
---|---|
102 protected: | 102 protected: |
103 template <typename LayerClass, typename ModelClass> | 103 template <typename LayerClass, typename ModelClass> |
104 bool trySetModel(Layer *layerBase, ModelId modelId) { | 104 bool trySetModel(Layer *layerBase, ModelId modelId) { |
105 LayerClass *layer = dynamic_cast<LayerClass *>(layerBase); | 105 LayerClass *layer = dynamic_cast<LayerClass *>(layerBase); |
106 if (!layer) return false; | 106 if (!layer) return false; |
107 auto model = ModelById::getAs<ModelClass>(modelId); | 107 if (!modelId.isNone()) { |
108 if (!model) return false; | 108 auto model = ModelById::getAs<ModelClass>(modelId); |
109 if (!model) return false; | |
110 } | |
109 layer->setModel(modelId); | 111 layer->setModel(modelId); |
110 return true; | 112 return true; |
111 } | 113 } |
112 | 114 |
113 static LayerFactory *m_instance; | 115 static LayerFactory *m_instance; |