1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-27 15:50:40 +02:00

Merge pull request #229 from tomahawk-player/breakpad_external

Use libcrashreporter-qt in submodule instead of breakpad in tree
This commit is contained in:
Dominik Schmidt
2014-04-25 01:27:19 +02:00
1165 changed files with 96 additions and 465961 deletions

View File

@@ -21,7 +21,10 @@ add_subdirectory( viewpages )
# application
add_subdirectory( tomahawk )
add_subdirectory( crashreporter )
if(WITH_CRASHREPORTER)
add_subdirectory( crashreporter )
endif()
# tests
add_subdirectory( tests )

View File

@@ -3,14 +3,16 @@ cmake_policy(SET CMP0017 NEW)
setup_qt()
set(crashreporter_SOURCES main.cpp CrashReporter.cpp)
set(crashreporter_UI CrashReporter.ui)
set(crashreporter_RC ../../resources.qrc)
list(APPEND crashreporter_SOURCES main.cpp)
list(APPEND crashreporter_RC resources.qrc)
qt_wrap_ui( crashreporter_UI_HEADERS ${crashreporter_UI} )
qt_add_resources( crashreporter_RC_RCC ${crashreporter_RC} )
include_directories( ${CMAKE_CURRENT_BINARY_DIR} ../../libtomahawk )
include_directories( ${CMAKE_CURRENT_BINARY_DIR}
../../libtomahawk
../../thirdparty/libcrashreporter-qt/src
)
add_executable( tomahawk_crash_reporter WIN32
${crashreporter_SOURCES}
@@ -22,6 +24,7 @@ add_executable( tomahawk_crash_reporter WIN32
target_link_libraries(tomahawk_crash_reporter
tomahawklib
crashreporter-gui
${QT_LIBRARIES}
)

View File

@@ -1,208 +0,0 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#include "CrashReporter.h"
#include <QIcon>
#include <QDebug>
#include <QTimer>
#include <QDir>
#include <QDateTime>
#include "utils/TomahawkUtils.h"
#define LOGFILE TomahawkUtils::appLogDir().filePath( "Tomahawk.log" ).toLocal8Bit()
#define RESPATH ":/data/"
CrashReporter::CrashReporter( const QUrl& url, const QStringList& args )
: m_reply( 0 )
, m_url( url )
{
setWindowIcon( QIcon( RESPATH "icons/tomahawk-icon-128x128.png" ) );
ui.setupUi( this );
ui.logoLabel->setPixmap( QPixmap( RESPATH "icons/tomahawk-icon-128x128.png" ).scaled( QSize( 55, 55 ), Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
ui.progressBar->setRange( 0, 100 );
ui.progressBar->setValue( 0 );
ui.progressLabel->setPalette( Qt::gray );
#ifdef Q_OS_MAC
QFont f = ui.bottomLabel->font();
f.setPointSize( 10 );
ui.bottomLabel->setFont( f );
f.setPointSize( 11 );
ui.progressLabel->setFont( f );
ui.progressLabel->setIndent( 3 );
#else
ui.vboxLayout->setSpacing( 16 );
ui.hboxLayout1->setSpacing( 16 );
ui.progressBar->setTextVisible( false );
ui.progressLabel->setIndent( 1 );
ui.bottomLabel->setDisabled( true );
ui.bottomLabel->setIndent( 1 );
#endif //Q_OS_MAC
m_request = new QNetworkRequest( m_url );
m_dir = args.value( 1 );
m_minidump = m_dir + '/' + args.value( 2 ) + ".dmp";
m_product_name = args.value( 3 );
//hide until "send report" has been clicked
ui.progressBar->setVisible( false );
ui.button->setVisible( false );
ui.progressLabel->setVisible( false );
connect( ui.sendButton, SIGNAL( clicked() ), SLOT( onSendButton() ) );
adjustSize();
setFixedSize( size() );
}
CrashReporter::~CrashReporter()
{
delete m_request;
delete m_reply;
}
static QByteArray
contents( const QString& path )
{
QFile f( path );
f.open( QFile::ReadOnly );
return f.readAll();
}
void
CrashReporter::send()
{
QByteArray body;
// socorro expects a 10 digit build id
QRegExp rx( "(\\d+\\.\\d+\\.\\d+).(\\d+)" );
rx.exactMatch( TomahawkUtils::appFriendlyVersion() );
QString const version = rx.cap( 1 );
QString const buildId = rx.cap( 2 ).leftJustified( 10, '0' );
// add parameters
typedef QPair<QByteArray, QByteArray> Pair;
QList<Pair> pairs;
pairs << Pair( "BuildID", buildId.toUtf8() )
<< Pair( "ProductName", m_product_name.toUtf8() )
<< Pair( "Version", TomahawkUtils::appFriendlyVersion().toLocal8Bit() )
<< Pair( "Vendor", "Tomahawk" )
<< Pair( "timestamp", QByteArray::number( QDateTime::currentDateTime().toTime_t() ) );
foreach ( Pair const pair, pairs )
{
body += "--thkboundary\r\n";
body += "Content-Disposition: form-data; name=\"" +
pair.first + "\"\r\n\r\n" +
pair.second + "\r\n";
}
// add minidump file
body += "--thkboundary\r\n";
body += "Content-Disposition: form-data; name=\"upload_file_minidump\"; filename=\""
+ QFileInfo( m_minidump ).fileName() + "\"\r\n";
body += "Content-Type: application/octet-stream\r\n";
body += "\r\n";
body += contents( m_minidump );
body += "\r\n";
// add logfile
body += "--thkboundary\r\n";
body += "Content-Disposition: form-data; name=\"upload_file_tomahawklog\"; filename=\"Tomahawk.log\"\r\n";
body += "Content-Type: application/x-gzip\r\n";
body += "\r\n";
body += qCompress( contents( LOGFILE ) );
body += "\r\n";
body += "--thkboundary--\r\n";
QNetworkAccessManager* nam = new QNetworkAccessManager( this );
m_request->setHeader( QNetworkRequest::ContentTypeHeader, "multipart/form-data; boundary=thkboundary" );
m_reply = nam->post( *m_request, body );
#if QT_VERSION < QT_VERSION_CHECK( 5, 0, 0 )
connect( m_reply, SIGNAL( finished() ), SLOT( onDone() ), Qt::QueuedConnection );
connect( m_reply, SIGNAL( uploadProgress( qint64, qint64 ) ), SLOT( onProgress( qint64, qint64 ) ) );
#else
connect( m_reply, &QNetworkReply::finished, this, &CrashReporter::onDone, Qt::QueuedConnection );
connect( m_reply, &QNetworkReply::uploadProgress, this, &CrashReporter::onProgress );
#endif
}
void
CrashReporter::onProgress( qint64 done, qint64 total )
{
if ( total )
{
QString const msg = tr( "Uploaded %L1 of %L2 KB." ).arg( done / 1024 ).arg( total / 1024 );
ui.progressBar->setMaximum( total );
ui.progressBar->setValue( done );
ui.progressLabel->setText( msg );
}
}
void
CrashReporter::onDone()
{
QByteArray data = m_reply->readAll();
ui.progressBar->setValue( ui.progressBar->maximum() );
ui.button->setText( tr( "Close" ) );
QString const response = QString::fromUtf8( data );
if ( ( m_reply->error() != QNetworkReply::NoError ) || !response.startsWith( "CrashID=" ) )
{
onFail( m_reply->error(), m_reply->errorString() );
}
else
ui.progressLabel->setText( tr( "Sent! <b>Many thanks</b>." ) );
}
void
CrashReporter::onFail( int error, const QString& errorString )
{
ui.button->setText( tr( "Close" ) );
ui.progressLabel->setText( tr( "Failed to send crash info." ) );
qDebug() << "Error:" << error << errorString;
}
void
CrashReporter::onSendButton()
{
ui.progressBar->setVisible( true );
ui.button->setVisible( true );
ui.progressLabel->setVisible( true );
ui.sendButton->setEnabled( false );
ui.dontSendButton->setEnabled( false );
adjustSize();
setFixedSize( size() );
QTimer::singleShot( 0, this, SLOT( send() ) );
}

View File

@@ -1,58 +0,0 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CRASHREPORTER_H
#define CRASHREPORTER_H
#include <QDialog>
#include <QFile>
#include <QNetworkReply>
#include <QNetworkRequest>
#include "ui_CrashReporter.h"
class CrashReporter : public QDialog
{
Q_OBJECT
public:
CrashReporter( const QUrl& url, const QStringList& argv );
virtual ~CrashReporter( );
private:
Ui::CrashReporter ui;
QString m_minidump;
QString m_dir;
QString m_product_name;
QNetworkRequest* m_request;
QNetworkReply* m_reply;
QUrl m_url;
public slots:
void send();
private slots:
void onDone();
void onProgress( qint64 done, qint64 total );
void onFail( int error, const QString& errorString );
void onSendButton();
};
#endif // CRASHREPORTER_H

View File

@@ -1,257 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CrashReporter</class>
<widget class="QDialog" name="CrashReporter">
<property name="windowModality">
<enum>Qt::ApplicationModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>376</width>
<height>216</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Tomahawk Crash Reporter</string>
</property>
<property name="modal">
<bool>false</bool>
</property>
<layout class="QVBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>9</number>
</property>
<item>
<layout class="QHBoxLayout" name="hboxLayout">
<property name="spacing">
<number>12</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="logoLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>55</width>
<height>55</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>55</width>
<height>55</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="topLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Sorry!&lt;/span&gt; Tomahawk crashed. Please tell us about it! Tomahawk has created an error report for you that can help improve the stability in the future. You can now send this report directly to the Tomahawk developers.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>6</width>
<height>6</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="hboxLayout1">
<property name="spacing">
<number>-1</number>
</property>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="sendButton">
<property name="text">
<string>Send this report</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="dontSendButton">
<property name="text">
<string>Don't send</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="vboxLayout1">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="progressLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout">
<property name="spacing">
<number>9</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QProgressBar" name="progressBar">
<property name="value">
<number>24</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Abort</string>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="bottomLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>You can disable sending crash reports in the configuration dialog.</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>button</sender>
<signal>clicked()</signal>
<receiver>CrashReporter</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>426</x>
<y>203</y>
</hint>
<hint type="destinationlabel">
<x>247</x>
<y>195</y>
</hint>
</hints>
</connection>
<connection>
<sender>dontSendButton</sender>
<signal>clicked()</signal>
<receiver>CrashReporter</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>380</x>
<y>117</y>
</hint>
<hint type="destinationlabel">
<x>218</x>
<y>122</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -16,17 +16,20 @@
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#include "CrashReporter.h"
#include <libcrashreporter-gui/CrashReporter.h>
#include <QTranslator>
#include <iostream>
#include <QApplication>
#include <QFileInfo>
#include "utils/TomahawkUtils.h"
#include "utils/Logger.h"
const char* k_usage =
"Usage:\n"
" CrashReporter <logDir> <dumpFileName> <productName>\n";
" CrashReporter <dumpFilePath>\n";
int main( int argc, char* argv[] )
{
@@ -39,13 +42,71 @@ int main( int argc, char* argv[] )
QApplication app( argc, argv );
TomahawkUtils::installTranslator( &app );
if ( app.arguments().size() != 4 )
if ( app.arguments().size() != 2 )
{
std::cout << k_usage;
return 1;
}
CrashReporter reporter( QUrl( "http://oops.tomahawk-player.org/addreport.php" ), app.arguments() );
CrashReporter reporter( QUrl( "http://crash-reports.tomahawk-player.org/submit" ), app.arguments() );
reporter.setLogo(QPixmap(":/tomahawk-icon.png"));
// // socorro expects a 10 digit build id
// QRegExp rx( "(\\d+\\.\\d+\\.\\d+).(\\d+)" );
// rx.exactMatch( TomahawkUtils::appFriendlyVersion() );
// //QString const version = rx.cap( 1 );
// QString const buildId = rx.cap( 2 ).leftJustified( 10, '0' );
reporter.setReportData( "BuildID", "YYYYMMDDHH" );
reporter.setReportData( "ProductName", "WaterWolf" );
reporter.setReportData( "Version", TomahawkUtils::appFriendlyVersion().toLocal8Bit() );
//reporter.setReportData( "timestamp", QByteArray::number( QDateTime::currentDateTime().toTime_t() ) );
// add parameters
// QList<Pair> pairs;
// pairs //<< Pair( "BuildID", buildId.toUtf8() )
// << Pair( )
// //<< Pair( "Version", TomahawkUtils::appFriendlyVersion().toLocal8Bit() )
// //<< Pair( "Vendor", "Tomahawk" )
// //<< Pair( )
// << Pair("InstallTime", "1357622062")
// << Pair("Theme", "classic/1.0")
// << Pair("Version", "30")
// << Pair("id", "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}")
// << Pair("Vendor", "Mozilla")
// << Pair("EMCheckCompatibility", "true")
// << Pair("Throttleable", "0")
// << Pair("URL", "http://code.google.com/p/crashme/")
// << Pair("version", "20.0a1")
// << Pair("CrashTime", "1357770042")
// << Pair("ReleaseChannel", "nightly")
// << Pair("submitted_timestamp", "2013-01-09T22:21:18.646733+00:00")
// << Pair("buildid", "20130107030932")
// << Pair("timestamp", "1357770078.646789")
// << Pair("Notes", "OpenGL: NVIDIA Corporation -- GeForce 8600M GT/PCIe/SSE2 -- 3.3.0 NVIDIA 313.09 -- texture_from_pixmap\r\n")
// << Pair("StartupTime", "1357769913")
// << Pair("FramePoisonSize", "4096")
// << Pair("FramePoisonBase", "7ffffffff0dea000")
// << Pair("Add-ons", "%7B972ce4c6-7e08-4474-a285-3208198ce6fd%7D:20.0a1,crashme%40ted.mielczarek.org:0.4")
// << Pair("BuildID", "YYYYMMDDHH")
// << Pair("SecondsSinceLastCrash", "1831736")
// << Pair("ProductName", "WaterWolf")
// << Pair("legacy_processing", "0")
// << Pair("ProductID", "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}")
;
// send log
QFile logFile( Logger::logFile() );
logFile.open( QFile::ReadOnly );
reporter.setReportData( "upload_file_tomahawklog", qCompress( logFile.readAll() ), "application/x-gzip", QFileInfo( Logger::logFile() ).fileName().toUtf8());
logFile.close();
reporter.show();
return app.exec();

View File

@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/">
<file alias="tomahawk-icon.png">../../data/icons/tomahawk-icon-128x128.png</file>
</qresource>
</RCC>

View File

@@ -71,10 +71,6 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui}
widgets/UnstyledFrame.cpp
)
IF( WITH_BREAKPAD )
LIST(APPEND tomahawkSourcesGui breakpad/BreakPad.cpp)
ENDIF()
SET( tomahawkUI ${tomahawkUI}
dialogs/DiagnosticsDialog.ui
dialogs/HostDialog.ui
@@ -100,7 +96,7 @@ INCLUDE_DIRECTORIES(
../libtomahawk
mac
${THIRDPARTY_DIR}/breakpad
${THIRDPARTY_DIR}/libcrashreporter-qt/src/
${TAGLIB_INCLUDES}
${LIBATTICA_INCLUDE_DIR}
@@ -177,8 +173,8 @@ ENDIF( LIBLASTFM_FOUND )
IF( QCA2_FOUND )
LIST(APPEND LINK_LIBRARIES ${LINK_LIBRARIES} ${QCA2_LIBRARIES} )
ENDIF( QCA2_FOUND )
IF( WITH_BREAKPAD )
LIST(APPEND LINK_LIBRARIES ${LINK_LIBRARIES} tomahawk_breakpad )
IF( WITH_CRASHREPORTER )
LIST(APPEND LINK_LIBRARIES ${LINK_LIBRARIES} crashreporter-handler )
ENDIF()
TARGET_LINK_LIBRARIES( tomahawk_bin

View File

@@ -12,7 +12,6 @@
#cmakedefine LEOPARD
#cmakedefine HAVE_SPARKLE
#cmakedefine WITH_BREAKPAD
#cmakedefine WITH_CRASHREPORTER
#cmakedefine WITH_BINARY_ATTICA
#cmakedefine WITH_QTSPARKLE

View File

@@ -1,179 +0,0 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#include "BreakPad.h"
#include "config.h"
#include "utils/Logger.h"
#include <QCoreApplication>
#include <QString>
#include <QFileInfo>
#include <string.h>
#define CRASH_REPORTER_BINARY "tomahawk_crash_reporter"
bool s_active = true;
#ifndef WIN32
#include <unistd.h>
static bool
LaunchUploader( const char* dump_dir, const char* minidump_id, void* that, bool succeeded )
{
// DON'T USE THE HEAP!!!
// So that indeed means, no QStrings, no qDebug(), no QAnything, seriously!
if ( !succeeded )
return false;
const char* crashReporter = static_cast<BreakPad*>(that)->crashReporter();
if ( !s_active || strlen( crashReporter ) == 0 )
return false;
pid_t pid = fork();
if ( pid == -1 ) // fork failed
return false;
if ( pid == 0 )
{
// we are the fork
execl( crashReporter,
crashReporter,
dump_dir,
minidump_id,
minidump_id,
(char*) 0 );
// execl replaces this process, so no more code will be executed
// unless it failed. If it failed, then we should return false.
printf( "Error: Can't launch CrashReporter!\n" );
return false;
}
// we called fork()
return true;
}
BreakPad::BreakPad( const QString& path, bool active )
#ifdef Q_OS_LINUX
: google_breakpad::ExceptionHandler( path.toStdString(), 0, LaunchUploader, this, true )
#else
: google_breakpad::ExceptionHandler( path.toStdString(), 0, LaunchUploader, this, true, 0 )
#endif
{
s_active = active;
QString reporter;
QString localReporter = QString( "%1/%2" ).arg( qApp->applicationDirPath() ).arg( CRASH_REPORTER_BINARY );
QString globalReporter = QString( "%1/%2" ).arg( CMAKE_INSTALL_FULL_LIBEXECDIR ).arg( CRASH_REPORTER_BINARY );
if ( QFileInfo( localReporter ).exists() )
reporter = localReporter;
else if ( QFileInfo( globalReporter ).exists() )
reporter = globalReporter;
else
qDebug() << "Could not find \"" CRASH_REPORTER_BINARY "\" in \"" CMAKE_INSTALL_FULL_LIBEXECDIR "\" or application path";
char* creporter;
std::string sreporter = reporter.toStdString();
creporter = new char[ sreporter.size() + 1 ];
strcpy( creporter, sreporter.c_str() );
m_crashReporter = creporter;
}
#else
static bool
LaunchUploader( const wchar_t* dump_dir, const wchar_t* minidump_id, void* that, EXCEPTION_POINTERS *exinfo, MDRawAssertionInfo *assertion, bool succeeded )
{
if ( !succeeded )
return false;
// DON'T USE THE HEAP!!!
// So that indeed means, no QStrings, no qDebug(), no QAnything, seriously!
// broken in mingw, hardcode it for now
// const char* productName = static_cast<BreakPad*>(that)->productName();s
// convert productName to widechars, which sadly means the product name must be Latin1
wchar_t product_name[ 256 ] = L"tomahawk";;
// char* out = (char*)product_name;
// const char* in = productName - 1;
// do {
// *out++ = *++in; //latin1 chars fit in first byte of each wchar
// *out++ = '\0'; //every second byte is NULL
// }
// while (*in);
wchar_t command[MAX_PATH * 3 + 6];
wcscpy( command, CRASH_REPORTER_BINARY L" \"" );
wcscat( command, dump_dir );
wcscat( command, L"\" \"" );
wcscat( command, minidump_id );
wcscat( command, L"\" \"" );
wcscat( command, product_name );
wcscat( command, L"\"" );
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof( si ) );
si.cb = sizeof(si);
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_SHOWNORMAL;
ZeroMemory( &pi, sizeof(pi) );
if ( CreateProcess( NULL, command, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi ) )
{
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
TerminateProcess( GetCurrentProcess(), 1 );
}
return false;
}
BreakPad::BreakPad( const QString& path, bool active )
: google_breakpad::ExceptionHandler( path.toStdWString(), 0, LaunchUploader, this, true )
{
s_active = active;
}
#endif // WIN32
void
BreakPad::setActive( bool enabled )
{
s_active = enabled;
}
bool
BreakPad::isActive()
{
return s_active;
}

View File

@@ -1,50 +0,0 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QString>
#ifdef __APPLE__
# include "client/mac/handler/exception_handler.h"
#elif defined WIN32
# include "client/windows/handler/exception_handler.h"
#elif defined __linux__
# include "client/linux/handler/exception_handler.h"
#endif
class BreakPad : public google_breakpad::ExceptionHandler
{
const char* m_productName; // yes! It MUST be const char[]
const char* m_crashReporter; // again, const char[]
public:
BreakPad( const QString& dump_write_dirpath, bool active );
~BreakPad()
{}
static void setActive( bool enabled );
static bool isActive();
void setProductName( const char* s ) { m_productName = s; };
const char* productName() const { return m_productName; }
void setCrashReporter( const char* s ) { m_crashReporter = s; };
const char* crashReporter() const { return m_crashReporter; }
};
#undef char

View File

@@ -36,8 +36,8 @@
#ifndef ENABLE_HEADLESS
#include "TomahawkSettingsGui.h"
#ifdef WITH_BREAKPAD
#include "breakpad/BreakPad.h"
#ifdef WITH_CRASHREPORTER
#include "libcrashreporter-handler/Handler.h"
#endif
#ifdef Q_WS_X11 // This is probably a very bad idea with Qt5 anyway... because (if at all) X lives in a QPA plugin
@@ -165,8 +165,8 @@ main( int argc, char *argv[] )
#endif
#ifndef ENABLE_HEADLESS
#ifdef WITH_BREAKPAD
new BreakPad( QDir::tempPath(), TomahawkSettings::instance()->crashReporterEnabled() && !TomahawkUtils::headless() );
#ifdef WITH_CRASHREPORTER
new CrashReporter::Handler( QDir::tempPath(), TomahawkSettings::instance()->crashReporterEnabled() && !TomahawkUtils::headless(), "tomahawk_crash_reporter" );
#endif
#endif