From 5602e01ff0a6f599b44cfff35251f959b53b5bbb Mon Sep 17 00:00:00 2001
From: Alexander Golubev <fatzer2@gmail.com>
Date: Wed, 20 Aug 2025 10:19:03 +0300
Subject: Fix build WITH_NATIVE_GNU_BARCODE enabled.

I verified that app compiles and starts fine with the GnuBarcode backend
enabled. During runtime no noticeable regressions were spotted.

The whole virtual BarkodeEngine::operator=() thing seems to me like
quite a lousy design, but I don't feel comfortable enough to rework the
code.

Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
---
 ConfigureChecks.cmake    |  5 +++--
 kbarcode/CMakeLists.txt  |  1 +
 kbarcode/barkodeengine.h |  1 +
 kbarcode/gnubarcode.cpp  | 27 +++++++++++++++++++++++++++
 kbarcode/gnubarcode.h    |  1 +
 5 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index cc77191..bbcb85b 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -30,10 +30,11 @@ endif( WITH_GCC_VISIBILITY )
 
 if( WITH_NATIVE_GNU_BARCODE )
     check_include_file( "barcode.h" HAVE_NATIVE_GNU_BARCODE )
-    if( HAVE_NATIVE_GNU_BARCODE )
+    find_library( GNU_BARCODE_LIBRARY barcode )
+    if( HAVE_NATIVE_GNU_BARCODE AND GNU_BARCODE_LIBRARY )
         set( _ENABLE_NATIVE_GNU_BARCODE 1 )
       else()
-        tde_message_fatal( "Barcode is requested, but GNU Barcode header was not found on your system" )
+        tde_message_fatal( "Barcode is requested, but GNU Barcode library was not found on your system" )
     endif()
 endif( WITH_NATIVE_GNU_BARCODE )
 
diff --git a/kbarcode/CMakeLists.txt b/kbarcode/CMakeLists.txt
index be08786..430fc00 100644
--- a/kbarcode/CMakeLists.txt
+++ b/kbarcode/CMakeLists.txt
@@ -61,6 +61,7 @@ tde_add_executable( ${PROJECT_NAME} AUTOMOC
      tdeabc-shared
      ${KJS_LIBRARIES}
      ${PCRE2_LIBRARIES}
+     ${GNU_BARCODE_LIBRARY}
 
   DESTINATION ${BIN_INSTALL_DIR}
 )
diff --git a/kbarcode/barkodeengine.h b/kbarcode/barkodeengine.h
index 0975baf..f3bbc6c 100644
--- a/kbarcode/barkodeengine.h
+++ b/kbarcode/barkodeengine.h
@@ -53,6 +53,7 @@ class BarkodeEngine{
         BarkodeEngine();
         virtual ~BarkodeEngine();
 
+        // FIXME: the operator should rather be called copySettings()
         virtual const BarkodeEngine & operator=( const BarkodeEngine & rhs ) = 0;
 
         virtual EEngine engine() const = 0;
diff --git a/kbarcode/gnubarcode.cpp b/kbarcode/gnubarcode.cpp
index deef484..5767493 100644
--- a/kbarcode/gnubarcode.cpp
+++ b/kbarcode/gnubarcode.cpp
@@ -165,6 +165,33 @@ void GnuBarcode::setupSize()
     m_size.setHeight( (int)(m_item->height * m_scaley) );
 }
 
+const BarkodeEngine &GnuBarcode::operator=( const BarkodeEngine & rhs )
+{
+    const GnuBarcode* gb = dynamic_cast<const GnuBarcode*>(&rhs);
+
+    if( gb )
+    {
+        m_bar_height     = gb->m_bar_height;
+        m_barcode_height = gb->m_barcode_height;
+        m_font_size      = gb->m_font_size;
+
+        m_scalex         = gb->m_scalex;
+        m_scaley         = gb->m_scaley;
+        m_scale_ps_x     = gb->m_scale_ps_x;
+        m_scale_ps_y     = gb->m_scale_ps_y;
+        m_size           = gb->m_size;
+
+        if( m_item )
+        {
+            tqDebug("GnuBarcode::operator=() : deleting internal barcode item");
+            Barcode_Delete( m_item );
+            m_item = NULL;
+        }
+    }
+
+    return *this;
+}
+
 int GnuBarcode::drawBars( TQPainter* painter, int x, int y )
 {
 #if 0
diff --git a/kbarcode/gnubarcode.h b/kbarcode/gnubarcode.h
index 1f71e79..1f66912 100644
--- a/kbarcode/gnubarcode.h
+++ b/kbarcode/gnubarcode.h
@@ -41,6 +41,7 @@ class GnuBarcode : public BarkodeEngine {
     void update( const TQPaintDevice* device );
     void drawBarcode( TQPainter & painter, int x, int y );
 
+    const BarkodeEngine & operator=( const BarkodeEngine & rhs );
  private:
     /** Draws the barcodes bars if @p painter is not 0.
       * Otherwise only the required width is returned.
-- 
cgit v1.2.3

