mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-21 08:21:54 +02:00
Prevent boost from throwing an exception when env's locale is invalid.
This commit is contained in:
parent
84dadd04fe
commit
65116a209f
@ -266,7 +266,7 @@ endif()
|
||||
macro_optional_find_package(Echonest 2.2.0)
|
||||
macro_log_feature(ECHONEST_FOUND "Echonest" "Qt library for communicating with The Echo Nest" "http://projects.kde.org/libechonest" TRUE "" "libechonest 2.2.0 is needed for dynamic playlists and the infosystem")
|
||||
|
||||
find_package(Boost REQUIRED COMPONENTS system)
|
||||
find_package(Boost REQUIRED COMPONENTS filesystem system)
|
||||
macro_log_feature(Boost_FOUND "Boost" "Provides free peer-reviewed portable C++ source libraries" "http://www.boost.org" TRUE "" "") #FIXME: give useful explanation
|
||||
|
||||
macro_optional_find_package(Lucene++ 3.0.0)
|
||||
|
@ -194,6 +194,7 @@ TARGET_LINK_LIBRARIES( tomahawk_bin
|
||||
${MAC_EXTRA_LIBS}
|
||||
${ECHONEST_LIBRARIES}
|
||||
${TAGLIB_LIBRARIES}
|
||||
${Boost_LIBRARIES}
|
||||
)
|
||||
|
||||
IF( APPLE )
|
||||
|
@ -43,6 +43,30 @@
|
||||
#endif
|
||||
|
||||
#include <exception>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
|
||||
void
|
||||
checkLocales()
|
||||
{
|
||||
#if !defined(WIN32) && !defined(MAC_OSX) && !defined(__FreeBSD__) && !defined(__OpenBSD__)
|
||||
std::locale l( "C" );
|
||||
try
|
||||
{
|
||||
// Check if env's locale is valid
|
||||
l = std::locale( "" );
|
||||
}
|
||||
catch ( const std::runtime_error& )
|
||||
{
|
||||
// env's locale is invalid. Prevent boost from throwing an exception
|
||||
setenv( "LC_ALL", "C", 1 );
|
||||
}
|
||||
|
||||
// Needs be set by main thread
|
||||
boost::filesystem::path::imbue( l );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#include <windows.h>
|
||||
@ -131,6 +155,8 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine
|
||||
int
|
||||
main( int argc, char *argv[] )
|
||||
{
|
||||
checkLocales();
|
||||
|
||||
QCA::Initializer init;
|
||||
Q_UNUSED( init )
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user