diff options
-rw-r--r-- | desktop/source/app/crashreport.cxx | 34 | ||||
-rw-r--r-- | include/desktop/crashreport.hxx | 4 |
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; }; |