From 63f3bdaf77ebebd1dde759c295b40d7348e63a2d Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Sat, 11 Mar 2023 06:28:21 +0100 Subject: [PATCH] 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 --- src/Base/CMakeLists.txt | 1 + src/Base/Observer.cpp | 34 ++++++++++++++++++++++++++++++++++ src/Base/Observer.h | 17 +++++++++-------- src/Gui/QtAll.h | 1 + 4 files changed, 45 insertions(+), 8 deletions(-) create mode 100644 src/Base/Observer.cpp diff --git a/src/Base/CMakeLists.txt b/src/Base/CMakeLists.txt index 38609caf05..a82dd77b2d 100644 --- a/src/Base/CMakeLists.txt +++ b/src/Base/CMakeLists.txt @@ -231,6 +231,7 @@ SET(FreeCADBase_CPP_SRCS MatrixPyImp.cpp MemDebug.cpp Mutex.cpp + Observer.cpp Parameter.xsd Parameter.cpp ParameterPy.cpp diff --git a/src/Base/Observer.cpp b/src/Base/Observer.cpp new file mode 100644 index 0000000000..26813b28ff --- /dev/null +++ b/src/Base/Observer.cpp @@ -0,0 +1,34 @@ +/*************************************************************************** + * Copyright (c) 2023 Abdullah Tahiri * + * * + * 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; +template class BaseExport Subject; + +} //namespace Base diff --git a/src/Base/Observer.h b/src/Base/Observer.h index 00de45e81e..e4f004d604 100644 --- a/src/Base/Observer.h +++ b/src/Base/Observer.h @@ -216,16 +216,17 @@ protected: std::set *> _ObserverSet; }; -#if defined (FC_OS_WIN32) || defined(FC_OS_CYGWIN) -# ifdef FCBase -template class BaseExport Observer; -template class BaseExport Subject; -# else -extern template class BaseExport Observer; -extern template class BaseExport Subject; -# endif +// Workaround for MSVC +#ifdef FreeCADBase_EXPORTS +# define Base_EXPORT +#else +# define Base_EXPORT BaseExport #endif +extern template class Base_EXPORT Observer; +extern template class Base_EXPORT Subject; + + } //namespace Base diff --git a/src/Gui/QtAll.h b/src/Gui/QtAll.h index 3139f58415..0d570a641e 100644 --- a/src/Gui/QtAll.h +++ b/src/Gui/QtAll.h @@ -191,6 +191,7 @@ #include #include #include +#include // QtXML #include