mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 16:20:06 +00:00
Create LayerModel singleton
This commit is contained in:
parent
dd7bfc7a6f
commit
b6aef07af4
3 changed files with 26 additions and 6 deletions
|
|
@ -1117,6 +1117,24 @@ LayerInfo tag_invoke(boost::json::value_to_tag<LayerInfo>,
|
|||
boost::json::value_to<std::array<bool, 4>>(jv.at(kDisplayedName_))};
|
||||
}
|
||||
|
||||
std::shared_ptr<LayerModel> LayerModel::Instance()
|
||||
{
|
||||
static std::weak_ptr<LayerModel> layerModelReference_ {};
|
||||
static std::mutex instanceMutex_ {};
|
||||
|
||||
std::unique_lock lock(instanceMutex_);
|
||||
|
||||
std::shared_ptr<LayerModel> layerModel = layerModelReference_.lock();
|
||||
|
||||
if (layerModel == nullptr)
|
||||
{
|
||||
layerModel = std::make_shared<LayerModel>();
|
||||
layerModelReference_ = layerModel;
|
||||
}
|
||||
|
||||
return layerModel;
|
||||
}
|
||||
|
||||
} // namespace model
|
||||
} // namespace qt
|
||||
} // namespace scwx
|
||||
|
|
|
|||
|
|
@ -74,6 +74,8 @@ public:
|
|||
const QModelIndex& destinationParent,
|
||||
int destinationChild) override;
|
||||
|
||||
static std::shared_ptr<LayerModel> Instance();
|
||||
|
||||
public slots:
|
||||
void HandlePlacefileRemoved(const std::string& name);
|
||||
void HandlePlacefileRenamed(const std::string& oldName,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue