git: 0004b136f998 - 2026Q1 - math/wxmaxima: Use wx 3.2, fix connection to maxima

From: Tiago Gasiba <tiga_at_FreeBSD.org>
Date: Sun, 01 Feb 2026 21:37:22 UTC
The branch 2026Q1 has been updated by tiga:

URL: https://cgit.FreeBSD.org/ports/commit/?id=0004b136f99872454cea4a811833a89941018baf

commit 0004b136f99872454cea4a811833a89941018baf
Author:     Tiago Gasiba <tiga@FreeBSD.org>
AuthorDate: 2026-01-31 21:28:58 +0000
Commit:     Tiago Gasiba <tiga@FreeBSD.org>
CommitDate: 2026-02-01 21:35:05 +0000

    math/wxmaxima: Use wx 3.2, fix connection to maxima
    
    - Use wx 3.2
    - Fix connection to maxima by reverting upstream patch:
    https://github.com/wxMaxima-developers/wxmaxima/issues/2028
    
    PR:             289270
    Approved by:    eduardo (mentor)
    MFH:            2026Q1
    
    (cherry picked from commit 200782e2d6db2a12601191d0798110568d386bce)
---
 math/wxmaxima/Makefile                         |  3 +-
 math/wxmaxima/files/patch-src_Dirstructure.cpp |  4 +--
 math/wxmaxima/files/patch-src_Maxima.cpp       | 45 ++++++++++++++++++++++++++
 math/wxmaxima/files/patch-src_Maxima.h         | 28 ++++++++++++++++
 4 files changed, 77 insertions(+), 3 deletions(-)

diff --git a/math/wxmaxima/Makefile b/math/wxmaxima/Makefile
index 6bd3e32bf2b0..ffcf2364ca9f 100644
--- a/math/wxmaxima/Makefile
+++ b/math/wxmaxima/Makefile
@@ -1,6 +1,7 @@
 PORTNAME=	wxmaxima
 DISTVERSIONPREFIX=	Version-
 DISTVERSION=	25.04.0
+PORTREVISION=	1
 PORTEPOCH=	1
 CATEGORIES=	math
 
@@ -17,7 +18,7 @@ USES=		cmake compiler:c++14-lang desktop-file-utils shared-mime-info
 USE_GITHUB=	yes
 GH_ACCOUNT=	wxMaxima-Developers
 
-USE_WX=		3.0
+USE_WX=		3.2
 WX_COMPS=	wx
 WX_CONF_ARGS=	absolute
 
diff --git a/math/wxmaxima/files/patch-src_Dirstructure.cpp b/math/wxmaxima/files/patch-src_Dirstructure.cpp
index 42ab59c742be..aa019c94d05b 100644
--- a/math/wxmaxima/files/patch-src_Dirstructure.cpp
+++ b/math/wxmaxima/files/patch-src_Dirstructure.cpp
@@ -1,6 +1,6 @@
---- src/Dirstructure.cpp.orig	2023-02-19 14:20:34 UTC
+--- src/Dirstructure.cpp.orig	2025-04-27 13:21:48 UTC
 +++ src/Dirstructure.cpp
-@@ -120,6 +120,7 @@ wxString Dirstructure::ResourcesDir() const {
+@@ -121,6 +121,7 @@ wxString Dirstructure::ResourcesDir() {
      exepath = exe.GetPath();
    } else {
      exepath = CMAKE_INSTALL_PREFIX;
diff --git a/math/wxmaxima/files/patch-src_Maxima.cpp b/math/wxmaxima/files/patch-src_Maxima.cpp
new file mode 100644
index 000000000000..9476a615be43
--- /dev/null
+++ b/math/wxmaxima/files/patch-src_Maxima.cpp
@@ -0,0 +1,45 @@
+--- src/Maxima.cpp.orig	2025-10-22 20:06:30 UTC
++++ src/Maxima.cpp
+@@ -115,8 +115,18 @@ Maxima::~Maxima() {
+   wxEvtHandler::DeletePendingEvents();
+ }
+ 
++
++// revert https://github.com/wxMaxima-developers/wxmaxima/commit/5d8dff1564c4d8e0d07e6fdb262b476cad0cb643
++// as per https://github.com/wxMaxima-developers/wxmaxima/issues/2028
++// NOTE: this is temporary solution until wx 3.3.2
+ bool Maxima::Write(const void *buffer, std::size_t length) {
+-  if(!buffer)
++ if (!m_socketOutputData.IsEmpty()) {
++    if (buffer && length)
++      m_socketOutputData.AppendData(buffer, length);
++    buffer = m_socketOutputData.GetData();
++    length = m_socketOutputData.GetDataLen();
++  }
++  if (!length)
+     return false;
+   if (length == 0)
+     return false;
+@@ -125,8 +135,21 @@ bool Maxima::Write(const void *buffer, std::size_t len
+     wxThreadEvent *sendevent = new wxThreadEvent(EVT_MAXIMA);
+     sendevent->SetInt(WRITE_ERROR);
+     QueueEvent(sendevent);
+-    return false;
++    m_socketOutputData.Clear();
++    return true;
+   }
++  auto const wrote = m_socket->LastWriteCount();
++  if (wrote < length) {
++    auto *const source = reinterpret_cast<const char *>(buffer);
++    auto const leftToWrite = length - wrote;
++    if (m_socketOutputData.IsEmpty())
++      m_socketOutputData.AppendData(source + wrote, leftToWrite);
++    else {
++      memmove(m_socketOutputData.GetData(), source + wrote, leftToWrite);
++      m_socketOutputData.SetDataLen(leftToWrite);
++    }
++  } else
++    m_socketOutputData.Clear();
+   return true;
+ }
+ 
diff --git a/math/wxmaxima/files/patch-src_Maxima.h b/math/wxmaxima/files/patch-src_Maxima.h
new file mode 100644
index 000000000000..d6d252c06caf
--- /dev/null
+++ b/math/wxmaxima/files/patch-src_Maxima.h
@@ -0,0 +1,28 @@
+--- src/Maxima.h.orig	2025-10-22 20:10:06 UTC
++++ src/Maxima.h
+@@ -123,6 +123,12 @@ class Maxima : public wxEvtHandler (private)
+ private:
+   //! If this is set to true by XmlInspectorActive we send all data we get to the XML inspector
+   bool m_xmlInspector = false;
++  /*! Send still-unsent data to wxMaxima
++   *
++   *     \todo As we tell wxWidgets to send all data in one go at the end of a write command
++   *         there should no more be unsent data.
++   */
++  void SendDataTowxMaxima();
+   //! The configuration of our wxMaxima process
+   Configuration *m_configuration;
+   //! The thread handler for SendDataTowxMaxima, the thread that parses the data from maxima.
+@@ -152,6 +158,12 @@ class Maxima : public wxEvtHandler (private)
+     waits for the other to exit before writing new data to this variable.
+    */
+   wxString m_socketInputData;
++  /*! Data we didn't manage to send to wxMaxima until now
++   *
++   *     \todo Do we still need this variable? We tell wxWidgets to send all data in
++   *         one go, so there should be no data be left at the end of a write command.
++   */
++  wxMemoryBuffer m_socketOutputData;
+ 
+   //! true = Maxima still has to send us its first prompt
+   bool m_firstPrompt = true;