[mapguide-commits] r10216 - in branches/4.0/MgDev: Common/Renderers Oem/DWFTK/develop/global/src/dwf Oem/DWFTK/develop/global/src/dwf/whiptk Server/src/UnitTesting

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Mon Sep 21 05:39:48 PDT 2026


Author: jng
Date: 2026-09-21 05:39:45 -0700 (Mon, 21 Sep 2026)
New Revision: 10216

Modified:
   branches/4.0/MgDev/Common/Renderers/AGGRenderer.cpp
   branches/4.0/MgDev/Common/Renderers/AGGRenderer.h
   branches/4.0/MgDev/Common/Renderers/DWFRenderer.cpp
   branches/4.0/MgDev/Common/Renderers/DWFRenderer.h
   branches/4.0/MgDev/Oem/DWFTK/develop/global/src/dwf/CMakeLists.txt
   branches/4.0/MgDev/Oem/DWFTK/develop/global/src/dwf/whiptk/color.cpp
   branches/4.0/MgDev/Oem/DWFTK/develop/global/src/dwf/whiptk/ellipse.cpp
   branches/4.0/MgDev/Oem/DWFTK/develop/global/src/dwf/whiptk/plotinfo.cpp
   branches/4.0/MgDev/Oem/DWFTK/develop/global/src/dwf/whiptk/plotinfo.h
   branches/4.0/MgDev/Oem/DWFTK/develop/global/src/dwf/whiptk/transform.h
   branches/4.0/MgDev/Oem/DWFTK/develop/global/src/dwf/whiptk/typedefs_defines.h
   branches/4.0/MgDev/Oem/DWFTK/develop/global/src/dwf/whiptk/usrhatchpat.cpp
   branches/4.0/MgDev/Server/src/UnitTesting/TestDrawingService.cpp
Log:
Fix MgDrawingService::EnumerateLayers() returning an empty list on Linux

Like our initial woes porting MapGuide to 64-bit Linux, the issue ultimately was incorrect typedefs on fundamental integral types in DWF Toolkit that caused the reading of DWF content to mis-behave due to these incorrect typedefs.

Our long-disabled test case for this API has been re-activated as proof this API is now working as advertised.

Fixes #2500

Modified: branches/4.0/MgDev/Common/Renderers/AGGRenderer.cpp
===================================================================
--- branches/4.0/MgDev/Common/Renderers/AGGRenderer.cpp	2026-09-13 09:13:38 UTC (rev 10215)
+++ branches/4.0/MgDev/Common/Renderers/AGGRenderer.cpp	2026-09-21 12:39:45 UTC (rev 10216)
@@ -3159,7 +3159,7 @@
 // of the destination DWF or be much larger, we need to take that scaling
 // into account when carrying over things like line weight, font height,
 // etc.  This helper function determines and applies that scale.
-double AGGRenderer::ScaleW2DNumber(WT_File& file, WT_Integer32 number)
+double AGGRenderer::ScaleW2DNumber(WT_File& file, int number)
 {
     WT_Matrix xform = file.desired_rendition().drawing_info().units().dwf_to_application_adjoint_transform();
 

Modified: branches/4.0/MgDev/Common/Renderers/AGGRenderer.h
===================================================================
--- branches/4.0/MgDev/Common/Renderers/AGGRenderer.h	2026-09-13 09:13:38 UTC (rev 10215)
+++ branches/4.0/MgDev/Common/Renderers/AGGRenderer.h	2026-09-21 12:39:45 UTC (rev 10216)
@@ -338,7 +338,7 @@
                                                               WT_Logical_Point* srcpts,
                                                               int               numpts,
                                                               bool              checkInBounds);
-    /*Do not export from DLL*/ double ScaleW2DNumber(WT_File& file, long number);
+    /*Do not export from DLL*/ double ScaleW2DNumber(WT_File& file, int number);
 
 private:
     void AddW2DContent(RS_InputStream* in, CSysTransformer* xformer, const RS_String& w2dfilter);

Modified: branches/4.0/MgDev/Common/Renderers/DWFRenderer.cpp
===================================================================
--- branches/4.0/MgDev/Common/Renderers/DWFRenderer.cpp	2026-09-13 09:13:38 UTC (rev 10215)
+++ branches/4.0/MgDev/Common/Renderers/DWFRenderer.cpp	2026-09-21 12:39:45 UTC (rev 10216)
@@ -3636,7 +3636,7 @@
 //scaling into account when carrying over things like line weight,
 //font height, etc. this helper funtion determines and applies
 //that scale
-WT_Integer32 DWFRenderer::ScaleW2DNumber(WT_File& file, WT_Integer32 number)
+int DWFRenderer::ScaleW2DNumber(WT_File& file, int number)
 {
     WT_Matrix xform = file.desired_rendition().drawing_info().units().dwf_to_application_adjoint_transform();
 
@@ -3662,7 +3662,7 @@
         dDstSpace *= m_scale;
     }
 
