Merge branch 'develop' of https://github.com/KingDuckZ/nana into KingDuckZ-develop

This commit is contained in:
Jinhao 2020-04-15 23:38:38 +08:00
commit 4c98a8d1bc
2 changed files with 14 additions and 21 deletions

View File

@ -73,7 +73,7 @@ namespace nana
void fps(std::size_t n);
std::size_t fps() const;
private:
impl * impl_;
std::unique_ptr<impl> impl_;
};
} //end namespace nana
#include <nana/pop_ignore_diagnostic>

View File

@ -302,7 +302,7 @@ namespace nana
};//end struct frameset::impl
//public:
frameset::frameset()
: impl_(new impl)
: impl_(std::make_unique<impl>())
{}
void frameset::push_back(paint::image img)
@ -449,12 +449,12 @@ namespace nana
}
}
auto thr = new thread_variable;
auto thr = std::make_unique<thread_variable>();
thr->animations.push_back(p);
thr->performance_parameter = 0.0;
thr->fps = p->fps;
thr->interval = 1000.0 / double(p->fps);
thr->thread = std::make_shared<std::thread>([thr]()
thr->thread = std::make_shared<std::thread>([thr=thr.get()]()
{
nana::system::timepiece tmpiece;
while (true)
@ -500,8 +500,8 @@ namespace nana
}
});
threads_.push_back(thr);
p->thr_variable = thr;
threads_.push_back(thr.release());
p->thr_variable = threads_.back();
}
void animation::performance_manager::set_fps(impl* p, std::size_t new_fps)
@ -562,30 +562,23 @@ namespace nana
//end class animation::performance_manager
animation::animation(std::size_t fps)
: impl_(new impl(fps))
: impl_(std::make_unique<impl>(fps))
{
}
animation::~animation()
{
delete impl_;
}
animation::~animation() = default;
animation::animation(animation&& rhs)
: impl_(rhs.impl_)
: impl_(std::move(rhs.impl_))
{
rhs.impl_ = new impl(23);
rhs.impl_ = std::make_unique<impl>(23);
}
animation& animation::operator=(animation&& rhs)
{
if (this != &rhs)
{
auto imp = new impl{ 23 };
delete impl_;
impl_ = rhs.impl_;
rhs.impl_ = imp;
std::swap(rhs.impl_, this->impl_);
}
return *this;
}
@ -667,7 +660,7 @@ namespace nana
if (n == impl_->fps)
return;
impl::perf_manager->set_fps(impl_, n);
impl::perf_manager->set_fps(impl_.get(), n);
}
std::size_t animation::fps() const