removed wxApp::DoInit(); added wxApp::CreateMessageOutput(); fixed wxMsgOutput memory leak
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16859 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -121,7 +121,10 @@ wxMSW:
|
|||||||
the include path in your make/project files appropriately. Furthermore,
|
the include path in your make/project files appropriately. Furthermore,
|
||||||
xpm.lib is no longer used by wxMSW, it was superseded by the wxXPMDecoder
|
xpm.lib is no longer used by wxMSW, it was superseded by the wxXPMDecoder
|
||||||
class. You'll need to remove all references to xpm.lib from your
|
class. You'll need to remove all references to xpm.lib from your
|
||||||
make/project files.
|
make/project files. Finally, the library names have changed as well and now
|
||||||
|
use the following consistent naming convention: wxmsw[u][d][ver].(lib|dll)
|
||||||
|
where 'u' appears for Unicode version, 'd' -- for the debug one and version
|
||||||
|
is only present for the DLLs builds.
|
||||||
|
|
||||||
- child frames appear in the taskbar by default now, use wxFRAME_NO_TASKBAR
|
- child frames appear in the taskbar by default now, use wxFRAME_NO_TASKBAR
|
||||||
style to avoid it
|
style to avoid it
|
||||||
@@ -226,12 +229,12 @@ All (GUI):
|
|||||||
- Added wxMouseCaptureChangedEvent
|
- Added wxMouseCaptureChangedEvent
|
||||||
- Added custom character filtering to wxTextValidator
|
- Added custom character filtering to wxTextValidator
|
||||||
- wxTreeCtrl now supports incremental keyboard search
|
- wxTreeCtrl now supports incremental keyboard search
|
||||||
|
- wxMessageOutput class added
|
||||||
- wxHelpProvider::RemoveHelp added and called from ~wxWindowBase
|
- wxHelpProvider::RemoveHelp added and called from ~wxWindowBase
|
||||||
so that erroneous help strings are no longer found as the hash
|
so that erroneous help strings are no longer found as the hash
|
||||||
table fills up
|
table fills up
|
||||||
- updated libpng from 1.0.3 to 1.2.4
|
- updated libpng from 1.0.3 to 1.2.4
|
||||||
- Added wxView::OnClosingDocument so the application can do
|
- Added wxView::OnClosingDocument so the application can do cleanup.
|
||||||
cleanup.
|
|
||||||
- generic wxListCtrl renamed to wxGenericListCtrl, wxImageList
|
- generic wxListCtrl renamed to wxGenericListCtrl, wxImageList
|
||||||
renamed to wxGenericImageList, so they can be used on wxMSW
|
renamed to wxGenericImageList, so they can be used on wxMSW
|
||||||
(Rene Rivera).
|
(Rene Rivera).
|
||||||
|
@@ -43,16 +43,15 @@ class WXDLLEXPORT wxCmdLineParser;
|
|||||||
#include "wx/window.h" // for wxTopLevelWindows
|
#include "wx/window.h" // for wxTopLevelWindows
|
||||||
#endif // wxUSE_GUI
|
#endif // wxUSE_GUI
|
||||||
|
|
||||||
#if wxUSE_LOG
|
|
||||||
#include "wx/log.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if WXWIN_COMPATIBILITY_2_2
|
#if WXWIN_COMPATIBILITY_2_2
|
||||||
#include "wx/icon.h"
|
#include "wx/icon.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/build.h"
|
#include "wx/build.h"
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxLog;
|
||||||
|
class WXDLLEXPORT wxMessageOutput;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// constants
|
// constants
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -108,10 +107,6 @@ public:
|
|||||||
// Override: always in GUI application, rarely in console ones.
|
// Override: always in GUI application, rarely in console ones.
|
||||||
virtual bool OnInit();
|
virtual bool OnInit();
|
||||||
|
|
||||||
// initializes wxMessageOutput; other responsibilities
|
|
||||||
// may be added later
|
|
||||||
virtual void DoInit();
|
|
||||||
|
|
||||||
#if wxUSE_GUI
|
#if wxUSE_GUI
|
||||||
// a platform-dependent version of OnInit(): the code here is likely to
|
// a platform-dependent version of OnInit(): the code here is likely to
|
||||||
// depend on the toolkit. default version does nothing.
|
// depend on the toolkit. default version does nothing.
|
||||||
@@ -282,14 +277,13 @@ public:
|
|||||||
// user-defined class (default implementation creates a wxLogGui
|
// user-defined class (default implementation creates a wxLogGui
|
||||||
// object) - this log object is used by default by all wxLogXXX()
|
// object) - this log object is used by default by all wxLogXXX()
|
||||||
// functions.
|
// functions.
|
||||||
virtual wxLog *CreateLogTarget()
|
virtual wxLog *CreateLogTarget();
|
||||||
#if wxUSE_GUI && wxUSE_LOGGUI && !defined(__WXMICROWIN__)
|
|
||||||
{ return new wxLogGui; }
|
|
||||||
#else // !GUI
|
|
||||||
{ return new wxLogStderr; }
|
|
||||||
#endif // wxUSE_GUI
|
|
||||||
#endif // wxUSE_LOG
|
#endif // wxUSE_LOG
|
||||||
|
|
||||||
|
// similar to CreateLogTarget() but for the global wxMessageOutput
|
||||||
|
// object
|
||||||
|
virtual wxMessageOutput *CreateMessageOutput();
|
||||||
|
|
||||||
#if wxUSE_GUI
|
#if wxUSE_GUI
|
||||||
|
|
||||||
#if WXWIN_COMPATIBILITY_2_2
|
#if WXWIN_COMPATIBILITY_2_2
|
||||||
|
@@ -32,6 +32,9 @@
|
|||||||
#include "wx/app.h"
|
#include "wx/app.h"
|
||||||
#include "wx/intl.h"
|
#include "wx/intl.h"
|
||||||
#include "wx/list.h"
|
#include "wx/list.h"
|
||||||
|
#if wxUSE_LOG
|
||||||
|
#include "wx/log.h"
|
||||||
|
#endif // wxUSE_LOG
|
||||||
#if wxUSE_GUI
|
#if wxUSE_GUI
|
||||||
#include "wx/msgdlg.h"
|
#include "wx/msgdlg.h"
|
||||||
#endif // wxUSE_GUI
|
#endif // wxUSE_GUI
|
||||||
@@ -153,9 +156,49 @@ int wxAppBase::OnExit()
|
|||||||
delete wxTheme::Set(NULL);
|
delete wxTheme::Set(NULL);
|
||||||
#endif // __WXUNIVERSAL__
|
#endif // __WXUNIVERSAL__
|
||||||
|
|
||||||
|
// use Set(NULL) and not Get() to avoid creating a message output object on
|
||||||
|
// demand when we just want to delete it
|
||||||
|
delete wxMessageOutput::Set(NULL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// customization hooks
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#if wxUSE_LOG
|
||||||
|
|
||||||
|
wxLog *wxAppBase::CreateLogTarget()
|
||||||
|
{
|
||||||
|
#if wxUSE_GUI && wxUSE_LOGGUI && !defined(__WXMICROWIN__)
|
||||||
|
return new wxLogGui;
|
||||||
|
#else // !GUI
|
||||||
|
return new wxLogStderr;
|
||||||
|
#endif // wxUSE_GUI
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // wxUSE_LOG
|
||||||
|
|
||||||
|
wxMessageOutput *wxAppBase::CreateMessageOutput()
|
||||||
|
{
|
||||||
|
// The standard way of printing help on command line arguments (app --help)
|
||||||
|
// is (according to common practice):
|
||||||
|
// - console apps: to stderr (on any platform)
|
||||||
|
// - GUI apps: stderr on Unix platforms (!)
|
||||||
|
// message box under Windows and others
|
||||||
|
#if wxUSE_GUI && !defined(__UNIX__)
|
||||||
|
// wxMessageOutputMessageBox doesn't work under Motif
|
||||||
|
#ifdef __WXMOTIF__
|
||||||
|
return new wxMessageOutputLog;
|
||||||
|
#else
|
||||||
|
return new wxMessageOutputMessageBox;
|
||||||
|
#endif
|
||||||
|
#else // !wxUSE_GUI || __UNIX__
|
||||||
|
return new wxMessageOutputStderr;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// wxAppBase
|
// wxAppBase
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -217,34 +260,12 @@ int wxAppBase::FilterEvent(wxEvent& WXUNUSED(event))
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxAppBase::DoInit()
|
|
||||||
{
|
|
||||||
if (wxMessageOutput::Get())
|
|
||||||
return;
|
|
||||||
|
|
||||||
// NB: The standard way of printing help on command line arguments (app --help)
|
|
||||||
// is (according to common practice):
|
|
||||||
// - console apps: to stderr (on any platform)
|
|
||||||
// - GUI apps: stderr on Unix platforms (!)
|
|
||||||
// message box under Windows and others
|
|
||||||
#if wxUSE_GUI && !defined(__UNIX__)
|
|
||||||
#ifdef __WXMOTIF__
|
|
||||||
wxMessageOutput::Set(new wxMessageOutputLog);
|
|
||||||
#else
|
|
||||||
wxMessageOutput::Set(new wxMessageOutputMessageBox);
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
wxMessageOutput::Set(new wxMessageOutputStderr);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// cmd line parsing
|
// cmd line parsing
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool wxAppBase::OnInit()
|
bool wxAppBase::OnInit()
|
||||||
{
|
{
|
||||||
DoInit();
|
|
||||||
#if wxUSE_CMDLINE_PARSER
|
#if wxUSE_CMDLINE_PARSER
|
||||||
wxCmdLineParser parser(argc, argv);
|
wxCmdLineParser parser(argc, argv);
|
||||||
|
|
||||||
|
@@ -50,16 +50,11 @@ wxMessageOutput* wxMessageOutput::ms_msgOut = 0;
|
|||||||
|
|
||||||
wxMessageOutput* wxMessageOutput::Get()
|
wxMessageOutput* wxMessageOutput::Get()
|
||||||
{
|
{
|
||||||
// FIXME this is an hack
|
if ( !ms_msgOut && wxTheApp )
|
||||||
static bool inGet = FALSE;
|
|
||||||
|
|
||||||
if(!ms_msgOut && wxTheApp && !inGet)
|
|
||||||
{
|
{
|
||||||
inGet = TRUE;
|
ms_msgOut = wxTheApp->CreateMessageOutput();
|
||||||
wxTheApp->DoInit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inGet = FALSE;
|
|
||||||
return ms_msgOut;
|
return ms_msgOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,15 +110,15 @@ void wxMessageOutputMessageBox::Printf(const wxChar* format, ...)
|
|||||||
|
|
||||||
void wxMessageOutputLog::Printf(const wxChar* format, ...)
|
void wxMessageOutputLog::Printf(const wxChar* format, ...)
|
||||||
{
|
{
|
||||||
|
wxString out;
|
||||||
|
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
wxString out;
|
|
||||||
|
|
||||||
out.PrintfV(format, args);
|
out.PrintfV(format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
out.Replace(wxT("\t"),wxT(" "));
|
out.Replace(wxT("\t"),wxT(" "));
|
||||||
// under Motif, wxMessageDialog needs a parent window, so we use
|
|
||||||
// wxLog, which is better than nothing
|
|
||||||
::wxLogMessage(wxT("%s"), out.c_str());
|
::wxLogMessage(wxT("%s"), out.c_str());
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user