From d79d4633c8634a6e93893d14c322aa541c107ac6 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Mon, 23 Sep 2024 19:54:44 -0400 Subject: [PATCH] snapshots: Don't save outdated screenshot data Current code will take a screenshot when the 'New Snapshot' dialog is initially launched, and then use that cached content as the screenshot for the snapshot... which may be totally out of date by the time the user enters all the snapshot info. Instead, drop the snapshot preview UI in the 'New Snapshot' wizard entirely, and use a screenshot that is fetched after the user actually clicks 'Finish' Signed-off-by: Cole Robinson --- ui/snapshotsnew.ui | 27 +-------------------------- virtManager/details/snapshots.py | 26 ++------------------------ 2 files changed, 3 insertions(+), 50 deletions(-) diff --git a/ui/snapshotsnew.ui b/ui/snapshotsnew.ui index 4eba43fa4..5f3285e22 100644 --- a/ui/snapshotsnew.ui +++ b/ui/snapshotsnew.ui @@ -89,7 +89,7 @@ True False - + True False @@ -203,31 +203,6 @@ 1 - - - True - False - start - start - Screenshot: - - - 0 - 5 - - - - - True - False - start - image-missing - - - 1 - 5 - - True diff --git a/virtManager/details/snapshots.py b/virtManager/details/snapshots.py index ae9280ec5..a4f38de6d 100644 --- a/virtManager/details/snapshots.py +++ b/virtManager/details/snapshots.py @@ -165,12 +165,6 @@ class vmmSnapshotNew(vmmGObjectUI): self.widget("snapshot-new-status-icon").set_from_icon_name( self.vm.run_status_icon_name(), Gtk.IconSize.BUTTON) - sn = self._get_screenshot() - uiutil.set_grid_row_visible( - self.widget("snapshot-new-screenshot"), bool(sn)) - if sn: - self.widget("snapshot-new-screenshot").set_from_pixbuf(sn) - self._reset_snapshot_mode() self._reset_snapshot_memory_path() @@ -265,10 +259,7 @@ class vmmSnapshotNew(vmmGObjectUI): if not ext: return # pragma: no cover - newpix = _make_screenshot_pixbuf(mime, sdata) - setattr(newpix, "vmm_mimetype", mime) - setattr(newpix, "vmm_sndata", sdata) - return newpix + return mime, sdata def _get_mode(self): mode_external = self.widget("snapshot-new-mode-external") @@ -308,19 +299,6 @@ class vmmSnapshotNew(vmmGObjectUI): except Exception as e: return self.err.val_err(_("Error validating snapshot: %s") % e) - def _get_screenshot_data_for_save(self): - snwidget = self.widget("snapshot-new-screenshot") - if not snwidget.is_visible(): - return None, None - - sn = snwidget.get_pixbuf() - if not sn: # pragma: no cover - return None, None - - mime = getattr(sn, "vmm_mimetype", None) - sndata = getattr(sn, "vmm_sndata", None) - return mime, sndata - def _do_create_snapshot(self, asyncjob, xml, name, mime, sndata, diskOnly): ignore = asyncjob @@ -352,7 +330,7 @@ class vmmSnapshotNew(vmmGObjectUI): xml = snap.get_xml() name = snap.name - mime, sndata = self._get_screenshot_data_for_save() + mime, sndata = (self._get_screenshot() or (None, None)) diskOnly = not self.vm.is_active() and self._get_mode() == "external" self.set_finish_cursor()