-    return (WT_Integer32)dDstSpace;
+    return (int)dDstSpace;
 }
 
 

Modified: branches/4.0/MgDev/Common/Renderers/DWFRenderer.h
===================================================================
--- branches/4.0/MgDev/Common/Renderers/DWFRenderer.h	2026-09-13 09:13:38 UTC (rev 10215)
+++ branches/4.0/MgDev/Common/Renderers/DWFRenderer.h	2026-09-21 12:39:45 UTC (rev 10216)
@@ -384,8 +384,8 @@
                                                                            int                  numpts
                                                                          );
 
-    /*Do not export from DLL*/  long ScaleW2DNumber(WT_File& file,
-                                                    long     number);
+    /*Do not export from DLL*/  int ScaleW2DNumber(WT_File& file,
+                                                    int      number);
 
     /*Do not export from DLL*/  void UpdateSymbolTrans(WT_File& file, WT_Viewport& viewport);
 

Modified: branches/4.0/MgDev/Oem/DWFTK/develop/global/src/dwf/CMakeLists.txt
===================================================================
--- branches/4.0/MgDev/Oem/DWFTK/develop/global/src/dwf/CMakeLists.txt	2026-09-13 09:13:38 UTC (rev 10215)
+++ branches/4.0/MgDev/Oem/DWFTK/develop/global/src/dwf/CMakeLists.txt	2026-09-21 12:39:45 UTC (rev 10216)
@@ -1,6 +1,33 @@
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}
     ${CMAKE_CURRENT_SOURCE_DIR}/..)
 
