changeset 26321:cb96d4ba6daa

maint: merge stable to default.
author Rik <rik@octave.org>
date Sat, 29 Dec 2018 22:36:48 -0800
parents 7902a3a8f02c (current diff) 92c88ff62055 (diff)
children a025fcd02c60
files libinterp/corefcn/graphics.cc
diffstat 5 files changed, 61 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/documentation.cc	Fri Dec 28 22:05:27 2018 -0800
+++ b/libgui/src/documentation.cc	Sat Dec 29 22:36:48 2018 -0800
@@ -388,19 +388,28 @@
 
   void documentation::global_search (void)
   {
+
+    QString query_string;
 #if defined (HAVE_QHELPSEARCHQUERYWIDGET_SEARCHINPUT)
     QString queries
       = m_help_engine->searchEngine ()->queryWidget ()->searchInput ();
-    m_query_string = queries.split (" ").first ();
+    query_string = queries;
 #else
+    // FIXME: drop this part when support for Qt4 is dropped
     QList<QHelpSearchQuery> queries
       = m_help_engine->searchEngine ()->queryWidget ()->query ();
     if (queries.count ())
-      m_query_string = queries.first ().wordList.first ();
+      query_string = queries.first ().wordList.join (" ");
     else
-      m_query_string = "";
+      query_string = "";
 #endif
 
+    // Get quoted search strings first, then take first string as fall back
+    QRegExp rx ("\"([^\"]*)\"");
+    if (rx.indexIn (query_string, 0) != -1)
+      m_query_string = rx.cap (1);
+    else
+      m_query_string = query_string.split (" ", QString::SkipEmptyParts).first ();
 
     m_help_engine->searchEngine ()->search (queries);
   }
--- a/libinterp/corefcn/graphics.cc	Fri Dec 28 22:05:27 2018 -0800
+++ b/libinterp/corefcn/graphics.cc	Sat Dec 29 22:36:48 2018 -0800
@@ -12439,7 +12439,9 @@
 
   caseless_str p ("parent");
 
-  for (int i = 0; i < xargs.length (); i++)
+  // Remove all "parent" property overrides of the first argument to function
+  // and accept only the last one (bug #55322).
+  for (int i = 0; i < xargs.length (); i += 2)
     {
       if (xargs(i).is_string () && p.compare (xargs(i).string_value ()))
         {
@@ -12450,7 +12452,7 @@
           val = xargs(i+1).double_value ();
 
           xargs = xargs.splice (i, 2);
-          break;
+          i -= 2;
         }
     }
 
--- a/scripts/plot/util/__plt_get_axis_arg__.m	Fri Dec 28 22:05:27 2018 -0800
+++ b/scripts/plot/util/__plt_get_axis_arg__.m	Sat Dec 29 22:36:48 2018 -0800
@@ -26,12 +26,12 @@
 function [h, varargin, narg] = __plt_get_axis_arg__ (caller, varargin)
 
   h = [];
-  parent = find (strcmpi (varargin, "parent"), 1);
 
   ## Look for a scalar which is a graphics handle but not the
   ## Root Figure (0) or an ordinary figure (integer).
-  if (numel (varargin) > 0 && numel (varargin{1}) == 1
-      && ishghandle (varargin{1}) && varargin{1} != 0 && ! isfigure (varargin{1}))
+  if (! isempty (varargin) && isscalar (varargin{1})
+      && ishghandle (varargin{1}) && varargin{1} != 0
+      && ! isfigure (varargin{1}))
     htmp = varargin{1};
     if (! isaxes (htmp))
       error ("%s: first argument must be axes handle", caller);
@@ -41,18 +41,22 @@
       varargin(1) = [];
     endif
   ## Look for "parent"/axis prop/value pair
-  elseif (numel (varargin) > 1 && ! isempty (parent))
-    if (parent < numel (varargin) && ishghandle (varargin{parent+1}))
+  elseif (numel (varargin) > 1)
+    ## FIXME: This can be fooled by any string "parent" such as
+    ##        the prop/val pair "tag"/"parent".
+    parent = find (strcmpi (varargin, "parent"), 1, "last");
+    if (! isempty (parent))
+      if (parent == numel (varargin) || ! ishghandle (varargin{parent+1}))
+        error ('%s: "parent" value must be an axes handle', caller);
+      endif
       htmp = varargin{parent+1};
       if (isaxes (htmp) && ! strcmp (get (htmp, "tag"), "legend"))
         h = htmp;
         varargin(parent:parent+1) = [];
       else
-        ## 'parent' property for some other type like hggroup
+        ## "parent" property for some other type like hggroup
         h = [ancestor(htmp, "axes"), htmp];
       endif
-    else
-      error ("%s: parent value must be an axes handle", caller);
     endif
   endif
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/bug-55322/bug-55322.tst	Sat Dec 29 22:36:48 2018 -0800
@@ -0,0 +1,29 @@
+## Copyright (C) 2018 Rik Wehbring
+##
+## This file is part of Octave.
+##
+## Octave is free software: you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## (at your option) any later version.
+##
+## Octave is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Octave; see the file COPYING.  If not, see
+## <https://www.gnu.org/licenses/>.
+
+%!test
+%! hf = figure ("visible", "off");
+%! unwind_protect
+%!   hax = axes ("parent", hf);
+%!   hg = hggroup ();
+%!   hl = line (hax, [0, 1], [1, 1], "parent", hax, "parent", hg);
+%!   assert (get (hax, "children"), hg);
+%!   assert (get (hg, "children"), hl);
+%! unwind_protect_cleanup
+%!   close (hf);
+%! end_unwind_protect
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/bug-55322/module.mk	Sat Dec 29 22:36:48 2018 -0800
@@ -0,0 +1,4 @@
+bug_55322_TEST_FILES = \
+  %reldir%/bug-55322.tst
+
+TEST_FILES += $(bug_55322_TEST_FILES)