Audacity 3.2.0
CrashReport.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 CrashReport.cpp
6
7 *//*******************************************************************/
8
9
10#include "CrashReport.h"
11
12#if defined(HAS_CRASH_REPORT)
13#include <atomic>
14#include <thread>
15
16#if defined(__WXMSW__)
17#include <wx/evtloop.h>
18#endif
19
20#include "wxFileNameWrapper.h"
21#include "ActiveProject.h"
22#include "AudacityLogger.h"
23#include "AudioIOBase.h"
24#include "AudioIOExt.h"
25#include "BasicUI.h"
26#include "FileNames.h"
27#include "Internat.h"
28#include "Languages.h"
29#include "Project.h"
30#include "ProjectFileIO.h"
31#include "prefs/GUISettings.h"
33
34namespace CrashReport {
35
36void Generate(wxDebugReport::Context ctx)
37{
38 wxDebugReportCompress rpt;
39
40 // Bug 1927: Seems there problems with wxStackWalker, so don't even include
41 // the stack trace or memory dump. The former is pretty much useless in Release
42 // builds anyway and none of use have the skill/time/desire to fiddle with the
43 // latter.
44 // rpt.AddAll(ctx);
45
46 {
47 // Provides a progress dialog with indeterminate mode
48 using namespace BasicUI;
49 auto pd = MakeGenericProgress({},
50 XO("Audacity Support Data"), XO("This may take several seconds"));
51 wxASSERT(pd);
52
53 std::atomic_bool done = {false};
54 auto thread = std::thread([&]
55 {
57 rpt.AddFile(fn.GetFullPath(), _TS("Audacity Configuration"));
58 rpt.AddFile(FileNames::PluginRegistry(), wxT("Plugin Registry"));
59 rpt.AddFile(FileNames::PluginSettings(), wxT("Plugin Settings"));
60
61 if (ctx == wxDebugReport::Context_Current)
62 {
63 auto saveLang = Languages::GetLangShort();
65 auto cleanup = finally( [&]{ GUISettings::SetLang( saveLang ); } );
66
67 auto gAudioIO = AudioIOBase::Get();
68 for (const auto &diagnostics : gAudioIO->GetAllDeviceInfo())
69 rpt.AddText(
70 diagnostics.filename, diagnostics.text, diagnostics.description);
71 auto project = GetActiveProject().lock();
72 if (project) {
73 auto &projectFileIO = ProjectFileIO::Get( *project );
74 rpt.AddText(wxT("project.txt"), projectFileIO.GenerateDoc(), wxT("Active project doc"));
75 }
76 }
77
78 auto logger = AudacityLogger::Get();
79 if (logger)
80 {
81 rpt.AddText(wxT("log.txt"), logger->GetLog(), _TS("Audacity Log"));
82 }
83
84 done = true;
85 });
86
87 // Wait for information to be gathered
88 while (!done)
89 {
90 using namespace std::chrono;
91 std::this_thread::sleep_for(50ms);
92 pd->Pulse();
93 }
94 thread.join();
95 }
96
97 bool ok = wxDebugReportPreviewStd().Show(rpt);
98
99#if defined(__WXMSW__)
100 wxEventLoop::SetCriticalWindow(NULL);
101#endif
102
103 if (ok && rpt.Process())
104 {
105 AudacityTextEntryDialog dlg(nullptr,
106 XO("Report generated to:"),
107 XO("Audacity Support Data"),
108 rpt.GetCompressedFileName(),
109 wxOK | wxCENTER);
110 dlg.SetName(dlg.GetTitle());
111 dlg.ShowModal();
112
113 wxLogMessage(wxT("Report generated to: %s"),
114 rpt.GetCompressedFileName());
115
116 rpt.Reset();
117 }
118}
119
120}
121#endif
AUDACITY_DLL_API std::weak_ptr< AudacityProject > GetActiveProject()
Handle changing of active project and keep global project pointer.
wxT("CloseDown"))
Abstract base class for hooks into audio playback procedures.
Toolkit-neutral facade for basic user interface services.
XO("Cut/Copy/Paste")
#define _TS(s)
Definition: Internat.h:27
const auto project
static const auto fn
static AudacityLogger * Get()
Wrap wxTextEntryDialog so that caption IS translatable.
static AudioIOBase * Get()
Definition: AudioIOBase.cpp:94
static ProjectFileIO & Get(AudacityProject &project)
std::unique_ptr< GenericProgressDialog > MakeGenericProgress(const WindowPlacement &placement, const TranslatableString &title, const TranslatableString &message, int style=(ProgressAppModal|ProgressShowElapsedTime|ProgressSmooth))
Create and display a progress dialog (return nullptr if Services not installed)
Definition: BasicUI.h:320
FILES_API FilePath Configuration()
FILES_API FilePath PluginRegistry()
FILES_API FilePath PluginSettings()
AUDACITY_DLL_API wxString SetLang(const wxString &lang)
Definition: GUISettings.cpp:19
wxString GetLangShort()
Definition: Languages.cpp:403