summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-12-11 00:06:47 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-12-11 03:31:57 +0000
commit80049d110a742060acedb89eaad763e66d7f75a5 (patch)
tree1167541007dc7cc3821babff5cc9929d4bb9cd77
parent5e6c7d6d26349139ff5881a67c7fec3f48df6aa3 (diff)
don't overwrite the crashreport info that are written before upload
There was a race condition that the OpenGL code was initialized before the old report has been uploaded. Therefore the OpenGL setting was overwritten by the new start and we were not getting the old value. Now we store any value that wants to be added before the dump.ini is ready in a temporary map and will write them as soon as we write all the common information. This problem was introduced by the dialog requesting permission to upload the crash report. Change-Id: I29391a1ff56bac6381218c5a4aefb58c2c03f024 Reviewed-on: https://gerrit.libreoffice.org/31846 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
-rw-r--r--desktop/source/app/crashreport.cxx34
-rw-r--r--include/desktop/crashreport.hxx4
2 files changed, 34 insertions, 4 deletions
diff --git a/desktop/source/app/crashreport.cxx b/desktop/source/app/crashreport.cxx
index c50c2e98eba2..9715fde513c9 100644
--- a/desktop/source/app/crashreport.cxx
+++ b/desktop/source/app/crashreport.cxx
@@ -35,28 +35,54 @@ osl::Mutex CrashReporter::maMutex;
#endif
google_breakpad::ExceptionHandler* CrashReporter::mpExceptionHandler = nullptr;
+bool CrashReporter::mbInit = false;
+std::map<OUString, OUString> CrashReporter::maKeyValues;
+
+namespace {
+
+void writeToStream(std::ofstream& strm, const OUString& rKey, const OUString& rValue)
+{
+ strm << rtl::OUStringToOString(rKey, RTL_TEXTENCODING_UTF8).getStr() << "=";
+ strm << rtl::OUStringToOString(rValue, RTL_TEXTENCODING_UTF8).getStr() << "\n";
+}
+
+}
void CrashReporter::AddKeyValue(const OUString& rKey, const OUString& rValue)
{
osl::MutexGuard aGuard(maMutex);
- std::string ini_path = getIniFileName();
- std::ofstream ini_file(ini_path, std::ios_base::app);
- ini_file << rtl::OUStringToOString(rKey, RTL_TEXTENCODING_UTF8).getStr() << "=";
- ini_file << rtl::OUStringToOString(rValue, RTL_TEXTENCODING_UTF8).getStr() << "\n";
+ if (mbInit)
+ {
+ std::string ini_path = getIniFileName();
+ std::ofstream ini_file(ini_path, std::ios_base::app);
+ writeToStream(ini_file, rKey, rValue);
+ }
+ else
+ {
+ maKeyValues.insert(std::pair<OUString, OUString>(rKey, rValue));
+ }
}
#endif
void CrashReporter::writeCommonInfo()
{
+ osl::MutexGuard aGuard(maMutex);
// limit the amount of code that needs to be executed before the crash reporting
std::string ini_path = CrashReporter::getIniFileName();
std::ofstream minidump_file(ini_path, std::ios_base::trunc);
minidump_file << "ProductName=LibreOffice\n";
minidump_file << "Version=" LIBO_VERSION_DOTTED "\n";
minidump_file << "URL=http://crashreport.libreoffice.org/submit/\n";
+ for (auto& keyValue : maKeyValues)
+ {
+ writeToStream(minidump_file, keyValue.first, keyValue.second);
+ }
+ maKeyValues.clear();
minidump_file.close();
+ mbInit = true;
+
updateMinidumpLocation();
}
diff --git a/include/desktop/crashreport.hxx b/include/desktop/crashreport.hxx
index e58e387d0122..f4616e88c367 100644
--- a/include/desktop/crashreport.hxx
+++ b/include/desktop/crashreport.hxx
@@ -57,6 +57,10 @@ private:
static osl::Mutex maMutex;
+ static bool mbInit;
+
+ static std::map<OUString, OUString> maKeyValues; // used to temporarily save entries before the old info has been uploaded
+
static google_breakpad::ExceptionHandler* mpExceptionHandler;
};