+# Sanity-check the whiptk fundamental type sizes at configure time.
+# The W2D binary parser reads and writes 32-bit fields using WT_Integer32 /
+# WT_Unsigned_Integer32. If those are not exactly 4 bytes the parser silently
+# desynchronizes (e.g. `long` is 8 bytes on 64-bit Linux), producing empty or
+# corrupted drawing results. Fail the build early rather than at runtime.
+include(CheckCXXSourceCompiles)
+
+set(CMAKE_REQUIRED_INCLUDES
+    ${CMAKE_CURRENT_SOURCE_DIR}
+    ${CMAKE_CURRENT_SOURCE_DIR}/..)
+
+check_cxx_source_compiles(
+    "#include \"whiptk/typedefs_defines.h\"
+     typedef char DWFTK_WT_INT32_MUST_BE_4_BYTES[(sizeof(WT_Integer32) == 4) ? 1 : -1];
+     typedef char DWFTK_WT_UINT32_MUST_BE_4_BYTES[(sizeof(WT_Unsigned_Integer32) == 4) ? 1 : -1];
+     typedef char DWFTK_WT_INT16_MUST_BE_2_BYTES[(sizeof(WT_Integer16) == 2) ? 1 : -1];
+     typedef char DWFTK_WT_UINT16_MUST_BE_2_BYTES[(sizeof(WT_Unsigned_Integer16) == 2) ? 1 : -1];
+     typedef char DWFTK_WT_BYTE_MUST_BE_1_BYTE[(sizeof(WT_Byte) == 1) ? 1 : -1];
+     int main() { return 0; }"
+    DWFTK_WT_TYPES_HAVE_EXPECTED_SIZES)
+
+unset(CMAKE_REQUIRED_INCLUDES)
+
+if(NOT DWFTK_WT_TYPES_HAVE_EXPECTED_SIZES)
+    message(FATAL_ERROR "DWFTK whiptk fundamental types have unexpected sizes. WT_Integer32/WT_Unsigned_Integer32 must be exactly 4 bytes; see whiptk/typedefs_defines.h")
+endif()
+
 set (dwftk_SRCS
     Toolkit.cpp
     #dwfx

Modified: branches/4.0/MgDev/Oem/DWFTK/develop/global/src/dwf/whiptk/color.cpp
===================================================================
--- branches/4.0/MgDev/Oem/DWFTK/develop/global/src/dwf/whiptk/color.cpp	2026-09-13 09:13:38 UTC (rev 10215)
+++ branches/4.0/MgDev/Oem/DWFTK/develop/global/src/dwf/whiptk/color.cpp	2026-09-21 12:39:45 UTC (rev 10216)
@@ -43,7 +43,7 @@
 {
     // calc heidi color
     // cube index
-    long lr,lg,lb;
+    WT_Integer32 lr,lg,lb;
     short sr,sg,sb;
     lr = ( rgba.m_rgb.r * 6 ) << 8;
     lg = ( rgba.m_rgb.g * 6 ) << 8;

Modified: branches/4.0/MgDev/Oem/DWFTK/develop/global/src/dwf/whiptk/ellipse.cpp
===================================================================
--- branches/4.0/MgDev/Oem/DWFTK/develop/global/src/dwf/whiptk/ellipse.cpp	2026-09-13 09:13:38 UTC (rev 10215)
+++ branches/4.0/MgDev/Oem/DWFTK/develop/global/src/dwf/whiptk/ellipse.cpp	2026-09-21 12:39:45 UTC (rev 10216)
@@ -214,8 +214,8 @@
         else
         {
             // merge any ellipse tilt into the circle angles
-            long    start = ((long)m_start + (long)m_tilt) & 0x0000FFFF;
-            long    end   = ((long)m_end   + (long)m_tilt) & 0x0000FFFF;
+            WT_Integer32    start = ((WT_Integer32)m_start + (WT_Integer32)m_tilt) & 0x0000FFFF;
+            WT_Integer32    end   = ((WT_Integer32)m_end   + (WT_Integer32)m_tilt) & 0x0000FFFF;
 
             // Output a circle in ASCII
             if (start != end)

Modified: branches/4.0/MgDev/Oem/DWFTK/develop/global/src/dwf/whiptk/plotinfo.cpp
===================================================================
--- branches/4.0/MgDev/Oem/DWFTK/develop/global/src/dwf/whiptk/plotinfo.cpp	2026-09-13 09:13:38 UTC (rev 10215)
+++ branches/4.0/MgDev/Oem/DWFTK/develop/global/src/dwf/whiptk/plotinfo.cpp	2026-09-21 12:39:45 UTC (rev 10216)
@@ -132,7 +132,7 @@
             else
             {
                 WD_CHECK( file.read_ascii(m_rotation) );
-                m_rotation = ((long)((m_rotation / 90.0) + 0.5)) * 90; // Only allow 90 degree rotations in this release
+                m_rotation = ((WT_Integer32)((m_rotation / 90.0) + 0.5)) * 90; // Only allow 90 degree rotations in this release
             }
         }
         m_stage = Getting_Units_String;

Modified: branches/4.0/MgDev/Oem/DWFTK/develop/global/src/dwf/whiptk/plotinfo.h
===================================================================
--- branches/4.0/MgDev/Oem/DWFTK/develop/global/src/dwf/whiptk/plotinfo.h	2026-09-13 09:13:38 UTC (rev 10215)
+++ branches/4.0/MgDev/Oem/DWFTK/develop/global/src/dwf/whiptk/plotinfo.h	2026-09-21 12:39:45 UTC (rev 10216)
@@ -59,7 +59,7 @@
     WT_Paper_Units  m_units;
     WT_Boolean      m_show;
     WT_String       m_temp_string;
-    long            m_rotation;
+    WT_Integer32    m_rotation;
 
     enum WT_Materialize_Stage
     {   Eating_Initial_Whitespace,
@@ -117,9 +117,9 @@
     /// Returns the paper width (in paper units.)
     inline const double&         paper_width()         const { return m_width; }
     /// Returns a writable accessor to the rotation angle (in degrees, one of 0, 90, 180, 270.)
-    inline const long&           rotation()              const { return m_rotation; }
+    inline const WT_Integer32&   rotation()              const { return m_rotation; }
     /// Returns a the pre-applied rotation angle (in degrees, one of 0, 90, 180, 270, typically portrait==0 or landscape==90.)
-    inline long&                 rotation()        { return m_rotation; }
+    inline WT_Integer32&         rotation()        { return m_rotation; }
     /// Returns a writable accessor to the 3x3 matrix which facilitates transforming DWF coordinate space to paper coordinate space.
     inline WT_Matrix2D&          to_paper()       { return m_dwf2paper; }
     /// Returns the 3x3 matrix which facilitates transforming DWF coordinate space to paper coordinate space.

Modified: branches/4.0/MgDev/Oem/DWFTK/develop/global/src/dwf/whiptk/transform.h
===================================================================
--- branches/4.0/MgDev/Oem/DWFTK/develop/global/src/dwf/whiptk/transform.h	2026-09-13 09:13:38 UTC (rev 10215)
+++ branches/4.0/MgDev/Oem/DWFTK/develop/global/src/dwf/whiptk/transform.h	2026-09-21 12:39:45 UTC (rev 10216)
@@ -32,7 +32,7 @@
     WT_Logical_Point    m_translate; /**< \brief Translation vector. */
     double              m_x_scale; /**< \brief X scale factor. */
     double              m_y_scale; /**< \brief Y scale factor. */
-    long                m_rotation; /**< \brief Rotation (in degrees, one of 0, 90, 180, 270). */
+    WT_Integer32        m_rotation; /**< \brief Rotation (in degrees, one of 0, 90, 180, 270). */
 
     /// Constructs a WT_Transform object.
     WT_Transform()
@@ -66,13 +66,13 @@
         double rotation /**< Rotation (in degrees, one of 0, 90, 180, 270). */
         )
     {
-        switch ((long)rotation)
+        switch ((WT_Integer32)rotation)
         {
             case 0:
             case 90:
             case 180:
             case 270:
-                m_rotation = (long)rotation;
+                m_rotation = (WT_Integer32)rotation;
                 break;
             default:
                 m_rotation = 0;
@@ -81,7 +81,7 @@
     }
 
     /// Returns the rotation value (in degrees, one of 0, 90, 180, 270).
-    long rotation() const
+    WT_Integer32 rotation() const
     {   return m_rotation;    }
 };
 

Modified: branches/4.0/MgDev/Oem/DWFTK/develop/global/src/dwf/whiptk/typedefs_defines.h
===================================================================
--- branches/4.0/MgDev/Oem/DWFTK/develop/global/src/dwf/whiptk/typedefs_defines.h	2026-09-13 09:13:38 UTC (rev 10215)
+++ branches/4.0/MgDev/Oem/DWFTK/develop/global/src/dwf/whiptk/typedefs_defines.h	2026-09-21 12:39:45 UTC (rev 10216)
@@ -29,19 +29,33 @@
 /// \brief Simple boolean.
 typedef char WT_Boolean;
 
+// The W2D binary format stores 32-bit integers as exactly 4 bytes.
+// On Windows `long` is 4 bytes, but on 64-bit Linux (LP64) `long` is
+// 8 bytes, which silently desynchronizes the W2D parser. Keep the
+// original Windows typedefs and use fixed 4-byte types elsewhere.
+#if defined(_WIN32)
 /// \typedef typedef long WT_Integer32
 /// \brief 32-bit signed integer.
 typedef long WT_Integer32;
 
-/// \typedef typedef long WT_Integer16
-/// \brief 16-bit signed integer.
-typedef short WT_Integer16;
-
 /// \typedef typedef unsigned long WT_Unsigned_Integer32
 /// \brief 32-bit unsigned integer.
 typedef unsigned long WT_Unsigned_Integer32;
+#else
+/// \typedef typedef int WT_Integer32
+/// \brief 32-bit signed integer.
+typedef int WT_Integer32;
 
-/// \typedef typedef unsigned long WT_Unsigned_Integer16
+/// \typedef typedef unsigned int WT_Unsigned_Integer32
+/// \brief 32-bit unsigned integer.
+typedef unsigned int WT_Unsigned_Integer32;
+#endif
+
+/// \typedef typedef short WT_Integer16
+/// \brief 16-bit signed integer.
+typedef short WT_Integer16;
+
+/// \typedef typedef unsigned short WT_Unsigned_Integer16
 /// \brief 16-bit unsigned integer.
 typedef unsigned short WT_Unsigned_Integer16;
 

Modified: branches/4.0/MgDev/Oem/DWFTK/develop/global/src/dwf/whiptk/usrhatchpat.cpp
===================================================================
--- branches/4.0/MgDev/Oem/DWFTK/develop/global/src/dwf/whiptk/usrhatchpat.cpp	2026-09-13 09:13:38 UTC (rev 10215)
+++ branches/4.0/MgDev/Oem/DWFTK/develop/global/src/dwf/whiptk/usrhatchpat.cpp	2026-09-21 12:39:45 UTC (rev 10216)
@@ -18,7 +18,7 @@
 
 #include "whiptk/pch.h"
  
-#define DOUBLE_TO_LONG_BIT_SHIFT_16(x)    (long) ((float)x * 65536)
+#define DOUBLE_TO_LONG_BIT_SHIFT_16(x)    (WT_Integer32) ((float)x * 65536)
 #define LONG_TO_DOUBLE_BIT_SHIFT_16(x) (double) ((double)x * 0.0000152587890625) 
 /////////////////////////////////////////////////////////////////////////// 
 WT_User_Hatch_Pattern::WT_User_Hatch_Pattern(WT_User_Hatch_Pattern const & pattern)

Modified: branches/4.0/MgDev/Server/src/UnitTesting/TestDrawingService.cpp
===================================================================
--- branches/4.0/MgDev/Server/src/UnitTesting/TestDrawingService.cpp	2026-09-13 09:13:38 UTC (rev 10215)
+++ branches/4.0/MgDev/Server/src/UnitTesting/TestDrawingService.cpp	2026-09-21 12:39:45 UTC (rev 10216)
@@ -109,11 +109,7 @@
     }
 }
 
-#ifdef _WIN32
 TEST_CASE("EnumerateLayers", "[DrawingService]")
-#else
-TEST_CASE("EnumerateLayers", "[Broken]")
-#endif
 {
     try
     {



More information about the mapguide-commits mailing list