Raw -> Smart Pointers for mupp_plotter, qt5/qt6.

This commit is contained in:
2023-10-24 16:07:56 +02:00
parent 843770505a
commit 01567bb6f0
6 changed files with 48 additions and 160 deletions

View File

@@ -28,6 +28,7 @@
***************************************************************************/
#include <iostream>
#include <memory>
#include <TApplication.h>
#include <TSAXParser.h>
@@ -55,40 +56,22 @@ int main(int argc, char *argv[])
// read startup file
char startup_path_name[128];
TSAXParser *saxParser = new TSAXParser();
PMuppStartupHandler *startupHandler = new PMuppStartupHandler();
std::unique_ptr<TSAXParser> saxParser = std::make_unique<TSAXParser>();
std::unique_ptr<PMuppStartupHandler> startupHandler = std::make_unique<PMuppStartupHandler>();
if (!startupHandler->StartupFileFound()) {
std::cerr << std::endl << ">> mupp_plot **WARNING** couldn't find " << startupHandler->GetStartupFilePath().Data();
std::cerr << std::endl;
// clean up
if (saxParser) {
delete saxParser;
saxParser = 0;
}
if (startupHandler) {
delete startupHandler;
startupHandler = 0;
}
} else {
strcpy(startup_path_name, startupHandler->GetStartupFilePath().Data());
saxParser->ConnectToHandler("PMuppStartupHandler", startupHandler);
saxParser->ConnectToHandler("PMuppStartupHandler", startupHandler.get());
// parsing the file as above seems to lead to problems in certain environments;
// use the parseXmlFile function instead (see PMuppStartupHandler.cpp for the definition)
Int_t status = parseXmlFile(saxParser, startup_path_name);
Int_t status = parseXmlFile(saxParser.get(), startup_path_name);
// check for parse errors
if (status) { // error
std::cerr << std::endl << ">> mupp_plot **WARNING** Reading/parsing mupp_startup.xml failed.";
std::cerr << std::endl << ">> Graph will appear with random symbols and colors!";
std::cerr << std::endl;
// clean up
if (saxParser) {
delete saxParser;
saxParser = 0;
}
if (startupHandler) {
delete startupHandler;
startupHandler = 0;
}
} else {
startupHandler->CheckLists();
}
@@ -103,7 +86,7 @@ int main(int argc, char *argv[])
startupHandler->GetColorList(),
mupp_instance);
if (muppCanvas != 0) {
if (muppCanvas != nullptr) {
if (muppCanvas->IsValid()) {
// connect signal/slot
TQObject::Connect("TCanvas", "Closed()", "PMuppCanvas", muppCanvas, "LastCanvasClosed()");
@@ -125,14 +108,6 @@ int main(int argc, char *argv[])
app.Run(true); // true needed that Run will return after quit so that cleanup works
// clean up
if (saxParser) {
delete saxParser;
saxParser = 0;
}
if (startupHandler) {
delete startupHandler;
startupHandler = 0;
}
if (muppCanvas) {
delete muppCanvas;
muppCanvas = 0;