[PATCH] Delete the file object if the trace file could not be loaded due to being an unsupported (newer) version.

Peter Lohrmann peterl at valvesoftware.com
Thu Jul 4 09:42:34 PDT 2013


I fixed small memory leak / assert if a trace file can't be loaded due to being recorded with a newer version number than qapitrace. In this scenario, there is no error message that gets shown in the UI, but the title bar is updated with the trace file name, so the situation is very confusing. Is there an easy way to address these issues? I haven't used Qt enough yet to fully understand the moc files, etc, so I don't know the easiest way to add an 'error' Qevent that can be emitted back to the main window from the parser. Any help (or another patch) would be appreciated!

The version issue came up as I just started looking at the more-thumbnails branch, but it only supports version 4 of the trace files, and master is up to version 5 now. It seems the various branches need to be updated again.

- Peter

---
common/trace_parser.cpp | 2 ++
1 file changed, 2 insertions(+)

diff --git a/common/trace_parser.cpp b/common/trace_parser.cpp
index 095af67..6013b39 100644
--- a/common/trace_parser.cpp
+++ b/common/trace_parser.cpp
@@ -65,6 +65,8 @@ bool Parser::open(const char *filename) {
     version = read_uint();
     if (version > TRACE_VERSION) {
         std::cerr << "error: unsupported trace format version " << version << "\n";
+        delete file;
+        file = NULL;
         return false;
     }
     api = API_UNKNOWN;
--
1.8.1.msysgit.1

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/apitrace/attachments/20130704/cdcfbf91/attachment.html>


More information about the apitrace mailing list