diff --git a/configure1 b/configure1 index a3c533e..4e644d3 100644 --- a/configure1 +++ b/configure1 @@ -1,5 +1,5 @@ # Initial information about the package -AC_INIT([Agate],[1.4.0],[jordan.bieder@uliege.be]) +AC_INIT([Agate],[1.4.1],[jordan.bieder@uliege.be]) # Check source directory AC_CONFIG_SRCDIR([bin/agate.cpp]) diff --git a/src/plot/gnuplot.cpp b/src/plot/gnuplot.cpp index 64a38d3..786f3c5 100644 --- a/src/plot/gnuplot.cpp +++ b/src/plot/gnuplot.cpp @@ -38,13 +38,12 @@ Gnuplot::Gnuplot() : Graph(), _buffer(), _custom() { - _gp.reset(popen("gnuplot","w")); - if (errno != 0) { - pclose(_gp.release()); - _gp=nullptr; - } - if ( _gp.get() == nullptr ) + errno = 0; + auto* fd = popen("gnuplot","w"); + auto ret = pclose(fd); + if ( ret != 0 ) throw EXCEPTION("Unable to open pipe for gnuplot",ERRABT); + _gp.reset(popen("gnuplot","w")); _header << "reset" << std::endl; _header << "set style data line" << std::endl; _header << "set autoscale xy" << std::endl; @@ -57,10 +56,9 @@ Gnuplot::~Gnuplot() { if ( _gp != nullptr ) { fprintf(_gp.get(),"%s\n","quit"); fflush(_gp.get()); - r_val = pclose(_gp.get()); - _gp.release(); - if (r_val == -1) { - Exception e(EXCEPTION("Can not close gnuplot", ERRABT)); + r_val = pclose(_gp.release()); + if (r_val != 0) { + Exception e(EXCEPTION("Gnuplot returned non-zero code", ERRABT)); std::cerr << e.fullWhat() << std::endl; } } @@ -111,7 +109,7 @@ void Gnuplot::plot(const std::vector &x, const std::list &x, const std::list,std::vectordump(com,filename); - if ( _gp.get() != nullptr ) { + if ( _gp != nullptr ) { fprintf(_gp.get(),"%s\n",com.str().c_str()); fflush(_gp.get()); }