From 0e079a7ebe02cc8736752b71d468e11cb9aed5ef Mon Sep 17 00:00:00 2001
From: James Turner <james@flightgear.org>
Date: Wed, 9 Mar 2022 16:46:13 +0000
Subject: [PATCH] More #ifdefs around PUI in the UI code

---
 src/GUI/gui.cxx     | 28 +++++++++++++++++++---------
 src/GUI/new_gui.cxx | 12 +++++++-----
 2 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/src/GUI/gui.cxx b/src/GUI/gui.cxx
index d0f5699d1..e99ca3266 100644
--- a/src/GUI/gui.cxx
+++ b/src/GUI/gui.cxx
@@ -24,9 +24,7 @@
  **************************************************************************/
 
 
-#ifdef HAVE_CONFIG_H
-#  include <config.h>
-#endif
+#include <config.h>
 
 #include <simgear/compiler.h>
 
@@ -57,21 +55,27 @@
 
 using namespace flightgear;
 
+#if defined(HAVE_PUI)
+
 puFont guiFnt = 0;
 
 // this is declared in puLocal.h, re-declare here so we can call it ourselves
 void puSetPasteBuffer  ( const char *ch ) ;
 
+#endif
+
 /* -------------------------------------------------------------------------
 init the gui
 _____________________________________________________________________*/
 
 namespace
 {
-class GUIInitOperation : public GraphicsContextOperation
+
+#if defined(HAVE_PUI)
+class PUIInitOperation : public GraphicsContextOperation
 {
 public:
-    GUIInitOperation() : GraphicsContextOperation(std::string("GUI init"))
+    PUIInitOperation() : GraphicsContextOperation(std::string("GUI init"))
     {
     }
     void run(osg::GraphicsContext* gc)
@@ -110,6 +114,10 @@ public:
     }
 };
 
+osg::ref_ptr<PUIInitOperation> initOp;
+
+#endif
+
 // Operation for querying OpenGL parameters. This must be done in a
 // valid OpenGL context, potentially in another thread.
 
@@ -160,8 +168,6 @@ struct GeneralInitOperation : public GraphicsContextOperation
     }
 };
 
-osg::ref_ptr<GUIInitOperation> initOp;
-
 }
 
 /** Initializes GUI.
@@ -183,8 +189,10 @@ bool guiInit()
             gc = guiCamera->getGraphicsContext();
         if (gc) {
             gc->add(genOp.get());
-            initOp = new GUIInitOperation;
+#if defined(HAVE_PUI)
+            initOp = new PUIInitOperation;
             gc->add(initOp.get());
+#endif
         } else {
             wsa->windows[0]->gc->add(genOp.get());
         }
@@ -194,12 +202,14 @@ bool guiInit()
     {
         if (!genOp->isFinished())
             return false;
+#if defined(HAVE_PUI)
         if (!initOp.valid())
             return true;
         if (!initOp->isFinished())
             return false;
-        genOp = 0;
         initOp = 0;
+#endif
+        genOp = 0;
         // we're done
         return true;
     }
diff --git a/src/GUI/new_gui.cxx b/src/GUI/new_gui.cxx
index 24633678e..9047eb707 100644
--- a/src/GUI/new_gui.cxx
+++ b/src/GUI/new_gui.cxx
@@ -1,8 +1,6 @@
 // new_gui.cxx: implementation of XML-configurable GUI support.
 
-#ifdef HAVE_CONFIG_H
-#  include <config.h>
-#endif
+#include <config.h>
 
 #include "new_gui.hxx"
 
@@ -36,6 +34,10 @@
 #include "FGWindowsMenuBar.hxx"
 #endif
 
+#if defined(HAVE_PUI)
+    #include <plib/puAux.h>
+#endif
+
 #if defined(ENABLE_PUICOMPAT)
 #include "FGPUICompatDialog.hxx"
 #include "PUICompatObject.hxx"
@@ -595,7 +597,7 @@ NewGUI::setStyle (void)
     }
 
     FGColor *c = _colors["background"];
-#if !defined(ENABLE_PUICOMPAT)
+#if defined(HAVE_PUI)
     puSetDefaultColourScheme(c->red(), c->green(), c->blue(), c->alpha());
 #endif
 }
@@ -604,7 +606,7 @@ NewGUI::setStyle (void)
 void
 NewGUI::setupFont (SGPropertyNode *node)
 {
-#if !defined(ENABLE_PUICOMPAT)
+#if defined(HAVE_PUI)
     _font = FGFontCache::instance()->get(node);
     puSetDefaultFonts(*_font, *_font);
 #endif