made definition of wxUSE_LOG_DEBUG dependent on wxDEBUG_LEVEL and added wxUSE_LOG_TRACE (currently never enabled by default); fix warnings about unused variables after these changes

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59736 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2009-03-22 17:18:07 +00:00
parent 8a9464893a
commit 711f12ef2e
9 changed files with 174 additions and 193 deletions

View File

@ -40,8 +40,8 @@ public:
wxDataFormat GetMatchingPair(); wxDataFormat GetMatchingPair();
// implementation // implementation
GdkAtom GtkGetMatchingPair(); GdkAtom GtkGetMatchingPair(bool quiet = false);
void GtkRegisterWidget( GtkWidget *widget ); void GtkRegisterWidget( GtkWidget *widget );
void GtkUnregisterWidget( GtkWidget *widget ); void GtkUnregisterWidget( GtkWidget *widget );

View File

@ -57,7 +57,7 @@ public:
// implementation // implementation
GdkAtom GetMatchingPair(); GdkAtom GetMatchingPair(bool quiet = false);
void RegisterWidget( GtkWidget *widget ); void RegisterWidget( GtkWidget *widget );
void UnregisterWidget( GtkWidget *widget ); void UnregisterWidget( GtkWidget *widget );

View File

@ -55,6 +55,7 @@ typedef unsigned long wxLogLevel;
#include "wx/dynarray.h" #include "wx/dynarray.h"
// wxUSE_LOG_DEBUG enables the debug log messages
#ifndef wxUSE_LOG_DEBUG #ifndef wxUSE_LOG_DEBUG
#if wxDEBUG_LEVEL #if wxDEBUG_LEVEL
#define wxUSE_LOG_DEBUG 1 #define wxUSE_LOG_DEBUG 1
@ -63,6 +64,15 @@ typedef unsigned long wxLogLevel;
#endif #endif
#endif #endif
// wxUSE_LOG_TRACE enables the trace messages, they are disabled by default
#ifndef wxUSE_LOG_TRACE
#if wxDEBUG_LEVEL >= 2
#define wxUSE_LOG_TRACE 1
#else // wxDEBUG_LEVEL < 2
#define wxUSE_LOG_TRACE 0
#endif
#endif // wxUSE_LOG_TRACE
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// forward declarations // forward declarations
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -353,7 +363,8 @@ private:
// "trivial" derivations of wxLog // "trivial" derivations of wxLog
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// log everything to a buffer // log everything except for the debug/trace messages (which are passed to
// wxMessageOutputDebug) to a buffer
class WXDLLIMPEXP_BASE wxLogBuffer : public wxLog class WXDLLIMPEXP_BASE wxLogBuffer : public wxLog
{ {
public: public:
@ -367,10 +378,14 @@ public:
virtual void Flush(); virtual void Flush();
protected: protected:
#if wxUSE_LOG_DEBUG || wxUSE_LOG_TRACE
virtual void DoLog(wxLogLevel level, const wxString& szString, time_t t); virtual void DoLog(wxLogLevel level, const wxString& szString, time_t t);
virtual void DoLogString(const wxString& szString, time_t t);
wxSUPPRESS_DOLOG_HIDE_WARNING() wxSUPPRESS_DOLOG_HIDE_WARNING()
#endif // wxUSE_LOG_DEBUG || wxUSE_LOG_TRACE
virtual void DoLogString(const wxString& szString, time_t t);
wxSUPPRESS_DOLOGSTRING_HIDE_WARNING() wxSUPPRESS_DOLOGSTRING_HIDE_WARNING()
private: private:
@ -626,6 +641,12 @@ WXDLLIMPEXP_BASE const wxChar* wxSysErrorMsg(unsigned long nErrCode = 0);
#else // !wxUSE_LOG #else // !wxUSE_LOG
#undef wxUSE_LOG_DEBUG
#define wxUSE_LOG_DEBUG 0
#undef wxUSE_LOG_TRACE
#define wxUSE_LOG_TRACE 0
#ifdef __WATCOMC__ #ifdef __WATCOMC__
// workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351 // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
#define WX_WATCOM_ONLY_CODE( x ) x #define WX_WATCOM_ONLY_CODE( x ) x
@ -722,14 +743,42 @@ DECLARE_LOG_FUNCTION2(SysError, long, lErrCode);
DECLARE_LOG_FUNCTION2(SysError, unsigned long, lErrCode); DECLARE_LOG_FUNCTION2(SysError, unsigned long, lErrCode);
#endif #endif
// debug functions do nothing in release mode
#if wxUSE_LOG && wxUSE_LOG_DEBUG // debug functions can be completely disabled in optimized builds
// if these log functions are disabled, we prefer to define them as (empty)
// variadic macros as this completely removes them and their argument
// evaluation from the object code but if this is not supported by compiler we
// use empty inline functions instead (defining them as nothing would result in
// compiler warnings)
//
// note that making wxVLogDebug/Trace() themselves (empty inline) functions is
// a bad idea as some compilers are stupid enough to not inline even empty
// functions if their parameters are complicated enough, but by defining them
// as an empty inline function we ensure that even dumbest compilers optimise
// them away
#ifdef __BORLANDC__
// but Borland gives "W8019: Code has no effect" for wxLogNop() so we need
// to define it differently for it to avoid these warnings (same problem as
// with wxUnusedVar())
#define wxLogNop() { }
#else
inline void wxLogNop() { }
#endif
#if wxUSE_LOG_DEBUG
DECLARE_LOG_FUNCTION(Debug); DECLARE_LOG_FUNCTION(Debug);
#else // !wxUSE_LOG_DEBUG
#define wxVLogDebug(fmt, valist) wxLogNop()
// there is no more unconditional LogTrace: it is not different from #ifdef HAVE_VARIADIC_MACROS
// LogDebug and it creates overload ambiguities #define wxLogDebug(fmt, ...) wxLogNop()
//DECLARE_LOG_FUNCTION(Trace); #else // !HAVE_VARIADIC_MACROS
WX_DEFINE_VARARG_FUNC_NOP(wxLogDebug, 1, (const wxString&))
#endif
#endif // wxUSE_LOG_DEBUG/!wxUSE_LOG_DEBUG
#if wxUSE_LOG_TRACE
// this version only logs the message if the mask had been added to the // this version only logs the message if the mask had been added to the
// list of masks with AddTraceMask() // list of masks with AddTraceMask()
DECLARE_LOG_FUNCTION2(Trace, const wxString&, mask); DECLARE_LOG_FUNCTION2(Trace, const wxString&, mask);
@ -744,44 +793,18 @@ DECLARE_LOG_FUNCTION2(SysError, unsigned long, lErrCode);
// string identifiers // string identifiers
#if WXWIN_COMPATIBILITY_2_8 #if WXWIN_COMPATIBILITY_2_8
DECLARE_LOG_FUNCTION2(Trace, wxTraceMask, mask); DECLARE_LOG_FUNCTION2(Trace, wxTraceMask, mask);
#endif // wxDEBUG_LEVEL
#ifdef __WATCOMC__ #ifdef __WATCOMC__
// workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351 // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
DECLARE_LOG_FUNCTION2(Trace, int, mask); DECLARE_LOG_FUNCTION2(Trace, int, mask);
#endif #endif
#else //!debug || !wxUSE_LOG #endif // WXWIN_COMPATIBILITY_2_8
// these functions do nothing in release builds, but don't define them as
// nothing as it could result in different code structure in debug and
// release and this could result in trouble when these macros are used
// inside if/else
//
// note that making wxVLogDebug/Trace() themselves (empty inline) functions
// is a bad idea as some compilers are stupid enough to not inline even
// empty functions if their parameters are complicated enough, but by
// defining them as an empty inline function we ensure that even dumbest
// compilers optimise them away
#ifdef __BORLANDC__
// but Borland gives "W8019: Code has no effect" for wxLogNop() so we need
// to define it differently for it to avoid these warnings (same problem as
// with wxUnusedVar())
#define wxLogNop() { }
#else
inline void wxLogNop() { }
#endif
#define wxVLogDebug(fmt, valist) wxLogNop() #else // !wxUSE_LOG_TRACE
#define wxVLogTrace(mask, fmt, valist) wxLogNop() #define wxVLogTrace(mask, fmt, valist) wxLogNop()
#ifdef HAVE_VARIADIC_MACROS #ifdef HAVE_VARIADIC_MACROS
// unlike the inline functions below, this completely removes the
// wxLogXXX calls from the object file:
#define wxLogDebug(fmt, ...) wxLogNop()
#define wxLogTrace(mask, fmt, ...) wxLogNop() #define wxLogTrace(mask, fmt, ...) wxLogNop()
#else // !HAVE_VARIADIC_MACROS #else // !HAVE_VARIADIC_MACROS
//inline void wxLogDebug(const wxString& fmt, ...) {}
WX_DEFINE_VARARG_FUNC_NOP(wxLogDebug, 1, (const wxString&))
//inline void wxLogTrace(wxTraceMask, const wxString& fmt, ...) {}
//inline void wxLogTrace(const wxString&, const wxString& fmt, ...) {}
WX_DEFINE_VARARG_FUNC_NOP(wxLogTrace, 2, (wxTraceMask, const wxString&)) WX_DEFINE_VARARG_FUNC_NOP(wxLogTrace, 2, (wxTraceMask, const wxString&))
WX_DEFINE_VARARG_FUNC_NOP(wxLogTrace, 2, (const wxString&, const wxString&)) WX_DEFINE_VARARG_FUNC_NOP(wxLogTrace, 2, (const wxString&, const wxString&))
#ifdef __WATCOMC__ #ifdef __WATCOMC__
@ -790,7 +813,7 @@ DECLARE_LOG_FUNCTION2(SysError, unsigned long, lErrCode);
WX_DEFINE_VARARG_FUNC_NOP(wxLogTrace, 2, (const wchar_t*, const wchar_t*)) WX_DEFINE_VARARG_FUNC_NOP(wxLogTrace, 2, (const wchar_t*, const wchar_t*))
#endif #endif
#endif // HAVE_VARIADIC_MACROS/!HAVE_VARIADIC_MACROS #endif // HAVE_VARIADIC_MACROS/!HAVE_VARIADIC_MACROS
#endif // debug/!debug #endif // wxUSE_LOG_TRACE/!wxUSE_LOG_TRACE
#if defined(__VISUALC__) && __VISUALC__ < 1300 #if defined(__VISUALC__) && __VISUALC__ < 1300
#pragma warning(default:4003) #pragma warning(default:4003)

View File

@ -260,47 +260,42 @@ void wxDoLogVerboseUtf8(const char *format, ...)
} }
#endif // wxUSE_UNICODE_UTF8 #endif // wxUSE_UNICODE_UTF8
// debug functions // ----------------------------------------------------------------------------
#ifdef __WXDEBUG__ // debug and trace functions
// ----------------------------------------------------------------------------
#if wxUSE_LOG_DEBUG
void wxVLogDebug(const wxString& format, va_list argptr)
{
if ( wxLog::IsEnabled() )
{
wxLog::OnLog(wxLOG_Debug,
wxString::FormatV(format, argptr), time(NULL));
}
}
#if !wxUSE_UTF8_LOCALE_ONLY #if !wxUSE_UTF8_LOCALE_ONLY
#define IMPLEMENT_LOG_DEBUG_FUNCTION_WCHAR(level) \ void wxDoLogDebugWchar(const wxChar *format, ...)
void wxDoLog##level##Wchar(const wxChar *format, ...) \ {
{ \ va_list argptr;
va_list argptr; \ va_start(argptr, format);
va_start(argptr, format); \ wxVLogDebug(format, argptr);
wxVLog##level(format, argptr); \ va_end(argptr);
va_end(argptr); \ }
} #endif // !wxUSE_UTF8_LOCALE_ONLY
#else
#define IMPLEMENT_LOG_DEBUG_FUNCTION_WCHAR(level)
#endif
#if wxUSE_UNICODE_UTF8 #if wxUSE_UNICODE_UTF8
#define IMPLEMENT_LOG_DEBUG_FUNCTION_UTF8(level) \ void wxDoLogDebugUtf8(const char *format, ...)
void wxDoLog##level##Utf8(const char *format, ...) \ {
{ \ va_list argptr;
va_list argptr; \ va_start(argptr, format);
va_start(argptr, format); \ wxVLogDebug(format, argptr);
wxVLog##level(format, argptr); \ va_end(argptr);
va_end(argptr); \ }
} #endif // wxUSE_UNICODE_UTF8
#else #endif // wxUSE_LOG_DEBUG
#define IMPLEMENT_LOG_DEBUG_FUNCTION_UTF8(level)
#endif
#define IMPLEMENT_LOG_DEBUG_FUNCTION(level) \
void wxVLog##level(const wxString& format, va_list argptr) \
{ \
if ( wxLog::IsEnabled() ) { \
wxLog::OnLog(wxLOG_##level, \
wxString::FormatV(format, argptr), time(NULL)); \
} \
} \
IMPLEMENT_LOG_DEBUG_FUNCTION_WCHAR(level) \
IMPLEMENT_LOG_DEBUG_FUNCTION_UTF8(level)
#if wxUSE_LOG_TRACE
void wxVLogTrace(const wxString& mask, const wxString& format, va_list argptr) void wxVLogTrace(const wxString& mask, const wxString& format, va_list argptr)
{ {
if ( wxLog::IsEnabled() && wxLog::IsAllowedTraceMask(mask) ) { if ( wxLog::IsEnabled() && wxLog::IsAllowedTraceMask(mask) ) {
@ -403,13 +398,8 @@ void wxDoLogVerboseUtf8(const char *format, ...)
void wxVLogTrace(const wchar_t *mask, const wxString& format, va_list argptr) void wxVLogTrace(const wchar_t *mask, const wxString& format, va_list argptr)
{ wxVLogTrace(wxString(mask), format, argptr); } { wxVLogTrace(wxString(mask), format, argptr); }
#endif // __WATCOMC__ #endif // __WATCOMC__
#endif // wxUSE_LOG_TRACE
#else // release
#define IMPLEMENT_LOG_DEBUG_FUNCTION(level)
#endif
IMPLEMENT_LOG_DEBUG_FUNCTION(Debug)
IMPLEMENT_LOG_DEBUG_FUNCTION(Trace)
// wxLogSysError: one uses the last error code, for other you must give it // wxLogSysError: one uses the last error code, for other you must give it
// explicitly // explicitly
@ -730,17 +720,32 @@ void wxLog::DoLog(wxLogLevel level, const wxString& szString, time_t t)
LogString(szString, t); LogString(szString, t);
break; break;
#if wxUSE_LOG_DEBUG || wxUSE_LOG_TRACE
#if wxUSE_LOG_TRACE
case wxLOG_Trace: case wxLOG_Trace:
#endif
#if wxUSE_LOG_DEBUG
case wxLOG_Debug: case wxLOG_Debug:
#ifdef __WXDEBUG__ #endif
{ {
wxString msg = level == wxLOG_Trace ? wxS("Trace: ") wxString str;
: wxS("Debug: ");
msg << szString; // don't prepend "debug/trace" prefix under MSW as it goes to
LogString(msg, t); // the debug window anyhow and don't add time stamp neither as
// debug output viewers under Windows typically add it
// themselves anyhow
#ifndef __WXMSW__
TimeStamp(&str);
str += level == wxLOG_Trace ? wxT("Trace: ")
: wxT("Debug: ");
#endif // !__WXMSW__
str += szString;
wxMessageOutputDebug().Output(str);
} }
#endif // Debug
break; break;
#endif // wxUSE_LOG_DEBUG || wxUSE_LOG_TRACE
} }
} }
@ -793,31 +798,39 @@ void wxLogBuffer::Flush()
} }
} }
#if wxUSE_LOG_DEBUG || wxUSE_LOG_TRACE
void wxLogBuffer::DoLog(wxLogLevel level, const wxString& szString, time_t t) void wxLogBuffer::DoLog(wxLogLevel level, const wxString& szString, time_t t)
{ {
switch ( level ) // don't put debug messages in the buffer, we don't want to show
// them to the user in a msg box, log them immediately
bool showImmediately = false;
#if wxUSE_LOG_TRACE
if ( level == wxLOG_Trace )
showImmediately = true;
#endif
#if wxUSE_LOG_DEBUG
if ( level == wxLOG_Debug )
showImmediately = true;
#endif
if ( showImmediately )
{ {
case wxLOG_Trace: wxString str;
case wxLOG_Debug: TimeStamp(&str);
#ifdef __WXDEBUG__ str += szString;
// don't put debug messages in the buffer, we don't want to show
// them to the user in a msg box, log them immediately
{
wxString str;
TimeStamp(&str);
str += szString;
wxMessageOutputDebug dbgout; wxMessageOutputDebug dbgout;
dbgout.Printf(wxS("%s\n"), str.c_str()); dbgout.Printf(wxS("%s\n"), str.c_str());
} }
#endif // __WXDEBUG__ else
break; {
wxLog::DoLog(level, szString, t);
default:
wxLog::DoLog(level, szString, t);
} }
} }
#endif // wxUSE_LOG_DEBUG || wxUSE_LOG_TRACE
void wxLogBuffer::DoLogString(const wxString& szString, time_t WXUNUSED(t)) void wxLogBuffer::DoLogString(const wxString& szString, time_t WXUNUSED(t))
{ {
m_str << szString << wxS("\n"); m_str << szString << wxS("\n");

View File

@ -3459,7 +3459,7 @@ void wxGrid::ChangeCursorMode(CursorMode mode,
wxWindow *win, wxWindow *win,
bool captureMouse) bool captureMouse)
{ {
#ifdef __WXDEBUG__ #if wxUSE_LOG_TRACE
static const wxChar *cursorModes[] = static const wxChar *cursorModes[] =
{ {
_T("SELECT_CELL"), _T("SELECT_CELL"),
@ -3476,7 +3476,7 @@ void wxGrid::ChangeCursorMode(CursorMode mode,
: win ? _T("rowLabelWin") : win ? _T("rowLabelWin")
: _T("gridWin"), : _T("gridWin"),
cursorModes[m_cursorMode], cursorModes[mode]); cursorModes[m_cursorMode], cursorModes[mode]);
#endif #endif // wxUSE_LOG_TRACE
if ( mode == m_cursorMode && if ( mode == m_cursorMode &&
win == m_winCapture && win == m_winCapture &&

View File

@ -51,6 +51,7 @@
#include "wx/artprov.h" #include "wx/artprov.h"
#include "wx/collpane.h" #include "wx/collpane.h"
#include "wx/arrstr.h" #include "wx/arrstr.h"
#include "wx/msgout.h"
#if wxUSE_THREADS #if wxUSE_THREADS
#include "wx/thread.h" #include "wx/thread.h"
@ -434,32 +435,6 @@ void wxLogGui::DoLog(wxLogLevel level, const wxString& szString, time_t t)
#endif // wxUSE_STATUSBAR #endif // wxUSE_STATUSBAR
break; break;
case wxLOG_Trace:
case wxLOG_Debug:
#ifdef __WXDEBUG__
{
wxString str;
TimeStamp(&str);
str += szString;
#if defined(__WXMSW__) && !defined(__WXMICROWIN__)
// don't prepend debug/trace here: it goes to the
// debug window anyhow
str += wxT("\r\n");
OutputDebugString(str.wx_str());
#else
// send them to stderr
wxFprintf(stderr, wxT("[%s] %s\n"),
level == wxLOG_Trace ? wxT("Trace")
: wxT("Debug"),
str.c_str());
fflush(stderr);
#endif
}
#endif // __WXDEBUG__
break;
case wxLOG_FatalError: case wxLOG_FatalError:
// show this one immediately // show this one immediately
wxMessageBox(szString, _("Fatal error"), wxICON_HAND); wxMessageBox(szString, _("Fatal error"), wxICON_HAND);
@ -491,6 +466,11 @@ void wxLogGui::DoLog(wxLogLevel level, const wxString& szString, time_t t)
m_aTimes.Add((long)t); m_aTimes.Add((long)t);
m_bHasMessages = true; m_bHasMessages = true;
break; break;
default:
// let the base class deal with debug/trace messages as well as any
// custom levels
wxLog::DoLog(level, szString, t);
} }
} }

View File

@ -36,12 +36,10 @@ extern bool g_blockEventsOnDrag;
// the flags used for the last DoDragDrop() // the flags used for the last DoDragDrop()
static long gs_flagsForDrag = 0; static long gs_flagsForDrag = 0;
#ifdef __WXDEBUG__
// the trace mask we use with wxLogTrace() - call // the trace mask we use with wxLogTrace() - call
// wxLog::AddTraceMask(TRACE_DND) to enable the trace messages from here // wxLog::AddTraceMask(TRACE_DND) to enable the trace messages from here
// (there are quite a few of them, so don't enable this by default) // (there are quite a few of them, so don't enable this by default)
static const wxChar *TRACE_DND = _T("dnd"); #define TRACE_DND "dnd"
#endif
// global variables because GTK+ DnD want to have the // global variables because GTK+ DnD want to have the
// mouse event that caused it // mouse event that caused it
@ -334,9 +332,7 @@ static gboolean target_drag_drop( GtkWidget *widget,
if (!ret) if (!ret)
{ {
#ifdef __WXDEBUG__
wxLogTrace(TRACE_DND, wxT( "Drop target: OnDrop returned FALSE") ); wxLogTrace(TRACE_DND, wxT( "Drop target: OnDrop returned FALSE") );
#endif
/* cancel the whole thing */ /* cancel the whole thing */
gtk_drag_finish( context, gtk_drag_finish( context,
@ -346,9 +342,7 @@ static gboolean target_drag_drop( GtkWidget *widget,
} }
else else
{ {
#ifdef __WXDEBUG__
wxLogTrace(TRACE_DND, wxT( "Drop target: OnDrop returned true") ); wxLogTrace(TRACE_DND, wxT( "Drop target: OnDrop returned true") );
#endif
#if wxUSE_THREADS #if wxUSE_THREADS
/* disable GUI threads */ /* disable GUI threads */
@ -414,9 +408,7 @@ static void target_drag_data_received( GtkWidget *WXUNUSED(widget),
return; return;
} }
#ifdef __WXDEBUG__
wxLogTrace(TRACE_DND, wxT( "Drop target: data received event") ); wxLogTrace(TRACE_DND, wxT( "Drop target: data received event") );
#endif
/* inform the wxDropTarget about the current GtkSelectionData. /* inform the wxDropTarget about the current GtkSelectionData.
this is only valid for the duration of this call */ this is only valid for the duration of this call */
@ -426,18 +418,14 @@ static void target_drag_data_received( GtkWidget *WXUNUSED(widget),
if ( wxIsDragResultOk( drop_target->OnData( x, y, result ) ) ) if ( wxIsDragResultOk( drop_target->OnData( x, y, result ) ) )
{ {
#ifdef __WXDEBUG__
wxLogTrace(TRACE_DND, wxT( "Drop target: OnData returned true") ); wxLogTrace(TRACE_DND, wxT( "Drop target: OnData returned true") );
#endif
/* tell GTK that data transfer was successful */ /* tell GTK that data transfer was successful */
gtk_drag_finish( context, TRUE, FALSE, time ); gtk_drag_finish( context, TRUE, FALSE, time );
} }
else else
{ {
#ifdef __WXDEBUG__
wxLogTrace(TRACE_DND, wxT( "Drop target: OnData returned FALSE") ); wxLogTrace(TRACE_DND, wxT( "Drop target: OnData returned FALSE") );
#endif
/* tell GTK that data transfer was not successful */ /* tell GTK that data transfer was not successful */
gtk_drag_finish( context, FALSE, FALSE, time ); gtk_drag_finish( context, FALSE, FALSE, time );
@ -468,13 +456,9 @@ wxDragResult wxDropTarget::OnDragOver( wxCoord WXUNUSED(x),
{ {
// GetMatchingPair() checks for m_dataObject too, no need to do it here // GetMatchingPair() checks for m_dataObject too, no need to do it here
// disable the debug message from GetMatchingPair() - there are too many // disable the trace message from GetMatchingPair() by passing true to it
// of them otherwise // (there are just too many of them otherwise)
#ifdef __WXDEBUG__ return (GtkGetMatchingPair(true) != (GdkAtom) 0) ? def : wxDragNone;
wxLogNull noLog;
#endif // Debug
return (GtkGetMatchingPair() != (GdkAtom) 0) ? def : wxDragNone;
} }
bool wxDropTarget::OnDrop( wxCoord WXUNUSED(x), wxCoord WXUNUSED(y) ) bool wxDropTarget::OnDrop( wxCoord WXUNUSED(x), wxCoord WXUNUSED(y) )
@ -503,7 +487,7 @@ wxDataFormat wxDropTarget::GetMatchingPair()
return wxDataFormat( GtkGetMatchingPair() ); return wxDataFormat( GtkGetMatchingPair() );
} }
GdkAtom wxDropTarget::GtkGetMatchingPair() GdkAtom wxDropTarget::GtkGetMatchingPair(bool quiet)
{ {
if (!m_dataObject) if (!m_dataObject)
return (GdkAtom) 0; return (GdkAtom) 0;
@ -517,10 +501,11 @@ GdkAtom wxDropTarget::GtkGetMatchingPair()
GdkAtom formatAtom = (GdkAtom)(child->data); GdkAtom formatAtom = (GdkAtom)(child->data);
wxDataFormat format( formatAtom ); wxDataFormat format( formatAtom );
#ifdef __WXDEBUG__ if ( !quiet )
wxLogTrace(TRACE_DND, wxT("Drop target: drag has format: %s"), {
format.GetId().c_str()); wxLogTrace(TRACE_DND, wxT("Drop target: drag has format: %s"),
#endif // Debug format.GetId().c_str());
}
if (m_dataObject->IsSupportedFormat( format )) if (m_dataObject->IsSupportedFormat( format ))
return formatAtom; return formatAtom;
@ -613,10 +598,8 @@ source_drag_data_get (GtkWidget *WXUNUSED(widget),
{ {
wxDataFormat format( selection_data->target ); wxDataFormat format( selection_data->target );
#ifdef __WXDEBUG__
wxLogTrace(TRACE_DND, wxT("Drop source: format requested: %s"), wxLogTrace(TRACE_DND, wxT("Drop source: format requested: %s"),
format.GetId().c_str()); format.GetId().c_str());
#endif
drop_source->m_retValue = wxDragCancel; drop_source->m_retValue = wxDragCancel;
@ -624,26 +607,20 @@ source_drag_data_get (GtkWidget *WXUNUSED(widget),
if (!data) if (!data)
{ {
#ifdef __WXDEBUG__
wxLogTrace(TRACE_DND, wxT("Drop source: no data object") ); wxLogTrace(TRACE_DND, wxT("Drop source: no data object") );
#endif return;
return;
} }
if (!data->IsSupportedFormat(format)) if (!data->IsSupportedFormat(format))
{ {
#ifdef __WXDEBUG__
wxLogTrace(TRACE_DND, wxT("Drop source: unsupported format") ); wxLogTrace(TRACE_DND, wxT("Drop source: unsupported format") );
#endif return;
return;
} }
if (data->GetDataSize(format) == 0) if (data->GetDataSize(format) == 0)
{ {
#ifdef __WXDEBUG__
wxLogTrace(TRACE_DND, wxT("Drop source: empty data") ); wxLogTrace(TRACE_DND, wxT("Drop source: empty data") );
#endif return;
return;
} }
size_t size = data->GetDataSize(format); size_t size = data->GetDataSize(format);
@ -843,10 +820,9 @@ wxDragResult wxDropSource::DoDragDrop(int flags)
for (size_t i = 0; i < count; i++) for (size_t i = 0; i < count; i++)
{ {
GdkAtom atom = array[i]; GdkAtom atom = array[i];
#ifdef __WXDEBUG__ wxLogTrace(TRACE_DND, wxT("Drop source: Supported atom %s"),
wxLogTrace(TRACE_DND, wxT("Drop source: Supported atom %s"), gdk_atom_name( atom )); gdk_atom_name( atom ));
#endif gtk_target_list_add( target_list, atom, 0, 0 );
gtk_target_list_add( target_list, atom, 0, 0 );
} }
delete[] array; delete[] array;

View File

@ -37,13 +37,6 @@
extern void wxapp_install_idle_handler(); extern void wxapp_install_idle_handler();
extern bool g_isIdle; extern bool g_isIdle;
//-----------------------------------------------------------------------------
// thread system
//-----------------------------------------------------------------------------
#if wxUSE_THREADS
#endif
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// global data // global data
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -472,13 +465,8 @@ wxDragResult wxDropTarget::OnDragOver( wxCoord WXUNUSED(x),
{ {
// GetMatchingPair() checks for m_dataObject too, no need to do it here // GetMatchingPair() checks for m_dataObject too, no need to do it here
// disable the debug message from GetMatchingPair() - there are too many // disable the debug message from GetMatchingPair() by passing true to it
// of them otherwise return (GetMatchingPair(true) != (GdkAtom) 0) ? def : wxDragNone;
#ifdef __WXDEBUG__
wxLogNull noLog;
#endif // Debug
return (GetMatchingPair() != (GdkAtom) 0) ? def : wxDragNone;
} }
bool wxDropTarget::OnDrop( wxCoord WXUNUSED(x), wxCoord WXUNUSED(y) ) bool wxDropTarget::OnDrop( wxCoord WXUNUSED(x), wxCoord WXUNUSED(y) )
@ -515,10 +503,11 @@ GdkAtom wxDropTarget::GetMatchingPair()
GdkAtom formatAtom = GPOINTER_TO_INT(child->data); GdkAtom formatAtom = GPOINTER_TO_INT(child->data);
wxDataFormat format( formatAtom ); wxDataFormat format( formatAtom );
#ifdef __WXDEBUG__ if ( !quiet )
wxLogTrace(TRACE_DND, wxT("Drop target: drag has format: %s"), {
format.GetId().c_str()); wxLogTrace(TRACE_DND, wxT("Drop target: drag has format: %s"),
#endif // Debug format.GetId().c_str());
}
if (m_dataObject->IsSupportedFormat( format )) if (m_dataObject->IsSupportedFormat( format ))
return formatAtom; return formatAtom;

View File

@ -720,7 +720,7 @@ public:
wxThreadState GetState() const { return m_state; } wxThreadState GetState() const { return m_state; }
void SetState(wxThreadState state) void SetState(wxThreadState state)
{ {
#ifdef __WXDEBUG__ #if wxUSE_LOG_TRACE
static const wxChar *stateNames[] = static const wxChar *stateNames[] =
{ {
_T("NEW"), _T("NEW"),
@ -731,7 +731,7 @@ public:
wxLogTrace(TRACE_THREADS, _T("Thread %p: %s => %s."), wxLogTrace(TRACE_THREADS, _T("Thread %p: %s => %s."),
GetId(), stateNames[m_state], stateNames[state]); GetId(), stateNames[m_state], stateNames[state]);
#endif // __WXDEBUG__ #endif // wxUSE_LOG_TRACE
m_state = state; m_state = state;
} }