1
0
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:
Christian Muehlhaeuser 2015-04-13 08:04:32 +02:00
parent 9e9119ca6b
commit 51fd1227e7
3 changed files with 28 additions and 1 deletions

View File

@ -304,7 +304,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)

View File

@ -198,6 +198,7 @@ TARGET_LINK_LIBRARIES( tomahawk_bin
${MAC_EXTRA_LIBS}
${ECHONEST_LIBRARIES}
${TAGLIB_LIBRARIES}
${Boost_LIBRARIES}
)
IF( APPLE )

View File

@ -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 )