mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-16 16:10:06 +02:00
Remove AudacityApp::GetLogger() & HelpActions::DoShowLog()
This commit is contained in:
parent
e845bd9544
commit
8da6529329
@ -831,13 +831,6 @@ locations of the missing files."), missingFileName);
|
||||
}
|
||||
}
|
||||
|
||||
AudacityLogger *AudacityApp::GetLogger()
|
||||
{
|
||||
// Use dynamic_cast so that we get a NULL ptr if we haven't yet
|
||||
// setup our logger.
|
||||
return dynamic_cast<AudacityLogger *>(wxLog::GetActiveTarget());
|
||||
}
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
#define WL(lang, sublang) (lang), (sublang),
|
||||
#else
|
||||
@ -944,7 +937,7 @@ void AudacityApp::GenerateCrashReport(wxDebugReport::Context ctx)
|
||||
#endif
|
||||
}
|
||||
|
||||
AudacityLogger *logger = GetLogger();
|
||||
auto logger = AudacityLogger::Get();
|
||||
if (logger)
|
||||
{
|
||||
rpt.AddText(wxT("log.txt"), logger->GetLog(), _TS("Audacity Log"));
|
||||
@ -1051,11 +1044,8 @@ bool AudacityApp::OnInit()
|
||||
// Ensure we have an event loop during initialization
|
||||
wxEventLoopGuarantor eventLoop;
|
||||
|
||||
// wxWidgets will clean up the logger for the main thread, so we can say
|
||||
// safenew. See:
|
||||
// http://docs.wxwidgets.org/3.0/classwx_log.html#a2525bf54fa3f31dc50e6e3cd8651e71d
|
||||
std::unique_ptr < wxLog >
|
||||
{ wxLog::SetActiveTarget(safenew AudacityLogger) }; // DELETE old
|
||||
// cause initialization of wxWidgets' global logger target
|
||||
(void) AudacityLogger::Get();
|
||||
|
||||
#if defined(__WXMAC__)
|
||||
// Disable window animation
|
||||
|
@ -36,7 +36,6 @@ class IPCServ;
|
||||
class Importer;
|
||||
class CommandHandler;
|
||||
class AppCommandEvent;
|
||||
class AudacityLogger;
|
||||
class AudacityProject;
|
||||
|
||||
class AliasBlockFile;
|
||||
@ -93,8 +92,6 @@ class AudacityApp final : public wxApp {
|
||||
void AssociateFileTypes();
|
||||
#endif
|
||||
|
||||
AudacityLogger *GetLogger();
|
||||
|
||||
#if defined(EXPERIMENTAL_CRASH_REPORT)
|
||||
void GenerateCrashReport(wxDebugReport::Context ctx);
|
||||
#endif
|
||||
|
@ -22,6 +22,7 @@ Provides thread-safe logging based on the wxWidgets log facility.
|
||||
#include "FileNames.h"
|
||||
#include "ShuttleGui.h"
|
||||
|
||||
#include <mutex>
|
||||
#include <wx/filedlg.h>
|
||||
#include <wx/log.h>
|
||||
#include <wx/frame.h>
|
||||
@ -50,6 +51,22 @@ enum
|
||||
LoggerID_Close
|
||||
};
|
||||
|
||||
AudacityLogger *AudacityLogger::Get()
|
||||
{
|
||||
static std::once_flag flag;
|
||||
std::call_once( flag, []{
|
||||
// wxWidgets will clean up the logger for the main thread, so we can say
|
||||
// safenew. See:
|
||||
// http://docs.wxwidgets.org/3.0/classwx_log.html#a2525bf54fa3f31dc50e6e3cd8651e71d
|
||||
std::unique_ptr < wxLog > // DELETE any previous logger
|
||||
{ wxLog::SetActiveTarget(safenew AudacityLogger) };
|
||||
} );
|
||||
|
||||
// Use dynamic_cast so that we get a NULL ptr in case our logger
|
||||
// is no longer the target.
|
||||
return dynamic_cast<AudacityLogger *>(wxLog::GetActiveTarget());
|
||||
}
|
||||
|
||||
AudacityLogger::AudacityLogger()
|
||||
: wxEvtHandler(),
|
||||
wxLog()
|
||||
|
@ -27,7 +27,9 @@ class wxTextCtrl;
|
||||
|
||||
class AudacityLogger final : public wxEvtHandler, public wxLog {
|
||||
public:
|
||||
AudacityLogger();
|
||||
|
||||
// Get the singleton instance or null
|
||||
static AudacityLogger *Get();
|
||||
|
||||
void Show(bool show = true);
|
||||
|
||||
@ -40,6 +42,8 @@ class AudacityLogger final : public wxEvtHandler, public wxLog {
|
||||
void DoLogText(const wxString & msg) override;
|
||||
|
||||
private:
|
||||
AudacityLogger();
|
||||
|
||||
void OnCloseWindow(wxCloseEvent & e);
|
||||
void OnClose(wxCommandEvent & e);
|
||||
void OnClear(wxCommandEvent & e);
|
||||
|
@ -180,7 +180,6 @@ bool DoAudacityCommand(
|
||||
/// Namespace for functions for Help menu
|
||||
namespace HelpActions {
|
||||
void DoHelpWelcome( AudacityProject & );
|
||||
void DoShowLog( AudacityProject& );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -75,14 +75,6 @@ namespace HelpActions {
|
||||
|
||||
// exported helper functions
|
||||
|
||||
void DoShowLog( AudacityProject & )
|
||||
{
|
||||
AudacityLogger *logger = wxGetApp().GetLogger();
|
||||
if (logger) {
|
||||
logger->Show();
|
||||
}
|
||||
}
|
||||
|
||||
void DoHelpWelcome( AudacityProject &project )
|
||||
{
|
||||
SplashDialog::Show2( &project );
|
||||
@ -135,7 +127,10 @@ void OnMidiDeviceInfo(const CommandContext &context)
|
||||
|
||||
void OnShowLog( const CommandContext &context )
|
||||
{
|
||||
DoShowLog( context.project );
|
||||
auto logger = AudacityLogger::Get();
|
||||
if (logger) {
|
||||
logger->Show();
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(EXPERIMENTAL_CRASH_REPORT)
|
||||
|
@ -21,8 +21,6 @@ for each problem encountered, since there can be many orphans.
|
||||
#include "../Audacity.h"
|
||||
#include "MultiDialog.h"
|
||||
|
||||
#include "../Project.h"
|
||||
|
||||
#include <wx/app.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/dialog.h>
|
||||
@ -34,7 +32,7 @@ for each problem encountered, since there can be many orphans.
|
||||
#include <wx/artprov.h>
|
||||
#include <wx/radiobox.h>
|
||||
|
||||
#include "../Menus.h"
|
||||
#include "../AudacityLogger.h"
|
||||
#include "wxPanelWrapper.h"
|
||||
|
||||
class MultiDialog final : public wxDialogWrapper
|
||||
@ -153,8 +151,10 @@ void MultiDialog::OnOK(wxCommandEvent & WXUNUSED(event))
|
||||
|
||||
void MultiDialog::OnShowLog(wxCommandEvent & WXUNUSED(event))
|
||||
{
|
||||
auto project = GetActiveProject();
|
||||
HelpActions::DoShowLog(*project);
|
||||
auto logger = AudacityLogger::Get();
|
||||
if (logger) {
|
||||
logger->Show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user