Warning fixes for VC5 (Igor Korot)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37526 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Michael Wetherell
2006-02-12 12:16:56 +00:00
parent 51d0522672
commit 8d7eaf9140
25 changed files with 61 additions and 53 deletions

View File

@@ -73,6 +73,12 @@
# pragma warning(disable:4512) /* operator=() couldn't be generated */ # pragma warning(disable:4512) /* operator=() couldn't be generated */
# pragma warning(disable:4710) /* function not inlined */ # pragma warning(disable:4710) /* function not inlined */
/* For VC++ 5.0 for release mode, the warning 'C4702: unreachable code */
/* is buggy, and occurs for code that does actually get executed */
# if !defined __WXDEBUG__ && __VISUALC__ <= 1100
# pragma warning(disable:4702) /* unreachable code */
# endif
/* Deprecated functions such as sprintf, localtime */ /* Deprecated functions such as sprintf, localtime */
#if __VISUALC__ >= 1400 #if __VISUALC__ >= 1400
#define _CRT_SECURE_NO_DEPRECATE 1 #define _CRT_SECURE_NO_DEPRECATE 1
@@ -895,40 +901,42 @@ inline wxUIntPtr wxPtrToUInt(const void *p)
explicit with /Wp64 option, suppress them as we really know what we're explicit with /Wp64 option, suppress them as we really know what we're
doing here. Same thing with icc with -Wall. doing here. Same thing with icc with -Wall.
*/ */
#if defined(__VISUALC__) || defined(__INTELC__) #ifdef __VISUALC__
#if __VISUALC__ >= 1200
#pragma warning(push) #pragma warning(push)
#ifdef __VISUALC__ #endif
/* pointer truncation from '' to '' */ /* pointer truncation from '' to '' */
#pragma warning(disable: 4311) #pragma warning(disable: 4311)
#elif defined(__INTELC__) #elif defined(__INTELC__)
#pragma warning(push)
/* conversion from pointer to same-sized integral type */ /* conversion from pointer to same-sized integral type */
#pragma warning(disable: 1684) #pragma warning(disable: 1684)
#endif
#endif #endif
return wx_reinterpret_cast(wxUIntPtr, p); return wx_reinterpret_cast(wxUIntPtr, p);
#if defined(__VISUALC__) || defined(__INTELC__) #if (defined(__VISUALC__) && __VISUALC__ >= 1200) || defined(__INTELC__)
#pragma warning(pop) #pragma warning(pop)
#endif #endif
} }
inline void *wxUIntToPtr(wxUIntPtr p) inline void *wxUIntToPtr(wxUIntPtr p)
{ {
#if defined(__VISUALC__) || defined(__INTELC__) #ifdef __VISUALC__
#if __VISUALC__ >= 1200
#pragma warning(push) #pragma warning(push)
#ifdef __VISUALC__ #endif
/* conversion to type of greater size */ /* conversion to type of greater size */
#pragma warning(disable: 4312) #pragma warning(disable: 4312)
#elif defined(__INTELC__) #elif defined(__INTELC__)
#pragma warning(push)
/* invalid type conversion: "wxUIntPtr={unsigned long}" to "void *" */ /* invalid type conversion: "wxUIntPtr={unsigned long}" to "void *" */
#pragma warning(disable: 171) #pragma warning(disable: 171)
#endif
#endif #endif
return wx_reinterpret_cast(void *, p); return wx_reinterpret_cast(void *, p);
#if defined(__VISUALC__) || defined(__INTELC__) #if (defined(__VISUALC__) && __VISUALC__ >= 1200) || defined(__INTELC__)
#pragma warning(pop) #pragma warning(pop)
#endif #endif
} }

View File

@@ -101,7 +101,7 @@ public:
// calling DecRef() once will delete it. Calling IncRef() allows to lock // calling DecRef() once will delete it. Calling IncRef() allows to lock
// it until the matching DecRef() is called // it until the matching DecRef() is called
void IncRef() { m_nRef++; } void IncRef() { m_nRef++; }
void DecRef() { if ( !--m_nRef ) delete this; } void DecRef() { if ( --m_nRef == 0 ) delete this; }
// interpret renderer parameters: arbitrary string whose interpretatin is // interpret renderer parameters: arbitrary string whose interpretatin is
// left to the derived classes // left to the derived classes
@@ -656,7 +656,7 @@ public:
// calling DecRef() once will delete it. Calling IncRef() allows to lock // calling DecRef() once will delete it. Calling IncRef() allows to lock
// it until the matching DecRef() is called // it until the matching DecRef() is called
void IncRef() { m_nRef++; } void IncRef() { m_nRef++; }
void DecRef() { if ( !--m_nRef ) delete this; } void DecRef() { if ( --m_nRef == 0 ) delete this; }
// setters // setters
void SetTextColour(const wxColour& colText) { m_colText = colText; } void SetTextColour(const wxColour& colText) { m_colText = colText; }

