From 426272a35e5727f8c2ca147a6b1eb865cc5e34d6 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 28 Oct 2007 00:08:27 +0000 Subject: [PATCH] define wxTIFFHandler ctor in the .cpp file even if wxUSE_STREAMS==0 as it's declared in the header in this case (this doesn't really make much sense as the class is unusable anyhow but the other handlers do it like this so let's do the same thing here for consistency and maybe fix all of them at once later) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49500 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/imagtiff.cpp | 107 ++++++++++++++++++++++++---------------- 1 file changed, 64 insertions(+), 43 deletions(-) diff --git a/src/common/imagtiff.cpp b/src/common/imagtiff.cpp index 39a2bb2d19..3a5e63fb5e 100644 --- a/src/common/imagtiff.cpp +++ b/src/common/imagtiff.cpp @@ -7,6 +7,14 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// +// ============================================================================ +// declarations +// ============================================================================ + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -30,7 +38,7 @@ extern "C" { #ifdef __DMC__ #include "tif_config.h" -#endif +#endif #include "tiff.h" #include "tiffio.h" } @@ -45,12 +53,67 @@ extern "C" #endif #endif +// ============================================================================ +// implementation +// ============================================================================ + +// ---------------------------------------------------------------------------- +// TIFF library error/warning handlers +// ---------------------------------------------------------------------------- + +extern "C" +{ + +static void +TIFFwxWarningHandler(const char* module, + const char* WXUNUSED_IN_UNICODE(fmt), + va_list WXUNUSED_IN_UNICODE(ap)) +{ + if (module != NULL) + wxLogWarning(_("tiff module: %s"), wxString::FromAscii(module).c_str()); + + // FIXME: this is not terrible informative but better than crashing! +#if wxUSE_UNICODE + wxLogWarning(_("TIFF library warning.")); +#else + wxVLogWarning(fmt, ap); +#endif +} + +static void +TIFFwxErrorHandler(const char* module, + const char* WXUNUSED_IN_UNICODE(fmt), + va_list WXUNUSED_IN_UNICODE(ap)) +{ + if (module != NULL) + wxLogError(_("tiff module: %s"), wxString::FromAscii(module).c_str()); + + // FIXME: as above +#if wxUSE_UNICODE + wxLogError(_("TIFF library error.")); +#else + wxVLogError(fmt, ap); +#endif +} + +} // extern "C" + //----------------------------------------------------------------------------- // wxTIFFHandler //----------------------------------------------------------------------------- IMPLEMENT_DYNAMIC_CLASS(wxTIFFHandler,wxImageHandler) +wxTIFFHandler::wxTIFFHandler() +{ + m_name = wxT("TIFF file"); + m_extension = wxT("tif"); + m_type = wxBITMAP_TYPE_TIF; + m_mime = wxT("image/tiff"); + TIFFSetWarningHandler((TIFFErrorHandler) TIFFwxWarningHandler); + TIFFSetErrorHandler((TIFFErrorHandler) TIFFwxErrorHandler); +} + #if wxUSE_STREAMS // helper to translate our, possibly 64 bit, wxFileOffset to TIFF, always 32 @@ -168,38 +231,6 @@ wxTIFFUnmapProc(thandle_t WXUNUSED(handle), { } -static void -TIFFwxWarningHandler(const char* module, - const char* WXUNUSED_IN_UNICODE(fmt), - va_list WXUNUSED_IN_UNICODE(ap)) -{ - if (module != NULL) - wxLogWarning(_("tiff module: %s"), wxString::FromAscii(module).c_str()); - - // FIXME: this is not terrible informative but better than crashing! -#if wxUSE_UNICODE - wxLogWarning(_("TIFF library warning.")); -#else - wxVLogWarning(fmt, ap); -#endif -} - -static void -TIFFwxErrorHandler(const char* module, - const char* WXUNUSED_IN_UNICODE(fmt), - va_list WXUNUSED_IN_UNICODE(ap)) -{ - if (module != NULL) - wxLogError(_("tiff module: %s"), wxString::FromAscii(module).c_str()); - - // FIXME: as above -#if wxUSE_UNICODE - wxLogError(_("TIFF library error.")); -#else - wxVLogError(fmt, ap); -#endif -} - } // extern "C" TIFF* @@ -226,16 +257,6 @@ TIFFwxOpen(wxOutputStream &stream, const char* name, const char* mode) return tif; } -wxTIFFHandler::wxTIFFHandler() -{ - m_name = wxT("TIFF file"); - m_extension = wxT("tif"); - m_type = wxBITMAP_TYPE_TIF; - m_mime = wxT("image/tiff"); - TIFFSetWarningHandler((TIFFErrorHandler) TIFFwxWarningHandler); - TIFFSetErrorHandler((TIFFErrorHandler) TIFFwxErrorHandler); -} - bool wxTIFFHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose, int index ) { if (index == -1) -- 2.45.2