From 23c44a61342c308aca4b4756c00e664364454d68 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 6 Aug 2000 10:12:09 +0000 Subject: [PATCH] warnings fixed for compilation with VC++ at max warning level with optimization (mainly "unreachable code"), another warning ("function not inlined") disabled in defs.h, minor fixes to DLL project file template git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7961 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- distrib/msw/tmake/vc6dll.t | 7 +++--- include/wx/defs.h | 3 ++- src/common/docview.cpp | 12 +++++----- src/common/fontmap.cpp | 4 ++-- src/common/fs_zip.cpp | 9 +++----- src/common/image.cpp | 8 +++---- src/common/utilscmn.cpp | 5 ++++- src/generic/choicdgg.cpp | 21 +++++++++++------ src/html/htmlfilt.cpp | 2 +- src/html/htmprint.cpp | 26 +++++++++------------ src/msw/filedlg.cpp | 28 ++++++++++++++--------- src/msw/imaglist.cpp | 46 +++++++++++++++++++++----------------- src/msw/mdi.cpp | 10 +++++---- src/msw/menu.cpp | 4 +--- src/msw/nativdlg.cpp | 6 ++--- src/msw/ole/automtn.cpp | 8 ++----- src/msw/settings.cpp | 1 - src/msw/window.cpp | 8 +++---- src/msw/xpmhand.cpp | 3 ++- src/xpm/RdFToI.c | 3 ++- 20 files changed, 111 insertions(+), 103 deletions(-) diff --git a/distrib/msw/tmake/vc6dll.t b/distrib/msw/tmake/vc6dll.t index fe65c4d09b..133cdbc56b 100644 --- a/distrib/msw/tmake/vc6dll.t +++ b/distrib/msw/tmake/vc6dll.t @@ -87,13 +87,13 @@ RSC=rc.exe # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /i "$(wx)\include" /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib src\jpeg\Release\jpeg.lib src\tiff\Release\tiff.lib src\png\Release\png.lib src\xpm\Release\xpm.lib src\zlib\Release\zlib.lib /nologo /dll /machine:I386 /out:"ReleaseDll/wxmsw221.dll" -# ADD LINK32 kernel32.lib user32.lib gdi32.lib advapi32.lib comdlg32.lib shell32.lib ole32.lib oleaut32.lib odbc32.lib uuid.lib rpcrt4.lib comctl32.lib winmm.lib src\jpeg\Release\jpeg.lib src\tiff\Release\tiff.lib src\png\Release\png.lib src\xpm\Release\xpm.lib src\zlib\Release\zlib.lib /nologo /dll /machine:I386 /out:"ReleaseDll/wxmsw221.dll" +# ADD LINK32 kernel32.lib user32.lib gdi32.lib advapi32.lib comdlg32.lib shell32.lib ole32.lib oleaut32.lib odbc32.lib uuid.lib rpcrt4.lib comctl32.lib wsock32.lib winmm.lib src\jpeg\Release\jpeg.lib src\tiff\Release\tiff.lib src\png\Release\png.lib src\xpm\Release\xpm.lib src\zlib\Release\zlib.lib /nologo /dll /machine:I386 /out:"ReleaseDll/wxmsw221.dll" !ELSEIF "$(CFG)" == "wxWinDll - Win32 Debug" @@ -113,7 +113,7 @@ LINK32=link.exe # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /i "$(wx)\include" /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo @@ -152,6 +152,7 @@ SOURCE=.\src\common\y_tab.c !IF "$(CFG)" == "wxWinDll - Win32 Release" +# ADD CPP /W1 # SUBTRACT CPP /YX /Yc /Yu !ELSEIF "$(CFG)" == "wxWinDll - Win32 Debug" diff --git a/include/wx/defs.h b/include/wx/defs.h index 7bde10d685..090219a909 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -100,8 +100,9 @@ # pragma warning(disable:4100) // unreferenced formal parameter # pragma warning(disable:4511) // copy ctor couldn't be generated # pragma warning(disable:4512) // operator=() couldn't be generated -# pragma warning(disable:4699) // Using precompiled header +# pragma warning(disable:4699) // using precompiled header # pragma warning(disable:4134) // conversion between pointers to members of same class +# pragma warning(disable:4710) // function not inlined #ifndef WIN32 # pragma warning(disable:4135) // conversion between different integral types # pragma warning(disable:4769) // assignment of near pointer to long integer diff --git a/src/common/docview.cpp b/src/common/docview.cpp index 6f8a2ce363..bcb467b60e 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -1114,8 +1114,8 @@ wxDocument *wxDocManager::CreateDocument(const wxString& path, long flags) } return newDoc; } - else - return (wxDocument *) NULL; + + return (wxDocument *) NULL; } wxView *wxDocManager::CreateView(wxDocument *doc, long flags) @@ -1376,6 +1376,7 @@ wxDocTemplate *wxDocManager::SelectDocumentPath(wxDocTemplate **templates, 0, parent); + wxDocTemplate *theTemplate = (wxDocTemplate *)NULL; if (!pathTmp.IsEmpty()) { if (!wxFileExists(pathTmp)) @@ -1398,19 +1399,18 @@ wxDocTemplate *wxDocManager::SelectDocumentPath(wxDocTemplate **templates, // first choose the template using the extension, if this fails (i.e. // wxFileSelectorEx() didn't fill it), then use the path - wxDocTemplate *theTemplate = (wxDocTemplate *)NULL; if ( FilterIndex != -1 ) theTemplate = templates[FilterIndex]; if ( !theTemplate ) theTemplate = FindTemplateForPath(path); - - return theTemplate; } else { path = wxT(""); - return (wxDocTemplate *) NULL; } + + return theTemplate; + #if 0 // In all other windowing systems, until we have more advanced // file selectors, we must select the document type (template) first, and diff --git a/src/common/fontmap.cpp b/src/common/fontmap.cpp index 2ab2ba04f5..18a61b6768 100644 --- a/src/common/fontmap.cpp +++ b/src/common/fontmap.cpp @@ -741,8 +741,8 @@ bool wxFontMapper::IsEncodingAvailable(wxFontEncoding encoding, info.facename = facename; return wxTestFontEncoding(info); } - else - return FALSE; + + return FALSE; } #endif // wxUSE_GUI diff --git a/src/common/fs_zip.cpp b/src/common/fs_zip.cpp index 706cd05352..e78ce297a0 100644 --- a/src/common/fs_zip.cpp +++ b/src/common/fs_zip.cpp @@ -85,12 +85,9 @@ wxFSFile* wxZipFSHandler::OpenFile(wxFileSystem& WXUNUSED(fs), const wxString& l GetAnchor(location), wxDateTime(wxFileModificationTime(left))); } - else - { - if (s) - delete s; - return NULL; - } + + delete s; + return NULL; } diff --git a/src/common/image.cpp b/src/common/image.cpp index 7dc9b2ee42..edda6c960f 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -662,9 +662,9 @@ bool wxImage::SaveFile( const wxString& filename, int type ) wxBufferedOutputStream bstream( stream ); return SaveFile(bstream, type); } - else #endif // wxUSE_STREAMS - return FALSE; + + return FALSE; } bool wxImage::SaveFile( const wxString& filename, const wxString& mimetype ) @@ -677,9 +677,9 @@ bool wxImage::SaveFile( const wxString& filename, const wxString& mimetype ) wxBufferedOutputStream bstream( stream ); return SaveFile(bstream, mimetype); } - else #endif // wxUSE_STREAMS - return FALSE; + + return FALSE; } bool wxImage::CanRead( const wxString &name ) diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index 0bc2e97888..49c15f3284 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -887,10 +887,13 @@ int wxMessageBox(const wxString& message, const wxString& caption, long style, return wxYES; case wxID_NO: return wxNO; - default: case wxID_CANCEL: return wxCANCEL; } + + wxFAIL_MSG( _T("unexpected return code from wxMessageDialog") ); + + return wxCANCEL; } #if wxUSE_TEXTDLG diff --git a/src/generic/choicdgg.cpp b/src/generic/choicdgg.cpp index ec8857fa4d..f2c529666a 100644 --- a/src/generic/choicdgg.cpp +++ b/src/generic/choicdgg.cpp @@ -45,10 +45,11 @@ wxString wxGetSingleChoice( const wxString& message, const wxString& caption, in int WXUNUSED(width), int WXUNUSED(height) ) { wxSingleChoiceDialog dialog(parent, message, caption, n, choices); + wxString choice; if ( dialog.ShowModal() == wxID_OK ) - return dialog.GetStringSelection(); - else - return wxT(""); + choice = dialog.GetStringSelection(); + + return choice; } // Overloaded for backward compatibility @@ -75,10 +76,13 @@ int wxGetSingleChoiceIndex( const wxString& message, const wxString& caption, in int WXUNUSED(width), int WXUNUSED(height) ) { wxSingleChoiceDialog dialog(parent, message, caption, n, choices); + int choice; if ( dialog.ShowModal() == wxID_OK ) - return dialog.GetSelection(); + choice = dialog.GetSelection(); else - return -1; + choice = -1; + + return choice; } // Overloaded for backward compatibility @@ -102,10 +106,13 @@ void *wxGetSingleChoiceData( const wxString& message, const wxString& caption, i int WXUNUSED(width), int WXUNUSED(height) ) { wxSingleChoiceDialog dialog(parent, message, caption, n, choices, (char **)client_data); + void *data; if ( dialog.ShowModal() == wxID_OK ) - return dialog.GetSelectionClientData(); + data = dialog.GetSelectionClientData(); else - return NULL; + data = NULL; + + return data; } // Overloaded for backward compatibility diff --git a/src/html/htmlfilt.cpp b/src/html/htmlfilt.cpp index 639ea7272a..874ccaf991 100644 --- a/src/html/htmlfilt.cpp +++ b/src/html/htmlfilt.cpp @@ -160,7 +160,7 @@ wxString wxHtmlFilterHTML::ReadFile(const wxFSFile& file) const return s; } - else return doc; + return doc; } diff --git a/src/html/htmprint.cpp b/src/html/htmprint.cpp index 82f3e09fce..df55a076eb 100644 --- a/src/html/htmprint.cpp +++ b/src/html/htmprint.cpp @@ -485,16 +485,14 @@ bool wxHtmlEasyPrinting::DoPreview(wxHtmlPrintout *printout1, wxHtmlPrintout *pr delete preview; return FALSE; } - - else { - wxPreviewFrame *frame = new wxPreviewFrame(preview, m_Frame, - m_Name + _(" Preview"), - wxPoint(100, 100), wxSize(650, 500)); - frame -> Centre(wxBOTH); - frame -> Initialize(); - frame -> Show(TRUE); - return TRUE; - } + + wxPreviewFrame *frame = new wxPreviewFrame(preview, m_Frame, + m_Name + _(" Preview"), + wxPoint(100, 100), wxSize(650, 500)); + frame -> Centre(wxBOTH); + frame -> Initialize(); + frame -> Show(TRUE); + return TRUE; } @@ -508,11 +506,9 @@ bool wxHtmlEasyPrinting::DoPrint(wxHtmlPrintout *printout) { return FALSE; } - else - { - (*m_PrintData) = printer.GetPrintDialogData().GetPrintData(); - return TRUE; - } + + (*m_PrintData) = printer.GetPrintDialogData().GetPrintData(); + return TRUE; } diff --git a/src/msw/filedlg.cpp b/src/msw/filedlg.cpp index c81dfcdf52..cf25db47e6 100644 --- a/src/msw/filedlg.cpp +++ b/src/msw/filedlg.cpp @@ -151,13 +151,13 @@ wxString wxFileSelector(const wxChar *title, fileDialog.SetFilterIndex(filterFind); } + wxString filename; if ( fileDialog.ShowModal() == wxID_OK ) { - wxStrcpy(wxBuffer, (const wxChar *)fileDialog.GetPath()); - return wxBuffer; + filename = fileDialog.GetPath(); } - else - return wxGetEmptyString(); + + return filename; } @@ -172,17 +172,23 @@ wxString wxFileSelectorEx(const wxChar *title, int y) { - wxFileDialog fileDialog(parent, title ? title : wxT(""), defaultDir ? defaultDir : wxT(""), - defaultFileName ? defaultFileName : wxT(""), filter ? filter : wxT(""), flags, wxPoint(x, y)); + wxFileDialog fileDialog(parent, + title ? title : wxT(""), + defaultDir ? defaultDir : wxT(""), + defaultFileName ? defaultFileName : wxT(""), + filter ? filter : wxT(""), + flags, wxPoint(x, y)); + wxString filename; if ( fileDialog.ShowModal() == wxID_OK ) { - *defaultFilterIndex = fileDialog.GetFilterIndex(); - wxStrcpy(wxBuffer, (const wxChar *)fileDialog.GetPath()); - return wxBuffer; + if ( defaultFilterIndex ) + *defaultFilterIndex = fileDialog.GetFilterIndex(); + + filename = fileDialog.GetPath(); } - else - return wxGetEmptyString(); + + return filename; } wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message, diff --git a/src/msw/imaglist.cpp b/src/msw/imaglist.cpp index 48bd3c57a2..f8a26cd036 100644 --- a/src/msw/imaglist.cpp +++ b/src/msw/imaglist.cpp @@ -64,7 +64,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxImageList, wxObject) // returns the mask if it's valid, otherwise the bitmap mask and, if it's not // valid neither, a "solid" mask (no transparent zones at all) -static wxBitmap GetMaskForImage(const wxBitmap& bitmap, const wxBitmap& mask); +static HBITMAP GetMaskForImage(const wxBitmap& bitmap, const wxBitmap& mask); // ============================================================================ // implementation @@ -144,8 +144,7 @@ bool wxImageList::GetSize(int WXUNUSED(index), int &width, int &height) const // 'bitmap' and 'mask'. int wxImageList::Add(const wxBitmap& bitmap, const wxBitmap& mask) { - wxBitmap bmpMask = GetMaskForImage(bitmap, mask); - HBITMAP hbmpMask = wxInvertMask(GetHbitmapOf(bmpMask)); + HBITMAP hbmpMask = GetMaskForImage(bitmap, mask); int index = ImageList_Add(GetHImageList(), GetHbitmapOf(bitmap), hbmpMask); if ( index == -1 ) @@ -201,8 +200,7 @@ bool wxImageList::Replace(int index, wxFAIL_MSG(_T("ImageList_Replace not implemented in TWIN32")); return FALSE; #else - wxBitmap bmpMask = GetMaskForImage(bitmap, mask); - HBITMAP hbmpMask = wxInvertMask(GetHbitmapOf(bmpMask)); + HBITMAP hbmpMask = GetMaskForImage(bitmap, mask); bool ok = ImageList_Replace(GetHImageList(), index, GetHbitmapOf(bitmap), hbmpMask) != 0; @@ -314,36 +312,42 @@ bool wxImageList::Draw(int index, // helpers // ---------------------------------------------------------------------------- -static wxBitmap GetMaskForImage(const wxBitmap& bitmap, const wxBitmap& mask) +static HBITMAP GetMaskForImage(const wxBitmap& bitmap, const wxBitmap& mask) { - wxBitmap bmpMask; + HBITMAP hbmpMask; + wxBitmap *bmpMask = NULL; if ( mask.Ok() ) { - bmpMask = mask; + hbmpMask = GetHbitmapOf(mask); } else { wxMask *pMask = bitmap.GetMask(); if ( pMask ) { - bmpMask.SetHBITMAP(pMask->GetMaskBitmap()); + hbmpMask = (HBITMAP)pMask->GetMaskBitmap(); + } + else + { + // create a non transparent mask - apparently, this is needed under + // Win9x (it doesn't behave correctly if it's passed 0 mask) + bmpMask = new wxBitmap(bitmap.GetWidth(), bitmap.GetHeight(), 1); + + wxMemoryDC dcMem; + dcMem.SelectObject(*bmpMask); + dcMem.Clear(); + dcMem.SelectObject(wxNullBitmap); + + hbmpMask = GetHbitmapOf(*bmpMask); } } - if ( !bmpMask.Ok() ) - { - // create a non transparent mask - apparently, this is needed under - // Win9x (it doesn't behave correctly if it's passed 0 mask) - bmpMask.Create(bitmap.GetWidth(), bitmap.GetHeight(), 1); + // windows mask convention is opposite to the wxWindows one + HBITMAP hbmpMaskInv = wxInvertMask(hbmpMask); + delete bmpMask; - wxMemoryDC dcMem; - dcMem.SelectObject(bmpMask); - dcMem.Clear(); - dcMem.SelectObject(wxNullBitmap); - } - - return bmpMask; + return hbmpMaskInv; } #endif // Win95 diff --git a/src/msw/mdi.cpp b/src/msw/mdi.cpp index db7c4a295a..6d9792c740 100644 --- a/src/msw/mdi.cpp +++ b/src/msw/mdi.cpp @@ -925,15 +925,17 @@ bool wxMDIChildFrame::HandleCommand(WXWORD id, WXWORD cmd, WXHWND hwnd) return TRUE; } + bool processed; if (GetMenuBar() && GetMenuBar()->FindItem(id)) { - ProcessCommand(id); - return TRUE; + processed = ProcessCommand(id); } else - return FALSE; + { + processed = FALSE; + } - return TRUE; + return processed; } bool wxMDIChildFrame::HandleMDIActivate(long WXUNUSED(activate), diff --git a/src/msw/menu.cpp b/src/msw/menu.cpp index 67d416c466..48b0b30706 100644 --- a/src/msw/menu.cpp +++ b/src/msw/menu.cpp @@ -558,11 +558,9 @@ void wxMenuBar::Refresh() WXHMENU wxMenuBar::Create() { - if (m_hMenu != 0 ) + if ( m_hMenu != 0 ) return m_hMenu; - wxCHECK_MSG( !m_hMenu, TRUE, wxT("menubar already created") ); - m_hMenu = (WXHMENU)::CreateMenu(); if ( !m_hMenu ) diff --git a/src/msw/nativdlg.cpp b/src/msw/nativdlg.cpp index 9ce9195d15..5eef575db7 100644 --- a/src/msw/nativdlg.cpp +++ b/src/msw/nativdlg.cpp @@ -282,11 +282,9 @@ wxWindow* wxWindow::CreateWindowFromHWND(wxWindow* parent, WXHWND hWnd) win->SubclassWin(hWnd); win->AdoptAttributesFromHWND(); win->SetupColours(); - - return win; } - else - return NULL; + + return win; } // Make sure the window style (etc.) reflects the HWND style (roughly) diff --git a/src/msw/ole/automtn.cpp b/src/msw/ole/automtn.cpp index 9ea5f213aa..a5c49e721b 100644 --- a/src/msw/ole/automtn.cpp +++ b/src/msw/ole/automtn.cpp @@ -435,13 +435,9 @@ WXIDISPATCH* wxAutomationObject::GetDispatchProperty(const wxString& property, i { return (WXIDISPATCH*) retVariant.GetVoidPtr(); } - else - { - return (WXIDISPATCH*) NULL; - } } - else - return (WXIDISPATCH*) NULL; + + return (WXIDISPATCH*) NULL; } // A way of initialising another wxAutomationObject with a dispatch object diff --git a/src/msw/settings.cpp b/src/msw/settings.cpp index cd87ce1fb5..5e05b92cdf 100644 --- a/src/msw/settings.cpp +++ b/src/msw/settings.cpp @@ -171,6 +171,5 @@ int wxSystemSettings::GetSystemMetric(int index) default: return 0; } - return 0; } diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 635b50885c..41b6be66fc 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -2760,11 +2760,9 @@ bool wxWindow::HandleSetCursor(WXHWND hWnd, // cursor set, stop here return TRUE; } - else - { - // pass up the window chain - return FALSE; - } + + // pass up the window chain + return FALSE; } // --------------------------------------------------------------------------- diff --git a/src/msw/xpmhand.cpp b/src/msw/xpmhand.cpp index 1974d381f2..78459be100 100644 --- a/src/msw/xpmhand.cpp +++ b/src/msw/xpmhand.cpp @@ -67,7 +67,8 @@ static void XpmToBitmap(wxBitmap *bitmap, if (xmask) { wxMask *mask = new wxMask(); - mask->SetMaskBitmap((WXHBITMAP) wxInvertMask(xmask->bitmap)); + mask->SetMaskBitmap((WXHBITMAP) wxInvertMask(xmask->bitmap, + bm.bmWidth, bm.bmHeight)); bitmap->SetMask(mask); } } diff --git a/src/xpm/RdFToI.c b/src/xpm/RdFToI.c index 89cdc4ec0f..eff47d3ef3 100644 --- a/src/xpm/RdFToI.c +++ b/src/xpm/RdFToI.c @@ -155,8 +155,9 @@ OpenReadFile(filename, mdata) #endif { #ifndef NO_ZPIPE - char *compressfile, buf[BUFSIZ]; + char buf[BUFSIZ]; # ifdef STAT_ZFILE + char *compressfile; struct stat status; # endif #endif