View File

@@ -1139,7 +1139,7 @@ void wxEvtHandler::ProcessPendingEvents()
wxENTER_CRIT_SECT( Lock() ); wxENTER_CRIT_SECT( Lock() );
if ( !--n ) if ( --n == 0 )
break; break;
} }

View File

@@ -477,7 +477,7 @@ void wxUninitialize()
{ {
wxCRIT_SECT_LOCKER(lockInit, gs_initData.csInit); wxCRIT_SECT_LOCKER(lockInit, gs_initData.csInit);
if ( !--gs_initData.nInitCount ) if ( --gs_initData.nInitCount == 0 )
{ {
wxEntryCleanup(); wxEntryCleanup();
} }

View File

@@ -310,7 +310,7 @@ void wxObject::UnRef()
{ {
wxASSERT_MSG( m_refData->m_count > 0, _T("invalid ref data count") ); wxASSERT_MSG( m_refData->m_count > 0, _T("invalid ref data count") );
if ( !--m_refData->m_count ) if ( --m_refData->m_count == 0 )
delete m_refData; delete m_refData;
m_refData = NULL; m_refData = NULL;
} }

View File

@@ -159,7 +159,7 @@ void wxSocketBase::Shutdown()
{ {
// we should be initialized // we should be initialized
wxASSERT_MSG( m_countInit, _T("extra call to Shutdown()") ); wxASSERT_MSG( m_countInit, _T("extra call to Shutdown()") );
if ( !--m_countInit ) if ( --m_countInit == 0 )
{ {
GSocket_Cleanup(); GSocket_Cleanup();
} }

View File

@@ -1703,7 +1703,7 @@ bool wxWindowBase::Layout()
// If there is a sizer, use it instead of the constraints // If there is a sizer, use it instead of the constraints
if ( GetSizer() ) if ( GetSizer() )
{ {
int w, h; int w = 0, h = 0;
GetVirtualSize(&w, &h); GetVirtualSize(&w, &h);
GetSizer()->SetDimension( 0, 0, w, h ); GetSizer()->SetDimension( 0, 0, w, h );
} }

View File

@@ -123,7 +123,7 @@ bool wxGenericDragImage::Create(const wxString& str, const wxCursor& cursor)
{ {
wxFont font(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); wxFont font(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
long w, h; long w = 0, h = 0;
wxScreenDC dc; wxScreenDC dc;
dc.SetFont(font); dc.SetFont(font);
dc.GetTextExtent(str, & w, & h); dc.GetTextExtent(str, & w, & h);

View File

@@ -76,7 +76,7 @@ void wxFontPreviewer::OnPaint(wxPaintEvent& WXUNUSED(event))
{ {
dc.SetFont(font); dc.SetFont(font);
// Calculate vertical centre // Calculate vertical centre
long w, h; long w = 0, h = 0;
dc.GetTextExtent( wxT("X"), &w, &h); dc.GetTextExtent( wxT("X"), &w, &h);
dc.SetTextForeground(GetForegroundColour()); dc.SetTextForeground(GetForegroundColour());
dc.SetClippingRegion(2, 2, size.x-4, size.y-4); dc.SetClippingRegion(2, 2, size.x-4, size.y-4);

View File

@@ -7484,8 +7484,8 @@ void wxGrid::DrawTextRectangle( wxDC& dc,
int vertAlign, int vertAlign,
int textOrientation ) int textOrientation )
{ {
long textWidth, textHeight; long textWidth = 0, textHeight = 0;
long lineWidth, lineHeight; long lineWidth = 0, lineHeight = 0;
int nLines; int nLines;
dc.SetClippingRegion( rect ); dc.SetClippingRegion( rect );
@@ -7614,7 +7614,7 @@ void wxGrid::GetTextBoxSize( const wxDC& dc,
{ {
long w = 0; long w = 0;
long h = 0; long h = 0;
long lineW, lineH; long lineW = 0, lineH = 0;
size_t i; size_t i;
for ( i = 0; i < lines.GetCount(); i++ ) for ( i = 0; i < lines.GetCount(); i++ )

View File

@@ -2564,7 +2564,7 @@ void wxListMainWindow::Thaw()
{ {
wxCHECK_RET( m_freezeCount > 0, _T("thawing unfrozen list control?") ); wxCHECK_RET( m_freezeCount > 0, _T("thawing unfrozen list control?") );
if ( !--m_freezeCount ) if ( --m_freezeCount == 0 )
Refresh(); Refresh();
} }

View File

@@ -141,7 +141,7 @@ wxProgressDialog::wxProgressDialog(wxString const &title,
wxClientDC dc(this); wxClientDC dc(this);
dc.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); dc.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
long widthText; long widthText = 0;
dc.GetTextExtent(message, &widthText, NULL, NULL, NULL, NULL); dc.GetTextExtent(message, &widthText, NULL, NULL, NULL, NULL);
wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL); wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);

View File

@@ -95,7 +95,7 @@ void wxSashWindow::OnPaint(wxPaintEvent& WXUNUSED(event))
void wxSashWindow::OnMouseEvent(wxMouseEvent& event) void wxSashWindow::OnMouseEvent(wxMouseEvent& event)
{ {
wxCoord x, y; wxCoord x = 0, y = 0;
event.GetPosition(&x, &y); event.GetPosition(&x, &y);
wxSashEdgePosition sashHit = SashHitTest(x, y); wxSashEdgePosition sashHit = SashHitTest(x, y);

View File

@@ -868,7 +868,7 @@ void wxScrollHelper::Scroll( int x_pos, int y_pos )
if (((x_pos == -1) || (x_pos == m_xScrollPosition)) && if (((x_pos == -1) || (x_pos == m_xScrollPosition)) &&
((y_pos == -1) || (y_pos == m_yScrollPosition))) return; ((y_pos == -1) || (y_pos == m_yScrollPosition))) return;
int w, h; int w = 0, h = 0;
GetTargetSize(&w, &h); GetTargetSize(&w, &h);
if ((x_pos != -1) && (m_xScrollPixelsPerLine)) if ((x_pos != -1) && (m_xScrollPixelsPerLine))
@@ -957,7 +957,7 @@ bool wxScrollHelper::ScrollLayout()
// If we're the scroll target, take into account the // If we're the scroll target, take into account the
// virtual size and scrolled position of the window. // virtual size and scrolled position of the window.
int x, y, w, h; int x = 0, y = 0, w = 0, h = 0;
CalcScrolledPosition(0,0, &x,&y); CalcScrolledPosition(0,0, &x,&y);
m_win->GetVirtualSize(&w, &h); m_win->GetVirtualSize(&w, &h);
m_win->GetSizer()->SetDimension(x, y, w, h); m_win->GetSizer()->SetDimension(x, y, w, h);
@@ -1048,9 +1048,9 @@ void wxScrollHelper::HandleOnPaint(wxPaintEvent& WXUNUSED(event))
// this they always have the priority // this they always have the priority
void wxScrollHelper::HandleOnChar(wxKeyEvent& event) void wxScrollHelper::HandleOnChar(wxKeyEvent& event)
{ {
int stx, sty, // view origin int stx = 0, sty = 0, // view origin
szx, szy, // view size (total) szx = 0, szy = 0, // view size (total)
clix, cliy; // view size (on screen) clix = 0, cliy = 0; // view size (on screen)
GetViewStart(&stx, &sty); GetViewStart(&stx, &sty);
GetTargetSize(&clix, &cliy); GetTargetSize(&clix, &cliy);

View File

@@ -232,7 +232,7 @@ void wxStatusBarGeneric::DrawFieldText(wxDC& dc, int i)
wxString text(GetStatusText(i)); wxString text(GetStatusText(i));
long x, y; long x = 0, y = 0;
dc.GetTextExtent(text, &x, &y); dc.GetTextExtent(text, &x, &y);

View File

@@ -3518,7 +3518,7 @@ void wxGenericTreeCtrl::Thaw()
{ {
wxCHECK_RET( m_freezeCount > 0, _T("thawing unfrozen tree control?") ); wxCHECK_RET( m_freezeCount > 0, _T("thawing unfrozen tree control?") );
if ( !--m_freezeCount ) if ( --m_freezeCount == 0 )
{ {
Refresh(); Refresh();
} }

View File

@@ -253,7 +253,7 @@ wxPaintDC::~wxPaintDC()
wxCHECK_RET( info, wxT("existing DC should have a cache entry") ); wxCHECK_RET( info, wxT("existing DC should have a cache entry") );
if ( !--info->count ) if ( --info->count == 0 )
{ {
::EndPaint(GetHwndOf(m_canvas), &g_paintStruct); ::EndPaint(GetHwndOf(m_canvas), &g_paintStruct);
@@ -338,7 +338,7 @@ wxPaintDCEx::~wxPaintDCEx()
wxCHECK_RET( info, wxT("existing DC should have a cache entry") ); wxCHECK_RET( info, wxT("existing DC should have a cache entry") );
if ( !--info->count ) if ( --info->count == 0 )
{ {
RestoreDC((HDC) m_hDC, saveState); RestoreDC((HDC) m_hDC, saveState);
ms_cache.RemoveAt(index); ms_cache.RemoveAt(index);

View File

@@ -1188,7 +1188,7 @@ void wxDialUpManagerMSW::DisableAutoCheckOnlineStatus()
{ {
wxCHECK_RET( IsOk(), wxT("using uninitialized wxDialUpManager") ); wxCHECK_RET( IsOk(), wxT("using uninitialized wxDialUpManager") );
if ( --m_autoCheckLevel ) if ( --m_autoCheckLevel != 0 )
{ {
// still checking // still checking
return; return;

View File

@@ -208,7 +208,7 @@ bool wxDragImage::Create(const wxString& str, const wxCursor& cursor)
{ {
wxFont font(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); wxFont font(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
long w, h; long w = 0, h = 0;
wxScreenDC dc; wxScreenDC dc;
dc.SetFont(font); dc.SetFont(font);
dc.GetTextExtent(str, & w, & h); dc.GetTextExtent(str, & w, & h);

View File

@@ -100,12 +100,12 @@ IMPLEMENT_DYNAMIC_CLASS(wxMSWSystemMenuFontModule, wxModule)
// a UDT. Will produce errors if applied using infix notation. // a UDT. Will produce errors if applied using infix notation.
// //
// shut it down // shut it down
#ifdef __VISUALC__ #if defined __VISUALC__ && __VISUALC__ <= 1300
#if __VISUALC__ <= 1300 #if __VISUALC__ >= 1200
#pragma warning(push) #pragma warning(push)
#pragma warning(disable: 4284)
#define POP_WARNINGS #define POP_WARNINGS
#endif #endif
#pragma warning(disable: 4284)
#endif #endif
#include "wx/hashset.h" #include "wx/hashset.h"

View File

@@ -1324,7 +1324,7 @@ void wxToolBar::OnMouseEvent(wxMouseEvent& event)
if ( event.RightDown() ) if ( event.RightDown() )
{ {
// find the tool under the mouse // find the tool under the mouse
wxCoord x,y; wxCoord x = 0, y = 0;
event.GetPosition(&x, &y); event.GetPosition(&x, &y);
wxToolBarToolBase *tool = FindToolForPosition(x, y); wxToolBarToolBase *tool = FindToolForPosition(x, y);

View File

@@ -925,7 +925,7 @@ bool wxThread::SetConcurrency(size_t WXUNUSED_IN_WINCE(level))
dwProcMask |= bit; dwProcMask |= bit;
// another process added // another process added
if ( !--level ) if ( --level == 0 )
{ {
// and that's enough // and that's enough
break; break;

View File

@@ -1359,7 +1359,7 @@ void wxWindowMSW::Thaw()
{ {
wxASSERT_MSG( m_frozenness > 0, _T("Thaw() without matching Freeze()") ); wxASSERT_MSG( m_frozenness > 0, _T("Thaw() without matching Freeze()") );
if ( !--m_frozenness ) if ( --m_frozenness == 0 )
{ {
if ( IsShown() ) if ( IsShown() )
{ {

View File

@@ -703,7 +703,7 @@ bool wxRichTextCtrl::ScrollIntoView(long position, int keyCode)
startX = 0; startX = 0;
startY = startY * ppuY; startY = startY * ppuY;
int sx, sy; int sx = 0, sy = 0;
GetVirtualSize(& sx, & sy); GetVirtualSize(& sx, & sy);
sx = 0; sx = 0;
if (ppuY != 0) if (ppuY != 0)
@@ -796,7 +796,7 @@ bool wxRichTextCtrl::IsPositionVisible(long pos) const
startX = 0; startX = 0;
startY = startY * ppuY; startY = startY * ppuY;
int sx, sy; int sx = 0, sy = 0;
GetVirtualSize(& sx, & sy); GetVirtualSize(& sx, & sy);
sx = 0; sx = 0;
if (ppuY != 0) if (ppuY != 0)

View File

@@ -392,7 +392,7 @@ void wxRadioBox::DoSetToolTip(wxToolTip *tooltip)
wxSize wxRadioBox::GetMaxButtonSize() const wxSize wxRadioBox::GetMaxButtonSize() const
{ {
int widthMax, heightMax, width, height; int widthMax, heightMax, width = 0, height = 0;
widthMax = heightMax = 0; widthMax = heightMax = 0;
int count = GetCount(); int count = GetCount();