Base: Observer - fix template instantiation

===========================================

Merit goes to Werner for figuring out the issue and proposing a MSVC/MSYS2 viable solution:
https://github.com/FreeCAD/FreeCAD/pull/8781#issuecomment-1464898566
This commit is contained in:
Abdullah Tahiri
2023-03-11 06:28:21 +01:00
committed by abdullahtahiriyo
parent 77dc9bba1b
commit 63f3bdaf77
4 changed files with 45 additions and 8 deletions

View File

@@ -231,6 +231,7 @@ SET(FreeCADBase_CPP_SRCS
MatrixPyImp.cpp
MemDebug.cpp
Mutex.cpp
Observer.cpp
Parameter.xsd
Parameter.cpp
ParameterPy.cpp

34
src/Base/Observer.cpp Normal file
View File

@@ -0,0 +1,34 @@
/***************************************************************************
* Copyright (c) 2023 Abdullah Tahiri <abdullah.tahiri.yo@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Library General Public License (LGPL) *
* as published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* for detail see the LICENCE text file. *
* *
* FreeCAD is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with FreeCAD; if not, write to the Free Software *
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
* USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#include "Observer.h"
namespace Base {
template class BaseExport Observer<const char*>;
template class BaseExport Subject<const char*>;
} //namespace Base

View File

@@ -216,16 +216,17 @@ protected:
std::set<Observer <_MessageType> *> _ObserverSet;
};
#if defined (FC_OS_WIN32) || defined(FC_OS_CYGWIN)
# ifdef FCBase
template class BaseExport Observer<const char*>;
template class BaseExport Subject<const char*>;
# else
extern template class BaseExport Observer<const char*>;
extern template class BaseExport Subject<const char*>;
# endif
// Workaround for MSVC
#ifdef FreeCADBase_EXPORTS
# define Base_EXPORT
#else
# define Base_EXPORT BaseExport
#endif
extern template class Base_EXPORT Observer<const char*>;
extern template class Base_EXPORT Subject<const char*>;
} //namespace Base

View File

@@ -191,6 +191,7 @@
#include <QStackedWidget>
#include <QTableWidgetItem>
#include <QWidget>
#include <QWidgetAction>
// QtXML
#include <QDomDocument>