mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 22:26:32 +02:00
* Make sure to always launch CrashReporter from the directory the Tomahawk executable lives in.
This commit is contained in:
@@ -18,7 +18,9 @@
|
|||||||
|
|
||||||
#include "BreakPad.h"
|
#include "BreakPad.h"
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -35,6 +37,7 @@ LaunchUploader( const char* dump_dir, const char* minidump_id, void* that, bool
|
|||||||
if ( !succeeded )
|
if ( !succeeded )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
const char* crashReporter = static_cast<BreakPad*>(that)->crashReporter();
|
||||||
pid_t pid = fork();
|
pid_t pid = fork();
|
||||||
|
|
||||||
if ( pid == -1 ) // fork failed
|
if ( pid == -1 ) // fork failed
|
||||||
@@ -42,8 +45,8 @@ LaunchUploader( const char* dump_dir, const char* minidump_id, void* that, bool
|
|||||||
if ( pid == 0 )
|
if ( pid == 0 )
|
||||||
{
|
{
|
||||||
// we are the fork
|
// we are the fork
|
||||||
execl( CRASH_REPORTER_BINARY,
|
execl( crashReporter,
|
||||||
CRASH_REPORTER_BINARY,
|
crashReporter,
|
||||||
dump_dir,
|
dump_dir,
|
||||||
minidump_id,
|
minidump_id,
|
||||||
minidump_id,
|
minidump_id,
|
||||||
@@ -67,6 +70,14 @@ BreakPad::BreakPad( const QString& path )
|
|||||||
: google_breakpad::ExceptionHandler( path.toStdString(), 0, LaunchUploader, this, true, 0 )
|
: google_breakpad::ExceptionHandler( path.toStdString(), 0, LaunchUploader, this, true, 0 )
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
QString reporter = QString( "%1/%2" ).arg( qApp->applicationDirPath() ).arg( CRASH_REPORTER_BINARY );
|
||||||
|
|
||||||
|
char* creporter;
|
||||||
|
std::string sreporter = reporter.toStdString();
|
||||||
|
creporter = new char[ sreporter.size() + 1 ];
|
||||||
|
strcpy( creporter, sreporter.c_str() );
|
||||||
|
|
||||||
|
m_crashReporter = creporter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -82,12 +93,12 @@ LaunchUploader( const wchar_t* dump_dir, const wchar_t* minidump_id, void* that,
|
|||||||
// DON'T USE THE HEAP!!!
|
// DON'T USE THE HEAP!!!
|
||||||
// So that indeed means, no QStrings, no qDebug(), no QAnything, seriously!
|
// So that indeed means, no QStrings, no qDebug(), no QAnything, seriously!
|
||||||
|
|
||||||
const char* m_product_name = static_cast<BreakPad*>(that)->productName();
|
const char* productName = static_cast<BreakPad*>(that)->productName();
|
||||||
|
|
||||||
// convert m_product_name to widechars, which sadly means the product name must be Latin1
|
// convert productName to widechars, which sadly means the product name must be Latin1
|
||||||
wchar_t product_name[ 256 ];
|
wchar_t productName[ 256 ];
|
||||||
char* out = (char*)product_name;
|
char* out = (char*)product_name;
|
||||||
const char* in = m_product_name - 1;
|
const char* in = productName - 1;
|
||||||
do {
|
do {
|
||||||
*out++ = *++in; //latin1 chars fit in first byte of each wchar
|
*out++ = *++in; //latin1 chars fit in first byte of each wchar
|
||||||
*out++ = '\0'; //every second byte is NULL
|
*out++ = '\0'; //every second byte is NULL
|
||||||
|
@@ -28,7 +28,8 @@
|
|||||||
|
|
||||||
class BreakPad : public google_breakpad::ExceptionHandler
|
class BreakPad : public google_breakpad::ExceptionHandler
|
||||||
{
|
{
|
||||||
const char* m_product_name; // yes! It MUST be const char[]
|
const char* m_productName; // yes! It MUST be const char[]
|
||||||
|
const char* m_crashReporter; // again, const char[]
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BreakPad( const QString &dump_write_dirpath );
|
BreakPad( const QString &dump_write_dirpath );
|
||||||
@@ -36,8 +37,11 @@ public:
|
|||||||
~BreakPad()
|
~BreakPad()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void setProductName( const char* s ) { m_product_name = s; };
|
void setProductName( const char* s ) { m_productName = s; };
|
||||||
const char* productName() const { return m_product_name; }
|
const char* productName() const { return m_productName; }
|
||||||
|
|
||||||
|
void setCrashReporter( const char* s ) { m_crashReporter = s; };
|
||||||
|
const char* crashReporter() const { return m_crashReporter; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#undef char
|
#undef char
|
||||||
|
@@ -36,6 +36,7 @@ using namespace Tomahawk;
|
|||||||
|
|
||||||
TomahawkSettings* TomahawkSettings::s_instance = 0;
|
TomahawkSettings* TomahawkSettings::s_instance = 0;
|
||||||
|
|
||||||
|
|
||||||
inline QDataStream& operator<<(QDataStream& out, const AtticaManager::StateHash& states)
|
inline QDataStream& operator<<(QDataStream& out, const AtticaManager::StateHash& states)
|
||||||
{
|
{
|
||||||
out << (quint32)states.count();
|
out << (quint32)states.count();
|
||||||
@@ -47,6 +48,7 @@ inline QDataStream& operator<<(QDataStream& out, const AtticaManager::StateHash&
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline QDataStream& operator>>(QDataStream& in, AtticaManager::StateHash& states)
|
inline QDataStream& operator>>(QDataStream& in, AtticaManager::StateHash& states)
|
||||||
{
|
{
|
||||||
quint32 count = 0;
|
quint32 count = 0;
|
||||||
@@ -64,6 +66,7 @@ inline QDataStream& operator>>(QDataStream& in, AtticaManager::StateHash& states
|
|||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TomahawkSettings*
|
TomahawkSettings*
|
||||||
TomahawkSettings::instance()
|
TomahawkSettings::instance()
|
||||||
{
|
{
|
||||||
|
@@ -35,10 +35,6 @@
|
|||||||
int
|
int
|
||||||
main( int argc, char *argv[] )
|
main( int argc, char *argv[] )
|
||||||
{
|
{
|
||||||
#ifndef Q_WS_WIN
|
|
||||||
new BreakPad( "/tmp" );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_WS_MAC
|
||||||
// Do Mac specific startup to get media keys working.
|
// Do Mac specific startup to get media keys working.
|
||||||
// This must go before QApplication initialisation.
|
// This must go before QApplication initialisation.
|
||||||
@@ -50,6 +46,11 @@ main( int argc, char *argv[] )
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
TomahawkApp a( argc, argv );
|
TomahawkApp a( argc, argv );
|
||||||
|
|
||||||
|
#ifndef Q_WS_WIN
|
||||||
|
new BreakPad( "/tmp" );
|
||||||
|
#endif
|
||||||
|
|
||||||
KDSingleApplicationGuard guard( &a, KDSingleApplicationGuard::AutoKillOtherInstances );
|
KDSingleApplicationGuard guard( &a, KDSingleApplicationGuard::AutoKillOtherInstances );
|
||||||
QObject::connect( &guard, SIGNAL( instanceStarted( KDSingleApplicationGuard::Instance ) ), &a, SLOT( instanceStarted( KDSingleApplicationGuard::Instance ) ) );
|
QObject::connect( &guard, SIGNAL( instanceStarted( KDSingleApplicationGuard::Instance ) ), &a, SLOT( instanceStarted( KDSingleApplicationGuard::Instance ) ) );
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user