On 2018-12-31 16:05-0000 António Rodrigues Tomé wrote:
Hi Alan let's do a small change in qt_example. cpp to make it more orthodox. QApplication a( argc, argv ); PlotWindow win ( Argc, Argv ); win.show(); when I do this the program always crashes on close in my system. much likely because there is an attempt to free twice a memory block. It may result from setAttribute( Qt::WA_DeleteOnClose ); on qt_Plotwindow.cpp as at destructor level qt may try to free something that the driver has already free. the fact is if I erase or comment that line the program does not crash anymore on exit.
Hi António: Thanks for these comments. In particular your remark on setAttribute( Qt::WA_DeleteOnClose ) is likely to be quite relevant to my experiments today. Just to let you know where I am at the moment, I have been looking carefully at PlotWindow since that class is a part of qt_example (i.e., not part of the extqt device or the PLplot qt binding). And since I am not that familiar with extqt, I have been taking an experimental approach to learning about it starting with figuring out all the ramifications of PlotWindow construction and destruction by the following temporary changes to qt_example: argc = 1; QApplication a( argc, argv ); // Must construct an instance of PlotWindow after QApplication. PlotWindow * win = new PlotWindow( Argc, Argv ); // Clean up Argv now that we are done with processing arguments. for ( int i = 0; i < Argc; ++i ) { delete[] Argv[i]; } delete[] Argv; delete win; return 0; So the QApplication never gets explicitly used in this experimental version of the code whose job is simply to test the PlotWindow constructor and destructor without actually using the PlotWindow instance for anything. An additional important part of these experiments is to make some changes to the destructor such as calling plend from there. And now I am going to test the effect of the Qt::WA_DeleteOnClose attribute as well. For each such variant of the destructor I build the qt_example target (which builds the qt_example application and all its PLplot prerequisites) with the -g option for gcc and g++ and analyzed run-time results using valgrind --leak-check=full --show-leak-kinds=all --num-callers=500 examples/c++/qt_example >| valgrind.out 2>&1 The goal of these experiments is to implement a rock-solid destructor for PlotWindow that leaves no memory directly allocated by PLplot that continues to be allocated after PlotWindow destruction. I hasten to add I am no where near that goal at the moment, but these experiments are yielding a lot of data that I hope will help me to eventually reach that goal. Alan __________________________ Alan W. Irwin Programming affiliations with the FreeEOS equation-of-state implementation for stellar interiors (freeeos.sf.net); the Time Ephemerides project (timeephem.sf.net); PLplot scientific plotting software package (plplot.sf.net); the libLASi project (unifont.org/lasi); the Loads of Linux Links project (loll.sf.net); and the Linux Brochure Project (lbproject.sf.net). __________________________ Linux-powered Science __________________________ _______________________________________________ Plplot-devel mailing list Plplot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/plplot-devel