[pve-devel] [PATCH ha-manager 4/6] sim: improve canceling the migrate dialog

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Jan 12 15:51:57 CET 2017


We could only cancel the migrate dialog by pressing ESC or - if the
used window manager supports it - by pressing the windows "X" button
in the window border.
Pressing ESC caused a warning because the result of the domain was
now a string containing the signal names, as we checked for an
integer to see if the "Ok" button was pressed perl warned us about:
 > Argument "closed" isn't numeric in int at ...

Improve this by adding a cancel button and by switching the button
return values from integer to strings, which can be compared in a
more general way.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 src/PVE/HA/Sim/RTHardware.pm | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/PVE/HA/Sim/RTHardware.pm b/src/PVE/HA/Sim/RTHardware.pm
index 7d1210d..bda1356 100644
--- a/src/PVE/HA/Sim/RTHardware.pm
+++ b/src/PVE/HA/Sim/RTHardware.pm
@@ -415,14 +415,15 @@ sub show_migrate_dialog {
 
     $contarea->add($grid);
 
-    $dialog->add_button("_OK", 1);
+    $dialog->add_button("_OK", 'ok');
+    $dialog->add_button("_Cancel", 'cancel');
 
     $dialog->show_all();
     my $res = $dialog->run();
 
     $dialog->destroy();
 
-    if ($res == 1 && $target) {
+    if (defined($res) && $res eq 'ok' && $target) {
 	if ($relocate_btn->get_active()) {
 	    $self->queue_crm_commands("relocate $sid $target");
 	} else {
-- 
2.1.4





More information about the pve-devel mailing list