Commit b5acd127 authored by Locatelli's avatar Locatelli
Browse files

Improve memory leaks

parent ee972f8d
- recompute projections x and y min max values when zooming * move icons to a system directory and not in the project
- move icons to a system directory and not in the project
- status bar with mouse coordinates using qt event and not matplotib one * See possible using of CUDA acceleration
- nomad server restart ploty2 at during its starting
- nomad gui closing shall closed plot windows * Multiclient options
- nomad gui starting shall restart previous display plot windows - no offscreen log, webspy plots
- recover size and position of plots and also states for grid, log , aspect ratio .... - offscreen plots for spy and multiplot will be regenerated or taken form the nomad server computer
- Do offscreen for web plots and multiwindow plot
- bring plot to front wait it was already open * ROI
- send offscreen log image to log system
\ No newline at end of file * Cut windows
* Bugs:
- Plot1D crash after several time using it, see core file, pb QT event
- Problem to pass from empty data to others
- Problem close a plot take a time in cameo, so if restarting a new before finishing previous does not worked
...@@ -46,7 +46,7 @@ namespace bp = boost::python; ...@@ -46,7 +46,7 @@ namespace bp = boost::python;
//void figure() { //void figure() {
// cout << "figure lock: " << endl; // cout << "figure lock: " << endl;
// view::mpl::MplLock lock(__PRETTY_FUNCTION__); // view::mpl::MplLock lock;
// cout << "figure lock past" << endl; // cout << "figure lock past" << endl;
// bp::object fig = pyPlot.attr("figure")(); // bp::object fig = pyPlot.attr("figure")();
// cout << "figure : " << fig.is_none() << endl; // cout << "figure : " << fig.is_none() << endl;
...@@ -56,32 +56,6 @@ namespace bp = boost::python; ...@@ -56,32 +56,6 @@ namespace bp = boost::python;
// //
// //
class SavePlot;
unordered_map<string, pair<thread*, SavePlot *>> tm_;
static std::mutex m_Mutex;
bool intm(const string& id) {
unordered_map<string, pair<thread*, SavePlot *>>::iterator it = tm_.find(id);
return (it != tm_.end());
}
void addtm(const string& id, thread* td, SavePlot* sp) {
std::lock_guard<std::mutex> lock(m_Mutex);
tm_[id] = make_pair(td, sp);
cout << "add id " << id << " " << tm_.size() << endl;
}
void deltm(const string& id) {
std::lock_guard<std::mutex> lock(m_Mutex);
unordered_map<string, pair<thread*, SavePlot *>>::iterator it = tm_.find(id);
if (it != tm_.end()) {
delete it->second.first;
delete it->second.second;
tm_.erase(id);
cout << "del id " << id << " " << tm_.size() << endl;
}
}
/*! /*!
* \brief Save plot object for multithread offscreen plot * \brief Save plot object for multithread offscreen plot
...@@ -97,7 +71,7 @@ public: ...@@ -97,7 +71,7 @@ public:
* \param[in] path the path directory of the pb file * \param[in] path the path directory of the pb file
*/ */
SavePlot(view::mpl::Mpl* mpl, const std::string& pbfilename, const std::string& path); SavePlot(view::mpl::Mpl* mpl, const std::string& pbfilename, const std::string& path);
SavePlot();
/*! /*!
* \brief do save action * \brief do save action
*/ */
...@@ -110,6 +84,42 @@ private: ...@@ -110,6 +84,42 @@ private:
std::string m_Path; //! The path directory of the pb file std::string m_Path; //! The path directory of the pb file
}; };
unordered_map<string, thread> tm_;
unordered_map<string, SavePlot> spm_;
static std::mutex m_Mutex;
bool intm(const string& id) {
unordered_map<string, thread>::iterator it = tm_.find(id);
return (it != tm_.end());
}
void addtm(view::mpl::Mpl* mpl, const string& id, const string& path) {
std::lock_guard<std::mutex> lock(m_Mutex);
if (!intm(id)) {
SavePlot sp1(mpl, id, path);
thread t1(bind(&SavePlot::run, sp1));
t1.detach();
tm_[id] = std::move(t1);
spm_[id] = std::move(sp1);
cout << "add id " << id << " " << tm_.size() << endl;
}
}
void deltm(const string& id) {
string lid = std::move(id);
std::lock_guard<std::mutex> lock(m_Mutex);
unordered_map<string, thread>::iterator it = tm_.find(lid);
if (it != tm_.end()) {
it->second.std::thread::~thread();
tm_.erase(lid);
cout << "del id " << lid << " " << tm_.size() << endl;
}
unordered_map<string, SavePlot>::iterator it2 = spm_.find(lid);
if (it2 != spm_.end()) {
spm_.erase(lid);
cout << "del id " << lid << " " << spm_.size() << endl;
}
}
/* /*
* savePlot * savePlot
...@@ -119,6 +129,12 @@ SavePlot::SavePlot(view::mpl::Mpl* mpl, const std::string& pbfilename, const std ...@@ -119,6 +129,12 @@ SavePlot::SavePlot(view::mpl::Mpl* mpl, const std::string& pbfilename, const std
m_Pbfilename = pbfilename; m_Pbfilename = pbfilename;
m_Path = path; m_Path = path;
} }
/*
* savePlot
*/
SavePlot::SavePlot() {
m_Mpl = nullptr;
}
/* /*
* savePlot * savePlot
...@@ -224,55 +240,19 @@ void test(view::mpl::Mpl* mpl) { ...@@ -224,55 +240,19 @@ void test(view::mpl::Mpl* mpl) {
uint32 i = 0; uint32 i = 0;
while (true) { while (true) {
if (!intm("plot#detector_plot_data0#Detector.png")) { addtm(mpl, "plot#detector_plot_data0#Detector.png", "/users/locatelli/offscreenImages/web/pb");
SavePlot* sp1 = new SavePlot(mpl, "plot#detector_plot_data0#Detector.png", "/users/locatelli/offscreenImages/web/pb"); addtm(mpl, "ScanSpy#scanSpyPlot0.png", "/users/locatelli/offscreenImages/web/pb");
thread* t1 = new thread(bind(&SavePlot::run, sp1)); addtm(mpl, "plot#detector_plot_data.0.0#0.png", "/users/locatelli/offscreenImages/multiplot/pb");
t1->detach(); addtm(mpl, "plot#detector_plot_data.0.0#1.png", "/users/locatelli/offscreenImages/multiplot/pb");
addtm("plot#detector_plot_data0#Detector.png", t1, sp1); addtm(mpl, "plot#detector_plot_data.0.0#2.png", "/users/locatelli/offscreenImages/multiplot/pb");
} addtm(mpl, "plot#detector_plot_data.0.0#3.png", "/users/locatelli/offscreenImages/multiplot/pb");
if (!intm("ScanSpy#scanSpyPlot0.png")) { addtm(mpl, "plot#detector_plot_data.0.0#4.png", "/users/locatelli/offscreenImages/multiplot/pb");
SavePlot* sp2 = new SavePlot(mpl, "ScanSpy#scanSpyPlot0.png", "/users/locatelli/offscreenImages/web/pb"); addtm(mpl, "plot#detector_plot_data.0.0#5.png", "/users/locatelli/offscreenImages/multiplot/pb");
thread* t2 = new thread(bind(&SavePlot::run, sp2)); addtm(mpl, "plot#detector_plot_data.0.0#6.png", "/users/locatelli/offscreenImages/multiplot/pb");
t2->detach(); addtm(mpl, "plot#detector_plot_data.0.0#7.png", "/users/locatelli/offscreenImages/multiplot/pb");
addtm("ScanSpy#scanSpyPlot0.png", t2, sp2); addtm(mpl, "plot#detector_plot_data.0.0#8.png", "/users/locatelli/offscreenImages/multiplot/pb");
} addtm(mpl, "plot#detector_plot_data.0.0#9.png", "/users/locatelli/offscreenImages/multiplot/pb");
// tm_["plot#detector_plot_data0#Detector.png"] = std::move(t1); //break;
// SavePlot* sp3 = new SavePlot(mpl, "plot#detector_plot_data.0.0#0.png", "/users/locatelli/offscreenImages/multiplot/pb");
// thread t3(bind(&SavePlot::run, sp3));
// t3.detach();
// tm_["plot#detector_plot_data0#Detector.png"] = std::move(t1);
// SavePlot* sp4 = new SavePlot(mpl, "plot#detector_plot_data.0.0#1.png", "/users/locatelli/offscreenImages/multiplot/pb");
// thread t4(bind(&SavePlot::run, sp4));
// t4.detach();
// tm_["plot#detector_plot_data0#Detector.png"] = std::move(t1);
// SavePlot* sp5 = new SavePlot(mpl, "plot#detector_plot_data.0.0#2.png", "/users/locatelli/offscreenImages/multiplot/pb");
// thread t5(bind(&SavePlot::run, sp5));
// t5.detach();
// tm_["plot#detector_plot_data0#Detector.png"] = std::move(t1);
// SavePlot* sp6 = new SavePlot(mpl, "plot#detector_plot_data.0.0#3.png", "/users/locatelli/offscreenImages/multiplot/pb");
// thread t6(bind(&SavePlot::run, sp6));
// t6.detach();
// tm_["plot#detector_plot_data0#Detector.png"] = std::move(t1);
// SavePlot* sp7 = new SavePlot(mpl, "plot#detector_plot_data.0.0#4.png", "/users/locatelli/offscreenImages/multiplot/pb");
// thread t7(bind(&SavePlot::run, sp7));
// tm_["plot#detector_plot_data0#Detector.png"] = std::move(t1);
// t7.detach();
// SavePlot* sp8 = new SavePlot(mpl, "plot#detector_plot_data.0.0#5.png", "/users/locatelli/offscreenImages/multiplot/pb");
// thread t8(bind(&SavePlot::run, sp8));
// tm_["plot#detector_plot_data0#Detector.png"] = std::move(t1);
// t8.detach();
// SavePlot* sp9 = new SavePlot(mpl, "plot#detector_plot_data.0.0#6.png", "/users/locatelli/offscreenImages/multiplot/pb");
// thread t9(bind(&SavePlot::run, sp9));
// t9.detach();
// SavePlot* sp10 = new SavePlot(mpl, "plot#detector_plot_data.0.0#7.png", "/users/locatelli/offscreenImages/multiplot/pb");
// thread t10(bind(&SavePlot::run, sp10));
// t10.detach();
// SavePlot* sp11 = new SavePlot(mpl, "plot#detector_plot_data.0.0#8.png", "/users/locatelli/offscreenImages/multiplot/pb");
// thread t11(bind(&SavePlot::run, sp11));
// t11.detach();
// SavePlot* sp12 = new SavePlot(mpl, "plot#detector_plot_data.0.0#9.png", "/users/locatelli/offscreenImages/multiplot/pb");
// thread t12(bind(&SavePlot::run, sp12));
// t12.detach();
if (++i > 1000) break; if (++i > 1000) break;
this_thread::sleep_for(chrono::milliseconds(500)); this_thread::sleep_for(chrono::milliseconds(500));
} }
...@@ -296,7 +276,7 @@ int main() { ...@@ -296,7 +276,7 @@ int main() {
// //
//// cout << "lock" << endl; //// cout << "lock" << endl;
//// { //// {
////// view::mpl::MplLock lock(__PRETTY_FUNCTION__); ////// view::mpl::MplLock lock;
// cout << "matplotlib" << endl; // cout << "matplotlib" << endl;
// matplotlib = bp::import(bp::str("matplotlib")); // matplotlib = bp::import(bp::str("matplotlib"));
//// ////
...@@ -308,7 +288,7 @@ int main() { ...@@ -308,7 +288,7 @@ int main() {
//// PyThreadState* threadState = PyEval_SaveThread(); //// PyThreadState* threadState = PyEval_SaveThread();
////// vector<thread*> threads; ////// vector<thread*> threads;
// for(uint32 i = 0; i <10; ++i) { // for(uint32 i = 0; i <10; ++i) {
//// view::mpl::MplLock lock(__PRETTY_FUNCTION__); //// view::mpl::MplLock lock;
//// cout << "figure lock past" << endl; //// cout << "figure lock past" << endl;
// bp::object fig = pyPlot.attr("figure")(); // bp::object fig = pyPlot.attr("figure")();
// cout << "figure : " << fig.is_none() << endl; // cout << "figure : " << fig.is_none() << endl;
......
...@@ -74,7 +74,7 @@ int main(int argc, char *argv[]) { ...@@ -74,7 +74,7 @@ int main(int argc, char *argv[]) {
// buf << counter++; // buf << counter++;
// window->set(buf.str()); // window->set(buf.str());
// { // {
// view::mpl::MplLock lock(__PRETTY_FUNCTION__); // view::mpl::MplLock lock;
// x.push_back(x.size() + 1); // x.push_back(x.size() + 1);
// y.push_back(1); // y.push_back(1);
// try { // try {
......
...@@ -101,11 +101,13 @@ void OffScreenPlotManager::loop(application::Subscriber* subscriber) { ...@@ -101,11 +101,13 @@ void OffScreenPlotManager::loop(application::Subscriber* subscriber) {
if (messageType.type() == notification::Message::ImageDataReady) { if (messageType.type() == notification::Message::ImageDataReady) {
notification::ImageDataReady messageImageReady; notification::ImageDataReady messageImageReady;
messageImageReady.ParseFromString(data2); try {
SavePlot* sp = new SavePlot(m_CounterId, m_Mpl, messageImageReady.imagename(), messageImageReady.imagepath()); messageImageReady.ParseFromString(data2);
thread* td = new thread(bind(&SavePlot::run, sp)); addThreadMapElement(m_Mpl, m_CounterId++, messageImageReady.imagename(), messageImageReady.imagepath());
td->detach(); }
addThreadMapElement(m_CounterId++, td, sp); catch (std::bad_alloc &e) {
Error("OffScreenPlotManager", "loop", "Bad parsing of ImageDataReady");
}
} }
} else { } else {
break; break;
...@@ -116,9 +118,15 @@ void OffScreenPlotManager::loop(application::Subscriber* subscriber) { ...@@ -116,9 +118,15 @@ void OffScreenPlotManager::loop(application::Subscriber* subscriber) {
/* /*
* addThreadMapElement * addThreadMapElement
*/ */
void OffScreenPlotManager::addThreadMapElement(uint32 id, std::thread* td, SavePlot* sp) { void OffScreenPlotManager::addThreadMapElement(view::mpl::Mpl* mpl, uint32 id, std::string pbfilename, std::string path) {
std::lock_guard<std::mutex> lock(m_ThreadMapMutex); std::lock_guard<std::mutex> lock(m_ThreadMapMutex);
m_ThreadMap[id] = make_pair(td, sp); if (m_ThreadMap.find(id) == m_ThreadMap.end()) {
SavePlot sp(m_CounterId, m_Mpl, pbfilename, path);
thread td(bind(&SavePlot::run, sp));
td.detach();
m_ThreadMap[id] = std::move(td);
m_SavePlotMap[id] = std::move(sp);
}
} }
/* /*
...@@ -128,10 +136,13 @@ void OffScreenPlotManager::delThreadMapElement(uint32 id) { ...@@ -128,10 +136,13 @@ void OffScreenPlotManager::delThreadMapElement(uint32 id) {
std::lock_guard<std::mutex> lock(m_ThreadMapMutex); std::lock_guard<std::mutex> lock(m_ThreadMapMutex);
ThreadMap::iterator it = m_ThreadMap.find(id); ThreadMap::iterator it = m_ThreadMap.find(id);
if (it != m_ThreadMap.end()) { if (it != m_ThreadMap.end()) {
delete it->second.first; it->second.std::thread::~thread();
delete it->second.second;
m_ThreadMap.erase(id); m_ThreadMap.erase(id);
} }
SavePlotMap::iterator it1 = m_SavePlotMap.find(id);
if (it1 != m_SavePlotMap.end()) {
m_SavePlotMap.erase(id);
}
} }
/* /*
...@@ -144,6 +155,13 @@ SavePlot::SavePlot(uint32 id, view::mpl::Mpl* mpl, const std::string& pbfilename ...@@ -144,6 +155,13 @@ SavePlot::SavePlot(uint32 id, view::mpl::Mpl* mpl, const std::string& pbfilename
m_Path = path; m_Path = path;
} }
/*
* savePlot
*/
SavePlot::SavePlot() {
m_Mpl = nullptr;
}
/* /*
* savePlot * savePlot
*/ */
......
...@@ -36,6 +36,11 @@ class SavePlot { ...@@ -36,6 +36,11 @@ class SavePlot {
public: public:
/*!
* \brief constructor
*/
SavePlot();
/*! /*!
* \brief constructor * \brief constructor
* \param[in] mpl The mpl object * \param[in] mpl The mpl object
...@@ -113,14 +118,16 @@ private: ...@@ -113,14 +118,16 @@ private:
*/ */
void reset(); void reset();
void addThreadMapElement(uint32 id, std::thread* td, SavePlot* sp); void addThreadMapElement(view::mpl::Mpl* mpl, uint32 id, std::string pbfilename, std::string path);
static OffScreenPlotManager* m_Instance; //! Pointer of singleton instance static OffScreenPlotManager* m_Instance; //! Pointer of singleton instance
view::mpl::Mpl* m_Mpl; //! Mpl object (main class which managed the matplotib api) view::mpl::Mpl* m_Mpl; //! Mpl object (main class which managed the matplotib api)
typedef std::unordered_map<uint32, std::pair<std::thread*, SavePlot*>> ThreadMap; typedef std::unordered_map<uint32, std::thread> ThreadMap;
typedef std::unordered_map<uint32, SavePlot> SavePlotMap;
ThreadMap m_ThreadMap; ThreadMap m_ThreadMap;
SavePlotMap m_SavePlotMap;
std::mutex m_ThreadMapMutex; std::mutex m_ThreadMapMutex;
uint32 m_CounterId; uint32 m_CounterId;
}; };
......
...@@ -48,7 +48,7 @@ MplEventManager::MplEventManager() { ...@@ -48,7 +48,7 @@ MplEventManager::MplEventManager() {
* constructor * constructor
*/ */
MplEventManager::~MplEventManager() { MplEventManager::~MplEventManager() {
MplLock lock(__PRETTY_FUNCTION__); MplLock lock;
m_ModuleEvent = bp::object(); m_ModuleEvent = bp::object();
} }
...@@ -57,7 +57,7 @@ MplEventManager::~MplEventManager() { ...@@ -57,7 +57,7 @@ MplEventManager::~MplEventManager() {
*/ */
void MplEventManager::init(view::mpl::Mpl* mpl) { void MplEventManager::init(view::mpl::Mpl* mpl) {
m_mpl = mpl; m_mpl = mpl;
MplLock lock(__PRETTY_FUNCTION__); MplLock lock;
try { try {
m_ModuleEvent = bp::import(bp::str(MODULE_EVENT_NAME)); m_ModuleEvent = bp::import(bp::str(MODULE_EVENT_NAME));
} catch (...) { } catch (...) {
...@@ -96,7 +96,7 @@ MplEventManager* MplEventManager::getInstance() { ...@@ -96,7 +96,7 @@ MplEventManager* MplEventManager::getInstance() {
* subscriberXLimChanged * subscriberXLimChanged
*/ */
void MplEventManager::subscribeXLimChanged(bp::object* obj, MplEventSubscriber* subscriber) throw (Error) { void MplEventManager::subscribeXLimChanged(bp::object* obj, MplEventSubscriber* subscriber) throw (Error) {
MplLock mpllock(__PRETTY_FUNCTION__); MplLock mpllock;
unique_lock<recursive_mutex> lock(m_XLimChangedMutex); unique_lock<recursive_mutex> lock(m_XLimChangedMutex);
if (m_XLimChangedSubcribers.find(obj) == m_XLimChangedSubcribers.end()) { if (m_XLimChangedSubcribers.find(obj) == m_XLimChangedSubcribers.end()) {
// Connect pick event // Connect pick event
...@@ -112,7 +112,7 @@ void MplEventManager::subscribeXLimChanged(bp::object* obj, MplEventSubscriber* ...@@ -112,7 +112,7 @@ void MplEventManager::subscribeXLimChanged(bp::object* obj, MplEventSubscriber*
* unsubscriberXLimChanged * unsubscriberXLimChanged
*/ */
void MplEventManager::unsubscribeXLimChanged(bp::object* obj) throw (Error) { void MplEventManager::unsubscribeXLimChanged(bp::object* obj) throw (Error) {
MplLock mpllock(__PRETTY_FUNCTION__); MplLock mpllock;
unique_lock<recursive_mutex> lock(m_XLimChangedMutex); unique_lock<recursive_mutex> lock(m_XLimChangedMutex);
// remove subscriber from map // remove subscriber from map
if (m_XLimChangedSubcribers.find(obj) != m_XLimChangedSubcribers.end()) { if (m_XLimChangedSubcribers.find(obj) != m_XLimChangedSubcribers.end()) {
...@@ -145,7 +145,7 @@ void MplEventManager::xlimChanged(PyObject *self, PyObject* event) { ...@@ -145,7 +145,7 @@ void MplEventManager::xlimChanged(PyObject *self, PyObject* event) {
* subscriberYLimChanged * subscriberYLimChanged
*/ */
void MplEventManager::subscribeYLimChanged(bp::object* obj, MplEventSubscriber* subscriber) throw (Error) { void MplEventManager::subscribeYLimChanged(bp::object* obj, MplEventSubscriber* subscriber) throw (Error) {
MplLock mpllock(__PRETTY_FUNCTION__); MplLock mpllock;
unique_lock<recursive_mutex> lock(m_YLimChangedMutex); unique_lock<recursive_mutex> lock(m_YLimChangedMutex);
if (m_YLimChangedSubcribers.find(obj) == m_YLimChangedSubcribers.end()) { if (m_YLimChangedSubcribers.find(obj) == m_YLimChangedSubcribers.end()) {
// Connect pick event // Connect pick event
...@@ -161,7 +161,7 @@ void MplEventManager::subscribeYLimChanged(bp::object* obj, MplEventSubscriber* ...@@ -161,7 +161,7 @@ void MplEventManager::subscribeYLimChanged(bp::object* obj, MplEventSubscriber*
* unsubscriberYLimChanged * unsubscriberYLimChanged
*/ */
void MplEventManager::unsubscribeYLimChanged(bp::object* obj) throw (Error) { void MplEventManager::unsubscribeYLimChanged(bp::object* obj) throw (Error) {
MplLock mpllock(__PRETTY_FUNCTION__); MplLock mpllock;
unique_lock<recursive_mutex> lock(m_YLimChangedMutex); unique_lock<recursive_mutex> lock(m_YLimChangedMutex);
// remove subscriber from map // remove subscriber from map
if (m_YLimChangedSubcribers.find(obj) != m_YLimChangedSubcribers.end()) { if (m_YLimChangedSubcribers.find(obj) != m_YLimChangedSubcribers.end()) {
......
...@@ -282,8 +282,8 @@ void PropertyPlot2D::updateProjections() { ...@@ -282,8 +282,8 @@ void PropertyPlot2D::updateProjections() {
if (lims[1] >= m_dataprojx.size()) { if (lims[1] >= m_dataprojx.size()) {
lims[1] = m_dataprojx.size() - 1; lims[1] = m_dataprojx.size() - 1;
} }
float64 projymin = *std::min_element(m_dataprojx.begin() + lims[0], m_dataprojx.begin() + lims[1]); float64 projymin = *std::min_element(m_dataprojx.begin() + lims[0], m_dataprojx.begin() + lims[1] + 1);
float64 projymax = *std::max_element(m_dataprojx.begin() + lims[0], m_dataprojx.begin() + lims[1]); float64 projymax = *std::max_element(m_dataprojx.begin() + lims[0], m_dataprojx.begin() + lims[1] + 1);
m_MplPlot2D.set_projxlim(projymin, projymax); m_MplPlot2D.set_projxlim(projymin, projymax);
} }
// Reset y data limits of Y projection // Reset y data limits of Y projection
...@@ -294,8 +294,8 @@ void PropertyPlot2D::updateProjections() { ...@@ -294,8 +294,8 @@ void PropertyPlot2D::updateProjections() {
if (lims[3] >= m_dataprojy.size()) { if (lims[3] >= m_dataprojy.size()) {
lims[3] = m_dataprojy.size() - 1; lims[3] = m_dataprojy.size() - 1;
} }
float64 projxmin = *std::min_element(m_dataprojy.begin() + lims[2], m_dataprojy.begin() + lims[3]); float64 projxmin = *std::min_element(m_dataprojy.begin() + lims[2], m_dataprojy.begin() + lims[3] + 1);
float64 projxmax = *std::max_element(m_dataprojy.begin() + lims[2], m_dataprojy.begin() + lims[3]); float64 projxmax = *std::max_element(m_dataprojy.begin() + lims[2], m_dataprojy.begin() + lims[3] + 1);
m_MplPlot2D.set_projylim(projxmin, projxmax); m_MplPlot2D.set_projylim(projxmin, projxmax);
} }
// Update image on mpl plot // Update image on mpl plot
......
...@@ -45,7 +45,7 @@ const sipAPIDef *sipAPI() { ...@@ -45,7 +45,7 @@ const sipAPIDef *sipAPI() {
*/ */
template<typename T> T *extract(const boost::python::object &obj) throw (Error) { template<typename T> T *extract(const boost::python::object &obj) throw (Error) {
mpl::MplLock lock(__PRETTY_FUNCTION__); mpl::MplLock lock;
const auto sipapi = sipAPI(); const auto sipapi = sipAPI();
if (!PyObject_TypeCheck(obj.ptr(), sipapi->api_wrapper_type)) { if (!PyObject_TypeCheck(obj.ptr(), sipapi->api_wrapper_type)) {
......
...@@ -146,7 +146,7 @@ Mpl::~Mpl() { ...@@ -146,7 +146,7 @@ Mpl::~Mpl() {
* close * close
*/ */
void Mpl::close(const bp::object& figure) throw (Error) { void Mpl::close(const bp::object& figure) throw (Error) {
MplLock lock(__PRETTY_FUNCTION__); MplLock lock;
// Create matplotlib figure object // Create matplotlib figure object
auto args = bp::make_tuple(figure); auto args = bp::make_tuple(figure);
...@@ -161,7 +161,7 @@ void Mpl::close(const bp::object& figure) throw (Error) { ...@@ -161,7 +161,7 @@ void Mpl::close(const bp::object& figure) throw (Error) {
* xlabel * xlabel
*/ */
void Mpl::xlabel(const bp::object& axis, const std::string& name) throw (Error) { void Mpl::xlabel(const bp::object& axis, const std::string& name) throw (Error) {
mpl::MplLock lock(__PRETTY_FUNCTION__); mpl::MplLock lock;
try { try {
bp::call_method<void, const char *>(axis.ptr(), "set_xlabel", name.c_str()); bp::call_method<void, const char *>(axis.ptr(), "set_xlabel", name.c_str());
} catch (...) { } catch (...) {
...@@ -173,7 +173,7 @@ void Mpl::xlabel(const bp::object& axis, const std::string& name) throw (Error) ...@@ -173,7 +173,7 @@ void Mpl::xlabel(const bp::object& axis, const std::string& name) throw (Error)
* ylabel * ylabel
*/ */
void Mpl::ylabel(const bp::object& axis, const std::string& name) throw (Error) { void Mpl::ylabel(const bp::object& axis, const std::string& name) throw (Error) {
mpl::MplLock lock(__PRETTY_FUNCTION__); mpl::MplLock lock;
try { try {
bp::call_method<void, const char *>(axis.ptr(), "set_ylabel", name.c_str()); bp::call_method<void, const char *>(axis.ptr(), "set_ylabel", name.c_str());
} catch (...) { } catch (...) {
...@@ -185,7 +185,7 @@ void Mpl::ylabel(const bp::object& axis, const std::string& name) throw (Error) ...@@ -185,7 +185,7 @@ void Mpl::ylabel(const bp::object& axis, const std::string& name) throw (Error)
* grid * grid
*/ */
void Mpl::grid(const bp::object& axis, bool show) throw (Error) { void Mpl::grid(const bp::object& axis, bool show) throw (Error) {
mpl::MplLock lock(__PRETTY_FUNCTION__); mpl::MplLock lock;
bp::tuple args; bp::tuple args;
if (show == true) { if (show == true) {
args = bp::make_tuple(true); args = bp::make_tuple(true);
...@@ -204,7 +204,7 @@ void Mpl::grid(const bp::object& axis, bool show) throw (Error) { ...@@ -204,7 +204,7 @@ void Mpl::grid(const bp::object& axis, bool show) throw (Error) {
* savefig * savefig
*/ */
void Mpl::savefig(const bp::object& figure, const std::string& filename, uint32 dpi, float64 pad) throw (Error) { void Mpl::savefig(const bp::object& figure, const std::string& filename, uint32 dpi, float64 pad) throw (Error) {
mpl::MplLock lock(__PRETTY_FUNCTION__); mpl::MplLock lock;
auto args = bp::make_tuple(filename); auto args = bp::make_tuple(filename);
bp::dict kwargs; bp::dict kwargs;
kwargs["format"] = "png"; kwargs["format"] = "png";
...@@ -224,7 +224,7 @@ void Mpl::savefig(const bp::object& figure, const std::string& filename, uint32 ...@@ -224,7 +224,7 @@ void Mpl::savefig(const bp::object& figure, const std::string& filename, uint32
* get_xlim * get_xlim
*/ */
std::pair<float64, float64> Mpl::get_xlim(const bp::object& axis) throw (Error) { std::pair<float64, float64> Mpl::get_xlim(const bp::object& axis) throw (Error) {
mpl::MplLock lock(__PRETTY_FUNCTION__); mpl::MplLock lock;
try { try {
bp::tuple res(axis.attr("get_xlim")()); bp::tuple res(axis.attr("get_xlim")());
float64 min = bp::extract<float64>(res[0]);