mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-02 17:09:26 +02:00
Bug 337 - New logger class allows log to be initialized immediately without crashing Mac empty project windows
This is an older one...originally from 2011. Bug says it all, but basically it allows logging to begin immediately upon startup for all platforms. And it has multithreading protection, so it should now be safe to log from the non-GUI threads.
This commit is contained in:
parent
b3afe37889
commit
1fab1cdb21
@ -902,6 +902,7 @@
|
||||
28BD8AB2101DF4C700686679 /* CommandDirectory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 28BD8AAA101DF4C600686679 /* CommandDirectory.cpp */; };
|
||||
28BD8AB3101DF4C700686679 /* ExecMenuCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 28BD8AAC101DF4C600686679 /* ExecMenuCommand.cpp */; };
|
||||
28BD8AB4101DF4C700686679 /* GetAllMenuCommands.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 28BD8AAE101DF4C600686679 /* GetAllMenuCommands.cpp */; };
|
||||
28C3946D1818356800FDDAC9 /* AudacityLogger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 28C3946B1818356800FDDAC9 /* AudacityLogger.cpp */; };
|
||||
28C816BA131255790035BB10 /* Audacity.sh in Install wrapper */ = {isa = PBXBuildFile; fileRef = 28C816B81312555B0035BB10 /* Audacity.sh */; };
|
||||
28CCDD000F939FD70081F2FC /* FileHistory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 28CCDCFF0F939FD70081F2FC /* FileHistory.cpp */; };
|
||||
28D540050FD1912A00FA7C75 /* AppCommandEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 28D53FFA0FD1912A00FA7C75 /* AppCommandEvent.cpp */; };
|
||||
@ -3607,6 +3608,8 @@
|
||||
28BD8AAE101DF4C600686679 /* GetAllMenuCommands.cpp */ = {isa = PBXFileReference; fileEncoding = 5; indentWidth = 3; lastKnownFileType = sourcecode.cpp.cpp; path = GetAllMenuCommands.cpp; sourceTree = "<group>"; tabWidth = 3; };
|
||||
28BD8AAF101DF4C600686679 /* GetAllMenuCommands.h */ = {isa = PBXFileReference; fileEncoding = 5; indentWidth = 3; lastKnownFileType = sourcecode.c.h; path = GetAllMenuCommands.h; sourceTree = "<group>"; tabWidth = 3; };
|
||||
28BD8AB0101DF4C600686679 /* Validators.h */ = {isa = PBXFileReference; fileEncoding = 5; indentWidth = 3; lastKnownFileType = sourcecode.c.h; path = Validators.h; sourceTree = "<group>"; tabWidth = 3; };
|
||||
28C3946B1818356800FDDAC9 /* AudacityLogger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AudacityLogger.cpp; sourceTree = "<group>"; };
|
||||
28C3946C1818356800FDDAC9 /* AudacityLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudacityLogger.h; sourceTree = "<group>"; };
|
||||
28C816B81312555B0035BB10 /* Audacity.sh */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = text.script.sh; name = Audacity.sh; path = mac/Audacity.sh; sourceTree = "<group>"; };
|
||||
28CCDCFF0F939FD70081F2FC /* FileHistory.cpp */ = {isa = PBXFileReference; fileEncoding = 5; indentWidth = 3; lastKnownFileType = sourcecode.cpp.cpp; path = FileHistory.cpp; sourceTree = "<group>"; tabWidth = 3; };
|
||||
28CCDD040F93A0B20081F2FC /* FileHistory.h */ = {isa = PBXFileReference; fileEncoding = 5; indentWidth = 3; lastKnownFileType = sourcecode.c.h; path = FileHistory.h; sourceTree = "<group>"; tabWidth = 3; };
|
||||
@ -4866,6 +4869,8 @@
|
||||
1790AFCE09883BFD008A330A /* AudacityApp.cpp */,
|
||||
1790AFCF09883BFD008A330A /* AudacityApp.h */,
|
||||
1790AFD009883BFD008A330A /* AudacityHeaders.h */,
|
||||
28C3946B1818356800FDDAC9 /* AudacityLogger.cpp */,
|
||||
28C3946C1818356800FDDAC9 /* AudacityLogger.h */,
|
||||
1790AFD209883BFD008A330A /* AudioIO.cpp */,
|
||||
1790AFD309883BFD008A330A /* AudioIO.h */,
|
||||
28560C8F0A75E40F00A3429E /* AutoRecovery.cpp */,
|
||||
@ -8818,6 +8823,7 @@
|
||||
2849A42017F8BEC2005C653F /* KeyView.cpp in Sources */,
|
||||
284FD04217FC72A50009A025 /* ScienFilter.cpp in Sources */,
|
||||
284FD04517FC72EE0009A025 /* Biquad.cpp in Sources */,
|
||||
28C3946D1818356800FDDAC9 /* AudacityLogger.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -58,6 +58,7 @@ It handles initialization and termination by subclassing wxApp.
|
||||
|
||||
#include "AudacityApp.h"
|
||||
|
||||
#include "AudacityLogger.h"
|
||||
#include "AboutDialog.h"
|
||||
#include "AColor.h"
|
||||
#include "AudioIO.h"
|
||||
@ -284,15 +285,6 @@ void QuitAudacity(bool bForce)
|
||||
|
||||
ModuleManager::Dispatch(AppQuiting);
|
||||
|
||||
wxLogWindow *lw = wxGetApp().mLogger;
|
||||
if (lw)
|
||||
{
|
||||
lw->EnableLogging(false);
|
||||
lw->SetActiveTarget(NULL);
|
||||
delete lw;
|
||||
wxGetApp().mLogger = NULL;
|
||||
}
|
||||
|
||||
if (gParentFrame)
|
||||
gParentFrame->Destroy();
|
||||
gParentFrame = NULL;
|
||||
@ -313,6 +305,9 @@ void QuitAudacity(bool bForce)
|
||||
//delete the static lock for audacity projects
|
||||
AudacityProject::DeleteAllProjectsDeleteLock();
|
||||
|
||||
//remove our logger
|
||||
delete wxLog::SetActiveTarget(NULL);
|
||||
|
||||
if (bForce)
|
||||
{
|
||||
wxExit();
|
||||
@ -936,6 +931,11 @@ bool AudacityApp::ShouldShowMissingAliasedFileWarning()
|
||||
return ret;
|
||||
}
|
||||
|
||||
AudacityLogger *AudacityApp::GetLogger()
|
||||
{
|
||||
return wxStaticCast(wxLog::GetActiveTarget(), AudacityLogger);
|
||||
}
|
||||
|
||||
void AudacityApp::InitLang( const wxString & lang )
|
||||
{
|
||||
if( mLocale )
|
||||
@ -1022,6 +1022,8 @@ int AudacityApp::FilterEvent(wxEvent & event)
|
||||
// main frame
|
||||
bool AudacityApp::OnInit()
|
||||
{
|
||||
delete wxLog::SetActiveTarget(new AudacityLogger);
|
||||
|
||||
m_aliasMissingWarningShouldShow = true;
|
||||
m_LastMissingBlockFile = NULL;
|
||||
|
||||
@ -1059,18 +1061,6 @@ bool AudacityApp::OnInit()
|
||||
}
|
||||
#endif
|
||||
|
||||
mLogger=NULL;
|
||||
/* i18n-hint: We translate the title of the log window, but
|
||||
* we're not translating its contents, since the contents will be read by
|
||||
* English speaking engineers */
|
||||
#ifndef __WXMAC__
|
||||
mLogger = new wxLogWindow(NULL, _("Audacity Log"), false, false);
|
||||
mLogger->SetActiveTarget(mLogger);
|
||||
mLogger->EnableLogging(true);
|
||||
mLogger->SetLogLevel(wxLOG_Max);
|
||||
wxLogMessage(wxString::Format(wxT("Audacity %s"), AUDACITY_VERSION_STRING));
|
||||
#endif
|
||||
|
||||
// Unused strings that we want to be translated, even though
|
||||
// we're not using them yet...
|
||||
wxString future1 = _("Master Gain Control");
|
||||
@ -1276,14 +1266,6 @@ bool AudacityApp::OnInit()
|
||||
// So we also call StartMonitoring when STOP is called.
|
||||
project->MayStartMonitoring();
|
||||
|
||||
#ifdef __WXMAC__
|
||||
mLogger = new wxLogWindow(NULL, _("Audacity Log"), false, false);
|
||||
mLogger->SetActiveTarget(mLogger);
|
||||
mLogger->EnableLogging(true);
|
||||
mLogger->SetLogLevel(wxLOG_Max);
|
||||
wxLogMessage(wxString::Format(wxT("Audacity %s"), AUDACITY_VERSION_STRING));
|
||||
#endif
|
||||
|
||||
#ifdef USE_FFMPEG
|
||||
FFmpegStartup();
|
||||
#endif
|
||||
|
@ -33,6 +33,7 @@ class IPCServ;
|
||||
class Importer;
|
||||
class CommandHandler;
|
||||
class AppCommandEvent;
|
||||
class AudacityLogger;
|
||||
|
||||
void SaveWindowSize();
|
||||
|
||||
@ -187,9 +188,9 @@ class AudacityApp:public wxApp {
|
||||
bool GetWindowRectAlreadySaved()const {return mWindowRectAlreadySaved;}
|
||||
void SetWindowRectAlreadySaved(bool alreadySaved) {mWindowRectAlreadySaved = alreadySaved;}
|
||||
|
||||
Importer *mImporter;
|
||||
AudacityLogger *GetLogger();
|
||||
|
||||
wxLogWindow *mLogger;
|
||||
Importer *mImporter;
|
||||
|
||||
#if defined(__WXGTK__)
|
||||
/** \brief This flag is set true when in a keyboard event handler.
|
||||
|
@ -112,8 +112,6 @@ Module::~Module()
|
||||
|
||||
bool Module::Load()
|
||||
{
|
||||
// wxLogNull logNo;
|
||||
|
||||
if (mLib->IsLoaded()) {
|
||||
if (mDispatch) {
|
||||
return true;
|
||||
|
@ -51,6 +51,7 @@ OBJS = \
|
||||
AColor.o \
|
||||
AboutDialog.o \
|
||||
AudacityApp.o \
|
||||
AudacityLogger.o \
|
||||
AudioIO.o \
|
||||
AutoRecovery.o \
|
||||
BatchCommandDialog.o \
|
||||
|
@ -52,6 +52,7 @@ simplifies construction of menu items.
|
||||
#include "effects/EffectManager.h"
|
||||
|
||||
#include "AudacityApp.h"
|
||||
#include "AudacityLogger.h"
|
||||
#include "AudioIO.h"
|
||||
#include "Dependencies.h"
|
||||
#include "float_cast.h"
|
||||
@ -5736,25 +5737,10 @@ void AudacityProject::OnManual()
|
||||
|
||||
void AudacityProject::OnShowLog()
|
||||
{
|
||||
wxLogWindow* pLogger = wxGetApp().mLogger;
|
||||
// It's possible a log window was not created.
|
||||
if( !pLogger )
|
||||
return;
|
||||
wxFrame* pLoggerFrame = pLogger->GetFrame();
|
||||
if (!pLoggerFrame->IsShown())
|
||||
{
|
||||
// Show latest lines.
|
||||
//bool bSuccess = pLoggerFrame->ScrollPages(999); //v Doesn't work!
|
||||
int width, height;
|
||||
pLoggerFrame->GetVirtualSize(&width, &height);
|
||||
//pLoggerFrame->SetScrollPos(wxVERTICAL, height); //v Doesn't work!
|
||||
pLoggerFrame->SetSize(width, 430); // Have to just hope this brings the last into view.
|
||||
|
||||
pLogger->Show();
|
||||
AudacityLogger *logger = wxGetApp().GetLogger();
|
||||
if (logger) {
|
||||
logger->Show();
|
||||
}
|
||||
pLoggerFrame->Enable();
|
||||
pLoggerFrame->Raise();
|
||||
pLoggerFrame->SetFocus();
|
||||
}
|
||||
|
||||
void AudacityProject::OnBenchmark()
|
||||
|
@ -2051,13 +2051,7 @@ void AudacityProject::OnCloseWindow(wxCloseEvent & event)
|
||||
|
||||
if (gAudacityProjects.IsEmpty() && !gIsQuitting) {
|
||||
|
||||
if( wxGetApp().mLogger )
|
||||
wxGetApp().mLogger->Show(false);
|
||||
|
||||
#if !defined(__WXMAC__)
|
||||
// LL: On the Mac, we don't want the logger open after all projects
|
||||
// have been closed since its menu will show instead of the
|
||||
// common menu.
|
||||
if (quitOnClose) {
|
||||
QuitAudacity();
|
||||
}
|
||||
|
@ -431,6 +431,14 @@
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\AudacityLogger.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\AudacityLogger.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\AudioIO.cpp"
|
||||
>
|
||||
|
Loading…
x
Reference in New Issue
Block a user