changeset 20280:a5f9bf4df254 stable

Avoid crash when trying to annotate an empty figure (bug #45241) * Canvas.cc (Canvas::canvasMouseMoveEvent): allow axes object to be invalid when in TextMode * Canvas.cc (Canvas::canvasMousePressEvent): don't define m_mouseAxes when in textmode
author Pantxo Diribarne <pantxo.diribarne@gmail.com>
date Tue, 02 Jun 2015 19:42:07 +0200
parents 0bb456e9423b
children 6fe746def1aa
files libgui/graphics/Canvas.cc
diffstat 1 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/graphics/Canvas.cc	Tue Jun 02 19:24:44 2015 +0200
+++ b/libgui/graphics/Canvas.cc	Tue Jun 02 19:42:07 2015 +0200
@@ -401,14 +401,14 @@
   gh_manager::auto_lock lock;
   graphics_object ax = gh_manager::get_object (m_mouseAxes);
 
-  if (m_mouseMode != NoMode && ax.valid_object ())
+  if (m_mouseMode != NoMode && (ax.valid_object () || m_mouseMode == TextMode))
     {
-      axes::properties& ap = Utils::properties<axes> (ax);
-
       switch (m_mouseMode)
         {
         case RotateMode:
           {
+            axes::properties& ap = Utils::properties<axes> (ax);
+
             ap.rotate3d (m_mouseCurrent.x (), event->x (),
                          m_mouseCurrent.y (), event->y ());
 
@@ -428,6 +428,8 @@
 
         case PanMode:
           {
+            axes::properties& ap = Utils::properties<axes> (ax);
+
             graphics_object figObj (ax.get_ancestor ("figure"));
 
             std::string mode = pan_mode (figObj);
@@ -617,7 +619,6 @@
                   {
                   case Qt::LeftButton:
                     m_mouseAnchor = m_mouseCurrent = event->pos ();
-                    m_mouseAxes = axesObj.get_handle ();
                     m_mouseMode = newMouseMode;
                     m_rectMode = true;
                   }