Removed crash sending system for Windows.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2017-09-04 19:11:15 +03:00
parent 71649ccf2a
commit b19cb9aee7
16 changed files with 2 additions and 414 deletions

View File

@ -15,6 +15,7 @@
- [#750] Info Box Beside Mouse. - [#750] Info Box Beside Mouse.
- [#634] New feature: Fabric manager. - [#634] New feature: Fabric manager.
- [#731] Improve tab Increments. Separate the tab on two: Increments and Preview Calculation. - [#731] Improve tab Increments. Separate the tab on two: Increments and Preview Calculation.
- Removed crash sending system for Windows.
# Version 0.5.1 # Version 0.5.1
- [#683] Tool Seam allowance's dialog is off screen on small resolutions. - [#683] Tool Seam allowance's dialog is off screen on small resolutions.

BIN
dist/win/curl.exe vendored

Binary file not shown.

BIN
dist/win/dbghelp.dll vendored

Binary file not shown.

BIN
dist/win/exchndl.dll vendored

Binary file not shown.

View File

@ -219,8 +219,6 @@ Source: ".\valentina\*.dll"; DestDir: "{app}"
Source: ".\valentina\*.txt"; DestDir: "{app}"; Flags: ignoreversion Source: ".\valentina\*.txt"; DestDir: "{app}"; Flags: ignoreversion
Source: ".\valentina\*.rcc"; DestDir: "{app}"; Flags: ignoreversion Source: ".\valentina\*.rcc"; DestDir: "{app}"; Flags: ignoreversion
Source: ".\valentina\*.ico"; DestDir: "{app}"; Flags: ignoreversion Source: ".\valentina\*.ico"; DestDir: "{app}"; Flags: ignoreversion
Source: ".\valentina\*.dbg"; DestDir: "{app}"; Flags: ignoreversion skipifsourcedoesntexist
Source: ".\valentina\*.yes"; DestDir: "{app}"; Flags: ignoreversion skipifsourcedoesntexist
; NOTE: Don't use "Flags: ignoreversion" on any shared system files ; NOTE: Don't use "Flags: ignoreversion" on any shared system files
; DLL used to check if the target program is running at install time ; DLL used to check if the target program is running at install time

BIN
dist/win/mgwhelp.dll vendored

Binary file not shown.

BIN
dist/win/symsrv.dll vendored

Binary file not shown.

1
dist/win/symsrv.yes vendored
View File

@ -1 +0,0 @@

View File

@ -298,9 +298,6 @@ CONFIG(release, debug|release){
noDebugSymbols{ # For enable run qmake with CONFIG+=noDebugSymbols noDebugSymbols{ # For enable run qmake with CONFIG+=noDebugSymbols
DEFINES += V_NO_DEBUG DEFINES += V_NO_DEBUG
} else { } else {
noCrashReports{
DEFINES += V_NO_DEBUG
}
# Turn on debug symbols in release mode on Unix systems. # Turn on debug symbols in release mode on Unix systems.
# On Mac OS X temporarily disabled. Need find way how to strip binary file. # On Mac OS X temporarily disabled. Need find way how to strip binary file.
!macx:!*msvc*{ !macx:!*msvc*{

View File

@ -242,12 +242,6 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con
} }
} }
//---------------------------------------------------------------------------------------------------------------------
#if defined(Q_OS_WIN) && defined(Q_CC_GNU)
const QString VApplication::GistFileName = QStringLiteral("gist.json");
#endif // defined(Q_OS_WIN) && defined(Q_CC_GNU)
#define DefWidth 1.2//mm #define DefWidth 1.2//mm
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -552,12 +546,6 @@ void VApplication::ClearOldLogs() const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VApplication::InitOptions() void VApplication::InitOptions()
{ {
#if defined(Q_OS_WIN) && defined(Q_CC_GNU)
// Catch and send report
VApplication::DrMingw();
this->CollectReports();
#endif
// Run creation log after sending crash report // Run creation log after sending crash report
StartLogging(); StartLogging();
@ -605,9 +593,6 @@ void VApplication::StartLogging()
{ {
BeginLogging(); BeginLogging();
ClearOldLogs(); ClearOldLogs();
#if defined(Q_OS_WIN) && defined(Q_CC_GNU)
ClearOldReports();
#endif // defined(Q_OS_WIN) && defined(Q_CC_GNU)
} }
} }
@ -709,292 +694,3 @@ const VCommandLinePtr VApplication::CommandLine() const
{ {
return VCommandLine::instance; return VCommandLine::instance;
} }
//---------------------------------------------------------------------------------------------------------------------
#if defined(Q_OS_WIN) && defined(Q_CC_GNU)
//---------------------------------------------------------------------------------------------------------------------
void VApplication::ClearOldReports() const
{
const QString reportsDir = QString("%1/reports").arg(qApp->applicationDirPath());
QDir reports(reportsDir);
if (reports.exists())
{
QStringList filters{"*.log", "*.RPT"};
QDir logsDir(reportsDir);
logsDir.setNameFilters(filters);
logsDir.setCurrent(reportsDir);
const QStringList allFiles = logsDir.entryList(QDir::NoDotAndDotDot | QDir::Files);
if (allFiles.isEmpty() == false)
{
const QDateTime now = QDateTime::currentDateTime();
for (int i = 0; i < allFiles.size(); ++i)
{
QFileInfo info(allFiles.at(i));
if (info.created().daysTo(now) > 30)
{
QFile(allFiles.at(i)).remove();
}
}
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VApplication::GatherLogs() const
{
QTextStream *out = nullptr;
QFile *log = new QFile(QString("%1/valentina.log").arg(LogDirPath()));
if (log->open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text))
{
out = new QTextStream(log);
QStringList filters{"*.log"};
QDir logsDir(LogDirPath());
logsDir.setNameFilters(filters);
logsDir.setCurrent(LogDirPath());
const QStringList allFiles = logsDir.entryList(QDir::NoDotAndDotDot | QDir::Files);
if (allFiles.isEmpty() == false)
{
for (int i = 0, sz = allFiles.size(); i < sz; ++i)
{
auto fn = allFiles.at(i);
QFileInfo info(fn);
if (info.fileName() == "valentina.log")
{
continue;
}
VLockGuard<QFile> tmp(info.absoluteFilePath(), [&fn](){return new QFile(fn);});
if (tmp.IsLocked())
{
*out <<"--------------------------" << endl;
if (tmp.GetProtected()->open(QIODevice::ReadOnly | QIODevice::Text))
{
QTextStream in(tmp.GetProtected().get());
while (!in.atEnd())
{
*out << in.readLine() << endl;
}
tmp.GetProtected()->close();
}
else
{
*out << "Log file error:" + tmp.GetProtected()->errorString() << endl;
}
}
else
{
qCDebug(vApp, "Failed to lock %s", qUtf8Printable(info.absoluteFilePath()));
}
}
}
else
{
*out << "Could not find logs.";
}
log->close();
}
delete out;
delete log;
}
//---------------------------------------------------------------------------------------------------------------------
// Catch exception and create report. Use if program build with Mingw compiler.
// See more about catcher https://github.com/jrfonseca/drmingw/blob/master/README.md
void VApplication::DrMingw()
{
QFile drmingw("exchndl.dll");
if (drmingw.exists())
{// If don't want create reports just delete exchndl.dll from installer
LoadLibrary(L"exchndl.dll");
}
}
//---------------------------------------------------------------------------------------------------------------------
void VApplication::CollectReports() const
{
// Seek file "binary_name.RPT"
const QString reportName = QString("%1/%2.RPT").arg(applicationDirPath())
.arg(QFileInfo(arguments().at(0)).baseName());
QFile reportFile(reportName);
if (reportFile.exists())
{ // Hooray we have found crash
if (settings == nullptr)
{
return;// Settings was not opened.
}
if (settings->GetSendReportState())
{ // Try send report
// Remove gist.json file before close app.
connect(this, &VApplication::aboutToQuit, this, &VApplication::CleanGist, Qt::UniqueConnection);
SendReport(reportName);
}
else
{ // Just collect report to /reports directory
CollectReport(reportName);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VApplication::CollectReport(const QString &reportName) const
{
const QString reportsDir = QString("%1/reports").arg(qApp->applicationDirPath());
QDir reports(reportsDir);
if (reports.exists() == false)
{
reports.mkpath("."); // Create directory for reports if need
}
const QDateTime now = QDateTime::currentDateTime();
const QString timestamp = now.toString(QLatin1String("yyyy.MM.dd-hh_mm_ss"));
QString filename = QString("%1/reports/crash-%2.RPT").arg(qApp->applicationDirPath()).arg(timestamp);
QFile reportFile(reportName);
reportFile.copy(filename); // Collect new crash
reportFile.remove(); // Clear after yourself
filename = QString("%1/reports/log-%2.log").arg(qApp->applicationDirPath()).arg(timestamp);
GatherLogs();
QFile logFile(QString("%1/valentina.log").arg(LogDirPath()));
logFile.copy(filename); // Collect log
}
//---------------------------------------------------------------------------------------------------------------------
void VApplication::CleanGist() const
{
QFile gistFile(GistFileName);
if (gistFile.exists())
{
gistFile.remove();
}
}
//---------------------------------------------------------------------------------------------------------------------
void VApplication::SendReport(const QString &reportName) const
{
QString content;
QFile reportFile(reportName);
if (reportFile.open(QIODevice::ReadOnly | QIODevice::Text))
{
content = ReadFileForSending(reportFile);
reportFile.close();
}
else
{
content = "RPT file error:" + reportFile.errorString() + "\r\n";
}
// Additional information
content.append(QString("-------------------------------")+"\r\n");
content.append(QString("Version:%1").arg(APP_VERSION)+"\r\n");
content.append(QString("Build revision:%1").arg(BUILD_REVISION)+"\r\n");
content.append(QString("Based on Qt %1 (32 bit)").arg(QT_VERSION_STR)+"\r\n");
content.append(QString("Built on %1 at %2").arg(__DATE__).arg(__TIME__)+"\r\n");
content.append(QString("Web site:https://valentinaproject.bitbucket.io/ ")+"\r\n");
content.append("\r\n");
// Creating json with report
// Example:
//{
// "description":"Crash report",
// "public":"true",
// "files":{
// "valentina.RPT":{
// "content":"Report text here"
// }
// }
//}
// Useful to know when crash was created
const QDateTime now = QDateTime::currentDateTime();
const QString timestamp = now.toString(QLatin1String("yyyy/MM/dd hh:mm:ss:zzz"));
const QString report = QString("Crash report was created %2").arg(timestamp);
QJsonObject reportObject;
reportObject.insert(QStringLiteral("description"), QJsonValue(report));
reportObject.insert(QStringLiteral("public"), QJsonValue(QString("true")));
content.append(QString("\r\n-------------------------------\r\n"));
content.append(QString("Log:")+"\r\n");
GatherLogs();
QFile logFile(QString("%1/valentina.log").arg(LogDirPath()));
if (logFile.open(QIODevice::ReadOnly | QIODevice::Text))
{
const QString logContent = ReadFileForSending(logFile);
if (logContent.isEmpty())
{
content.append("Log file is empty.");
}
else
{
content.append(logContent);
}
logFile.close();
}
else
{
content.append("\r\n Log file error:" + logFile.errorString() + "\r\n");
}
const QString contentSection = QStringLiteral("content");
QJsonObject contentObject;
contentObject.insert(contentSection, QJsonValue(content));
const QString filesSection = QStringLiteral("files");
QJsonObject fileObject;
fileObject.insert(QFileInfo(reportName).fileName(), QJsonValue(contentObject));
reportObject.insert(filesSection, QJsonValue(fileObject));
QFile gistFile(GistFileName);
if (!gistFile.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text))
{
qDebug("Couldn't open gist file.");
return;
}
// Save data to file
QJsonDocument saveRep(reportObject);
gistFile.write(saveRep.toJson());
gistFile.close();
const QString curl = QString("%1/curl.exe").arg(qApp->applicationDirPath());
QFile curlFile(curl);
if (curlFile.exists())
{// Trying send report
// Change token if need
const QStringList token = QStringList()<<"eb"<<"78"<<"63"<<"4e"<<"de"<<"77"<<"f7"<<"e6"<<"01"<<"4a"<<"c3"<<"60"
<<"96"<<"b0"<<"2d"<<"54"<<"fb"<<"8e"<<"af"<<"ec";
const QString arg = QString("curl.exe -k -H \"Authorization: bearer ")+token.join("")+
QString("\" -H \"Accept: application/json\" -H \"Content-type: application/json\" -X POST "
"--data @gist.json https://api.github.com/gists");
QProcess proc;
proc.start(arg);
proc.waitForFinished(10000); // 10 sec
reportFile.remove();// Clear after yourself
}
else
{// We can not send than just collect
CollectReport(reportName);
}
curlFile.close();
}
//---------------------------------------------------------------------------------------------------------------------
QString VApplication::ReadFileForSending(QFile &file) const
{
QString content;
QTextStream in(&file);
while (!in.atEnd())
{
content.append(in.readLine()+"\r\n");// Windows end of line
}
return content;
}
#endif //defined(Q_OS_WIN) && defined(Q_CC_GNU)

View File

@ -70,10 +70,6 @@ public:
virtual const VTranslateVars *TrVars() Q_DECL_OVERRIDE; virtual const VTranslateVars *TrVars() Q_DECL_OVERRIDE;
#if defined(Q_OS_WIN) && defined(Q_CC_GNU)
static void DrMingw();
void CollectReports() const;
#endif // defined(Q_OS_WIN) && defined(Q_CC_GNU)
bool static IsGUIMode(); bool static IsGUIMode();
virtual bool IsAppInGUIMode() const Q_DECL_OVERRIDE; virtual bool IsAppInGUIMode() const Q_DECL_OVERRIDE;
@ -84,11 +80,6 @@ protected:
virtual void InitTrVars() Q_DECL_OVERRIDE; virtual void InitTrVars() Q_DECL_OVERRIDE;
virtual bool event(QEvent *e) Q_DECL_OVERRIDE; virtual bool event(QEvent *e) Q_DECL_OVERRIDE;
private slots:
#if defined(Q_OS_WIN) && defined(Q_CC_GNU)
void CleanGist() const;
#endif // defined(Q_OS_WIN) && defined(Q_CC_GNU)
private: private:
Q_DISABLE_COPY(VApplication) Q_DISABLE_COPY(VApplication)
VTranslateVars *trVars; VTranslateVars *trVars;
@ -97,16 +88,6 @@ private:
std::shared_ptr<VLockGuard<QFile>> lockLog; std::shared_ptr<VLockGuard<QFile>> lockLog;
std::shared_ptr<QTextStream> out; std::shared_ptr<QTextStream> out;
#if defined(Q_OS_WIN) && defined(Q_CC_GNU)
static const QString GistFileName;
void CollectReport(const QString &reportName) const;
void SendReport(const QString &reportName) const;
QString ReadFileForSending(QFile &file)const;
void ClearOldReports()const;
void GatherLogs()const;
#endif // defined(Q_OS_WIN) && defined(Q_CC_GNU)
QString LogDirPath()const; QString LogDirPath()const;
QString LogPath()const; QString LogPath()const;
bool CreateLogDir()const; bool CreateLogDir()const;

View File

@ -98,13 +98,6 @@ PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent)
{ {
ui->systemCombo->setCurrentIndex(index); ui->systemCombo->setCurrentIndex(index);
} }
//---------------------- Send crash reports
ui->sendReportCheck->setChecked(qApp->ValentinaSettings()->GetSendReportState());
ui->description = new QLabel(tr("After each crash Valentina collects information that may help us fix the "
"problem. We do not collect any personal information. Find more about what %1"
"kind of information%2 we collect.")
.arg("<a href=\"https://wiki.valentinaproject.org/wiki/UserManual:Crash_reports\">")
.arg("</a>"));
//----------------------------- Pattern Editing //----------------------------- Pattern Editing
connect(ui->resetWarningsButton, &QPushButton::released, []() connect(ui->resetWarningsButton, &QPushButton::released, []()
@ -138,7 +131,6 @@ void PreferencesConfigurationPage::Apply()
ui->autoSaveCheck->isChecked() ? autoSaveTimer->start(ui->autoTime->value()*60000) : autoSaveTimer->stop(); ui->autoSaveCheck->isChecked() ? autoSaveTimer->start(ui->autoTime->value()*60000) : autoSaveTimer->stop();
settings->SetOsSeparator(ui->osOptionCheck->isChecked()); settings->SetOsSeparator(ui->osOptionCheck->isChecked());
settings->SetSendReportState(ui->sendReportCheck->isChecked());
settings->SetToolBarStyle(ui->toolBarStyleCheck->isChecked()); settings->SetToolBarStyle(ui->toolBarStyleCheck->isChecked());
if (m_langChanged || m_systemChanged) if (m_langChanged || m_systemChanged)
@ -211,9 +203,4 @@ void PreferencesConfigurationPage::InitUnits()
void PreferencesConfigurationPage::RetranslateUi() void PreferencesConfigurationPage::RetranslateUi()
{ {
ui->osOptionCheck->setText(tr("With OS options") + QString(" (%1)").arg(QLocale().decimalPoint())); ui->osOptionCheck->setText(tr("With OS options") + QString(" (%1)").arg(QLocale().decimalPoint()));
ui->description->setText(tr("After each crash Valentina collects information that may help us fix the "
"problem. We do not collect any personal information. Find more about what %1"
"kind of information%2 we collect.")
.arg("<a href=\"https://wiki.valentinaproject.org/wiki/UserManual:Crash_reports\">")
.arg("</a>"));
} }

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>501</width> <width>501</width>
<height>640</height> <height>559</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -168,44 +168,6 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>Send crash reports</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="sendReportCheck">
<property name="text">
<string>Send crash reports (recommended)</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="description">
<property name="text">
<string notr="true">TextLabel</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::TextBrowserInteraction</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item> <item>
<widget class="QGroupBox" name="groupBox_5"> <widget class="QGroupBox" name="groupBox_5">
<property name="title"> <property name="title">

View File

@ -81,9 +81,6 @@ CONFIG(release, debug|release){
noDebugSymbols{ # For enable run qmake with CONFIG+=noDebugSymbols noDebugSymbols{ # For enable run qmake with CONFIG+=noDebugSymbols
DEFINES += V_NO_DEBUG DEFINES += V_NO_DEBUG
} else { } else {
noCrashReports{
DEFINES += V_NO_DEBUG
}
# Turn on debug symbols in release mode on Unix systems. # Turn on debug symbols in release mode on Unix systems.
# On Mac OS X temporarily disabled. Need find way how to strip binary file. # On Mac OS X temporarily disabled. Need find way how to strip binary file.
!macx:!*msvc*{ !macx:!*msvc*{
@ -301,20 +298,6 @@ win32:*g++* {
$$[QT_INSTALL_BINS]/libstdc++-6.dll \ $$[QT_INSTALL_BINS]/libstdc++-6.dll \
$$[QT_INSTALL_BINS]/libwinpthread-1.dll $$[QT_INSTALL_BINS]/libwinpthread-1.dll
!noDebugSymbols:!noCrashReports{
package.files += \
$${OUT_PWD}/$${DESTDIR}/valentina.exe.dbg \
$${OUT_PWD}/../tape/$${DESTDIR}/tape.exe.dbg \
$$PWD/../../../dist/win/exchndl.dll \
$$PWD/../../../dist/win/dbghelp.dll \
$$PWD/../../../dist/win/mgwhelp.dll \
$$PWD/../../../dist/win/symsrv.dll \
$$PWD/../../../dist/win/symsrv.yes \
$${OUT_PWD}/../../libs/qmuparser/$${DESTDIR}/qmuparser2.dll.dbg \
$${OUT_PWD}/../../libs/vpropertyexplorer/$${DESTDIR}/vpropertyexplorer.dll.dbg \
$$PWD/../../../dist/win/curl.exe
}
package.CONFIG = no_check_exist package.CONFIG = no_check_exist
INSTALLS += package INSTALLS += package

View File

@ -55,7 +55,6 @@ const QString settingPathsLabelTemplate = QStringLiteral("paths/labels"
const QString settingConfigurationOsSeparator = QStringLiteral("configuration/osSeparator"); const QString settingConfigurationOsSeparator = QStringLiteral("configuration/osSeparator");
const QString settingConfigurationAutosaveState = QStringLiteral("configuration/autosave/state"); const QString settingConfigurationAutosaveState = QStringLiteral("configuration/autosave/state");
const QString settingConfigurationAutosaveTime = QStringLiteral("configuration/autosave/time"); const QString settingConfigurationAutosaveTime = QStringLiteral("configuration/autosave/time");
const QString settingConfigurationSendReportState = QStringLiteral("configuration/send_report/state");
const QString settingConfigurationLocale = QStringLiteral("configuration/locale"); const QString settingConfigurationLocale = QStringLiteral("configuration/locale");
const QString settingPMSystemCode = QStringLiteral("configuration/pmscode"); const QString settingPMSystemCode = QStringLiteral("configuration/pmscode");
const QString settingConfigurationUnit = QStringLiteral("configuration/unit"); const QString settingConfigurationUnit = QStringLiteral("configuration/unit");
@ -393,18 +392,6 @@ void VCommonSettings::SetAutosaveTime(const int &value)
setValue(settingConfigurationAutosaveTime, value); setValue(settingConfigurationAutosaveTime, value);
} }
//---------------------------------------------------------------------------------------------------------------------
bool VCommonSettings::GetSendReportState() const
{
return value(settingConfigurationSendReportState, 1).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetSendReportState(const bool &value)
{
setValue(settingConfigurationSendReportState, value);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VCommonSettings::GetLocale() const QString VCommonSettings::GetLocale() const
{ {

View File

@ -79,9 +79,6 @@ public:
int GetAutosaveTime() const; int GetAutosaveTime() const;
void SetAutosaveTime(const int &value); void SetAutosaveTime(const int &value);
bool GetSendReportState() const;
void SetSendReportState(const bool &value);
QString GetLocale() const; QString GetLocale() const;
void SetLocale(const QString &value); void SetLocale(const QString &value);