changeset 28396:4ea54a38c500

maint: merge stable to default
author Pantxo Diribarne <pantxo.diribarne@gmail.com>
date Tue, 02 Jun 2020 14:57:56 +0200
parents 5147fbf58fa6 (current diff) a379987a74b0 (diff)
children 37c5532e558c
files doc/interpreter/genpropdoc.m
diffstat 4 files changed, 33 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/doc/interpreter/genpropdoc.m	Mon Jun 01 15:08:18 2020 -0700
+++ b/doc/interpreter/genpropdoc.m	Tue Jun 02 14:57:56 2020 +0200
@@ -125,7 +125,11 @@
   doc_fontname = "Name of font used for text rendering.  When setting \
 this property, the text rendering engine will search for a matching \
 font in your system.  If none is found then text is rendered using a \
-default sans serif font (same as the default @qcode{\"*\"} value).";
+default sans serif font (same as the default @qcode{\"*\"} value).\n\n\
+Programming Note: On systems that don’t use FontConfig natively \
+(all but Linux), the font cache is built when Octave is installed.  \
+You will need to run @code{system (\"fc-cache -fv\")} manually after \
+installing new fonts.";
   doc_fontunits = "Units used to interpret the @qcode{\"fontsize\"} property.";
   doc_fontweight = "Control the variant of the base font used for \
 text rendering.";
--- a/libgui/graphics/ObjectProxy.cc	Mon Jun 01 15:08:18 2020 -0700
+++ b/libgui/graphics/ObjectProxy.cc	Tue Jun 02 14:57:56 2020 +0200
@@ -55,14 +55,10 @@
           {
             disconnect (this, SIGNAL (sendUpdate (int)),
                         m_object, SLOT (slotUpdate (int)));
-            disconnect (this, SIGNAL (sendFinalize (void)),
-                        m_object, SLOT (slotFinalize (void)));
             disconnect (this, SIGNAL (sendRedraw (void)),
                         m_object, SLOT (slotRedraw (void)));
             disconnect (this, SIGNAL (sendShow (void)),
                         m_object, SLOT (slotShow (void)));
-            disconnect (this, SIGNAL (sendPrint (const QString&, const QString&)),
-                        m_object, SLOT (slotPrint (const QString&, const QString&)));
           }
 
         m_object = obj;
@@ -71,15 +67,10 @@
           {
             connect (this, SIGNAL (sendUpdate (int)),
                      m_object, SLOT (slotUpdate (int)));
-            connect (this, SIGNAL (sendFinalize (void)),
-                     m_object, SLOT (slotFinalize (void)));
             connect (this, SIGNAL (sendRedraw (void)),
                      m_object, SLOT (slotRedraw (void)));
             connect (this, SIGNAL (sendShow (void)),
                      m_object, SLOT (slotShow (void)));
-            connect (this, SIGNAL (sendPrint (const QString&, const QString&)),
-                     m_object, SLOT (slotPrint (const QString&, const QString&)),
-                     Qt::BlockingQueuedConnection);
           }
       }
   }
@@ -87,7 +78,10 @@
   void
   ObjectProxy::setObject (Object *obj)
   {
-    finalize ();
+    // Eventually destroy previous Object
+    if (m_object)
+      finalize ();
+
     init (obj);
   }
 
@@ -101,14 +95,15 @@
   ObjectProxy::finalize (void)
   {
     if (! m_object)
-      return;
+      error ("ObjectProxy::finalize: invalid GUI Object");
 
     Qt::ConnectionType t = Qt::BlockingQueuedConnection;
 
     if (QThread::currentThread () == QCoreApplication::instance ()->thread ())
       t = Qt::DirectConnection;
 
-    QMetaObject::invokeMethod (m_object, "slotFinalize", t);
+    if (! QMetaObject::invokeMethod (m_object, "slotFinalize", t))
+      error ("ObjectProxy::finalize: unable to delete GUI Object");
   }
 
   void
@@ -126,12 +121,26 @@
   void
   ObjectProxy::print (const QString& file_cmd, const QString& term)
   {
-    emit sendPrint (file_cmd, term);
+    if (! m_object)
+      error ("ObjectProxy::print: invalid GUI Object");
+
+    Qt::ConnectionType t = Qt::BlockingQueuedConnection;
+
+    if (QThread::currentThread () == QCoreApplication::instance ()->thread ())
+      t = Qt::DirectConnection;
+
+    if (! QMetaObject::invokeMethod (m_object, "slotPrint", t,
+                                     Q_ARG (QString, file_cmd),
+                                     Q_ARG (QString, term)))
+      error ("ObjectProxy::print: unable to print figure");
   }
 
   uint8NDArray
   ObjectProxy::get_pixels (void)
   {
+    if (! m_object)
+      error ("ObjectProxy::finalize: invalid GUI Object");
+
     uint8NDArray retval;
 
     // The ObjectProxy is generally ran from the interpreter thread
--- a/libgui/graphics/ObjectProxy.h	Mon Jun 01 15:08:18 2020 -0700
+++ b/libgui/graphics/ObjectProxy.h	Tue Jun 02 14:57:56 2020 +0200
@@ -56,10 +56,8 @@
 
   signals:
     void sendUpdate (int pId);
-    void sendFinalize (void);
     void sendRedraw (void);
     void sendShow (void);
-    void sendPrint (const QString& file_cmd, const QString& term);
 
   private:
     void init (Object *obj);
--- a/libgui/graphics/qt-graphics-toolkit.cc	Mon Jun 01 15:08:18 2020 -0700
+++ b/libgui/graphics/qt-graphics-toolkit.cc	Tue Jun 02 14:57:56 2020 +0200
@@ -107,9 +107,14 @@
     // cross from the interpreter thread (where requests to create
     // graphics object are initiated) to the GUI application thread
     // (where they are actually created and displayed).
+    // We need to make sure the GUI Object and its proxy are properly
+    // created before the initialize method returns, so we use a
+    // BlockingQueuedConnection. After the signal is emitted, the interpreter
+    // thread is locked until the slot has returned.
 
     connect (this, SIGNAL (create_object_signal (double)),
-             this, SLOT (create_object (double)));
+             this, SLOT (create_object (double)),
+             Qt::BlockingQueuedConnection);
   }
 
   bool