changeset 27794:18de38659606

Prevent uipanel from being redrawn when its bbox didn't change (bug #57350) * Panel.h, Panel.cc (Panel::m_previous_bbox): New member variable. (Panel::update): Do nothing if the the position didn't change. Update m_previous_bbox.
author Pantxo Diribarne <pantxo.diribarne@gmail.com>
date Tue, 03 Dec 2019 17:50:59 +0100
parents d8c53771645c
children 0157c4d4792e
files libgui/graphics/Panel.cc libgui/graphics/Panel.h
diffstat 2 files changed, 13 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/graphics/Panel.cc	Sun Dec 08 22:06:09 2019 +0100
+++ b/libgui/graphics/Panel.cc	Tue Dec 03 17:50:59 2019 +0100
@@ -109,7 +109,8 @@
   Panel::Panel (octave::base_qobject& oct_qobj, octave::interpreter& interp,
                 const graphics_object& go, QFrame *frame)
     : Object (oct_qobj, interp, go, frame), m_container (nullptr),
-      m_title (nullptr), m_blockUpdates (false)
+      m_title (nullptr), m_blockUpdates (false),
+      m_previous_bbox (Matrix (1, 4, 0))
   {
     uipanel::properties& pp = properties<uipanel> ();
 
@@ -266,10 +267,16 @@
       case uipanel::properties::ID_POSITION:
         {
           Matrix bb = pp.get_boundingbox (false);
-
-          frame->setGeometry (octave::math::round (bb(0)), octave::math::round (bb(1)),
-                              octave::math::round (bb(2)), octave::math::round (bb(3)));
-          updateLayout ();
+          if (m_previous_bbox(0) != bb(0) || m_previous_bbox(1) != bb(1)
+              || m_previous_bbox(2) != bb(2) || m_previous_bbox(3) != bb(3))
+            {
+              frame->setGeometry (octave::math::round (bb(0)),
+                                  octave::math::round (bb(1)),
+                                  octave::math::round (bb(2)),
+                                  octave::math::round (bb(3)));
+              updateLayout ();
+            }
+          m_previous_bbox = bb;
         }
         break;
 
--- a/libgui/graphics/Panel.h	Sun Dec 08 22:06:09 2019 +0100
+++ b/libgui/graphics/Panel.h	Tue Dec 03 17:50:59 2019 +0100
@@ -68,6 +68,7 @@
     Container *m_container;
     QLabel *m_title;
     bool m_blockUpdates;
+    Matrix m_previous_bbox;
   };
 
 }