mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 12:36:02 +08:00
Added a check that libslic3r/I18N.hpp is not included on the frontend by mistake,
also added a check that L macro is not defined when including libslic3r/I18N.hpp
This commit is contained in:
parent
19f2a1d9e9
commit
73857703b8
@ -3,6 +3,12 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#ifdef SLIC3R_CURRENTLY_COMPILING_GUI_MODULE
|
||||||
|
#ifndef SLIC3R_ALLOW_LIBSLIC3R_I18N_IN_SLIC3R
|
||||||
|
#error You included libslic3r/I18N.hpp into a file belonging to slic3r module.
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
namespace I18N {
|
namespace I18N {
|
||||||
@ -15,11 +21,18 @@ namespace I18N {
|
|||||||
|
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
|
|
||||||
namespace {
|
// When this is included from slic3r, better do not define the translation functions.
|
||||||
const char* L(const char* s) { return s; }
|
// Macros from slic3r/GUI/I18N.hpp should be used there.
|
||||||
std::string _u8L(const char* s) { return Slic3r::I18N::translate(s); }
|
#ifndef SLIC3R_CURRENTLY_COMPILING_GUI_MODULE
|
||||||
std::string _utf8(const char* s) { return Slic3r::I18N::translate(s); }
|
#ifdef L
|
||||||
std::string _utf8(const std::string& s) { return Slic3r::I18N::translate(s); }
|
#error L macro is defined where it shouldn't be. Didn't you include slic3r/GUI/I18N.hpp in libslic3r by mistake?
|
||||||
}
|
#endif
|
||||||
|
namespace {
|
||||||
|
const char* L(const char* s) { return s; }
|
||||||
|
std::string _u8L(const char* s) { return Slic3r::I18N::translate(s); }
|
||||||
|
std::string _utf8(const char* s) { return Slic3r::I18N::translate(s); }
|
||||||
|
std::string _utf8(const std::string& s) { return Slic3r::I18N::translate(s); }
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* slic3r_I18N_hpp_ */
|
#endif /* slic3r_I18N_hpp_ */
|
||||||
|
@ -344,3 +344,6 @@ if (UNIX AND NOT APPLE)
|
|||||||
target_include_directories(libslic3r_gui PRIVATE ${GTK${SLIC3R_GTK}_INCLUDE_DIRS})
|
target_include_directories(libslic3r_gui PRIVATE ${GTK${SLIC3R_GTK}_INCLUDE_DIRS})
|
||||||
target_link_libraries(libslic3r_gui ${GTK${SLIC3R_GTK}_LIBRARIES} fontconfig)
|
target_link_libraries(libslic3r_gui ${GTK${SLIC3R_GTK}_LIBRARIES} fontconfig)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
# Add a definition so that we can tell we are compiling slic3r.
|
||||||
|
target_compile_definitions(libslic3r_gui PRIVATE SLIC3R_CURRENTLY_COMPILING_GUI_MODULE)
|
||||||
|
@ -8,7 +8,11 @@
|
|||||||
|
|
||||||
// Localization headers: include libslic3r version first so everything in this file
|
// Localization headers: include libslic3r version first so everything in this file
|
||||||
// uses the slic3r/GUI version (the macros will take precedence over the functions).
|
// uses the slic3r/GUI version (the macros will take precedence over the functions).
|
||||||
|
// Also, there is a check that the former is not included from slic3r module.
|
||||||
|
// This is the only place where we want to allow that, so define an override macro.
|
||||||
|
#define SLIC3R_ALLOW_LIBSLIC3R_I18N_IN_SLIC3R
|
||||||
#include "libslic3r/I18N.hpp"
|
#include "libslic3r/I18N.hpp"
|
||||||
|
#undef SLIC3R_ALLOW_LIBSLIC3R_I18N_IN_SLIC3R
|
||||||
#include "slic3r/GUI/I18N.hpp"
|
#include "slic3r/GUI/I18N.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user