From cf2c079499083ff21a25c5bc83218b2250019c03 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Anthony=20L=C3=A9onard?=
 <anthony.leonard@savoirfairelinux.com>
Date: Thu, 24 Aug 2017 16:12:14 -0400
Subject: [PATCH] fix LIB_EXPORT behavior and misuse

This patch fixes DLL symbols export and especially imports from LRC.
When included in Windows client, classes were not using Q_DECL_IMPORT
which, on this platform, specify that symbols are imported from a lib.

A consequence of that is that Qt connects with the new syntax were
failing thus forcing us to rely on old-style ones. Those ones are not
checked at compile time and not compatibles with lambdas.

It may also fix other issues related to symbols availability and
uniqueness.

several incorrect LIB_EXPORT are also removed as they were used in template
declarations, or internal classes for LRC.

Change-Id: I2578deca5215a7e17327405ae6462c373b229ada
---
 src/collectionmanagerinterface.h | 1 -
 src/collectionmediator.h         | 3 +--
 src/dbuserrorhandlerdefault.h    | 2 +-
 src/globalinstances.h            | 4 ++--
 src/itembase.h                   | 1 -
 src/typedefs.h                   | 5 ++++-
 6 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/collectionmanagerinterface.h b/src/collectionmanagerinterface.h
index 0bc97a55..8f1ddc00 100644
--- a/src/collectionmanagerinterface.h
+++ b/src/collectionmanagerinterface.h
@@ -199,4 +199,3 @@ private:
 };
 
 #include "collectionmanagerinterface.hpp"
-
diff --git a/src/collectionmediator.h b/src/collectionmediator.h
index e43aa9fc..de8df502 100644
--- a/src/collectionmediator.h
+++ b/src/collectionmediator.h
@@ -36,7 +36,7 @@ class CollectionMediatorPrivate;
  * The later objective make it easier to later implement the decorator pattern.
  */
 template<typename T>
-class LIB_EXPORT CollectionMediator {
+class CollectionMediator {
 public:
    CollectionMediator(CollectionManagerInterface<T>* parentManager, QAbstractItemModel* m);
    virtual ~CollectionMediator();
@@ -50,4 +50,3 @@ private:
 };
 
 #include <collectionmediator.hpp>
-
diff --git a/src/dbuserrorhandlerdefault.h b/src/dbuserrorhandlerdefault.h
index 439503c8..2b233d3d 100644
--- a/src/dbuserrorhandlerdefault.h
+++ b/src/dbuserrorhandlerdefault.h
@@ -26,7 +26,7 @@ namespace Interfaces {
 /**
  * This implementation of the DBusErrorHandler interface throws an exception with the given message.
  */
-class LIB_EXPORT DBusErrorHandlerDefault : public DBusErrorHandlerI {
+class DBusErrorHandlerDefault : public DBusErrorHandlerI {
 public:
     [[noreturn]] void connectionError(const QString& error) override;
     [[noreturn]] void invalidInterfaceError(const QString& error) override;
diff --git a/src/globalinstances.h b/src/globalinstances.h
index 83b727ad..efd94f7c 100644
--- a/src/globalinstances.h
+++ b/src/globalinstances.h
@@ -52,7 +52,7 @@ void LIB_EXPORT setAccountListColorizer(std::unique_ptr<Interfaces::AccountListC
 LIB_EXPORT Interfaces::ContactMethodSelectorI& contactMethodSelector();
 void LIB_EXPORT setContactMethodSelector(std::unique_ptr<Interfaces::ContactMethodSelectorI> instance);
 
-LIB_EXPORT Interfaces::DBusErrorHandlerI& dBusErrorHandler();
+Interfaces::DBusErrorHandlerI& dBusErrorHandler();
 void setDBusErrorHandler(std::unique_ptr<Interfaces::DBusErrorHandlerI> instance);
 
 /**
@@ -96,7 +96,7 @@ void setInterfaceInternal(Interfaces::ActionExtenderI          *);
  * can be passed.
  */
 template<class I, typename ...Ts>
-void LIB_EXPORT setInterface(Ts... args)
+void setInterface(Ts... args)
 {
    try {
       auto i = new I(args...);
diff --git a/src/itembase.h b/src/itembase.h
index cb1c7729..cc6e92b2 100644
--- a/src/itembase.h
+++ b/src/itembase.h
@@ -58,4 +58,3 @@ private:
 };
 
 #include <itembase.hpp>
-
diff --git a/src/typedefs.h b/src/typedefs.h
index d7067d3b..59f73425 100644
--- a/src/typedefs.h
+++ b/src/typedefs.h
@@ -47,8 +47,11 @@ template<typename A> constexpr int enum_class_size() {
    return static_cast<int>(A::COUNT__);
 }
 
+#ifdef LRC_IMPORT
+#define LIB_EXPORT Q_DECL_IMPORT
+#else
 #define LIB_EXPORT Q_DECL_EXPORT
-#define LIB_IMPORT Q_DECL_IMPORT
+#endif
 
 //Doesn't work
 #if ((__GNUC_MINOR__ > 8) || (__GNUC_MINOR__ == 8))
-- 
GitLab