[Libreoffice-commits] core.git: Branch 'libreoffice-5-2' - desktop/source include/desktop
Markus Mohrhard
markus.mohrhard at googlemail.com
Sun Dec 11 20:53:37 UTC 2016
desktop/source/app/crashreport.cxx | 34 ++++++++++++++++++++++++++++++----
include/desktop/crashreport.hxx | 4 ++++
2 files changed, 34 insertions(+), 4 deletions(-)
New commits:
commit a2d66138ffa6a5e886bdbb5fe05ee13a0618d27e
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sun Dec 11 00:06:47 2016 +0100
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 at libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
(cherry picked from commit 80049d110a742060acedb89eaad763e66d7f75a5)
Reviewed-on: https://gerrit.libreoffice.org/31851
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/desktop/source/app/crashreport.cxx b/desktop/source/app/crashreport.cxx
index c50c2e9..9715fde 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 e58e387..f4616e8 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;
};
More information about the Libreoffice-commits
mailing list