]> git.cworth.org Git - vogl/blobdiff - src/vogleditor/vogleditor_tracereplayer.cpp
UI: separate capturing of vogl_gl_state_snapshot from allocation of the vogleditor_gl...
[vogl] / src / vogleditor / vogleditor_tracereplayer.cpp
index 383a2b11955a9fc12e151d4570b3a6fa9fb69e32..c7d826bd4cc65661c5f6d7c0c03dc501bd6cc8f0 100644 (file)
@@ -173,15 +173,20 @@ bool vogleditor_traceReplayer::recursive_replay_apicallTreeItem(vogleditor_apiCa
                {
                   vogl_printf("Taking snapshot on API call # %" PRIu64 "\n", apiCallNumber);
 
-                  *ppNewSnapshot = vogl_new(vogleditor_gl_state_snapshot, m_pTraceReplayer->snapshot_state());
-
-                  if (*ppNewSnapshot == NULL)
+                  vogl_gl_state_snapshot* pNewSnapshot = m_pTraceReplayer->snapshot_state();
+                  if (pNewSnapshot == NULL)
                   {
-                     vogl_error_printf("Snapshot failed!\n");
+                      vogl_error_printf("Taking new snapshot failed!\n");
                   }
                   else
                   {
-                      vogl_printf("Snapshot succeeded\n");
+                      vogl_printf("Taking snapshot succeeded\n");
+                      *ppNewSnapshot = vogl_new(vogleditor_gl_state_snapshot, pNewSnapshot);
+                      if (*ppNewSnapshot == NULL)
+                      {
+                         vogl_error_printf("Allocating memory for snapshot container failed!\n");
+                         vogl_delete(pNewSnapshot);
+                      }
                   }
 
                   bStatus = false;
@@ -196,7 +201,7 @@ bool vogleditor_traceReplayer::recursive_replay_apicallTreeItem(vogleditor_apiCa
         }
     }
 
-    if (bStatus && pItem->has_snapshot() && pItem->get_snapshot()->is_edited())
+    if (bStatus && pItem->has_snapshot() && pItem->get_snapshot()->is_edited() && pItem->get_snapshot()->is_valid())
     {
         bStatus = applying_snapshot_and_process_resize(pItem->get_snapshot()->get_snapshot());
     }