From d033a859efd36e8c1cf710259982bbe131be7194 Mon Sep 17 00:00:00 2001 From: Julian Storer Date: Mon, 2 Aug 2010 11:33:05 +0100 Subject: [PATCH] Fixed some namespace issues with png and zlib. Changed the way the DBG macro works to allow expressions like DBG ("foo" << 123 << "bar"), so that it's easier to dump out numbers. --- .../Project/jucer_ProjectTreeViewBase.cpp | 4 ++ juce_amalgamated.cpp | 68 ++++++++----------- juce_amalgamated.h | 7 +- src/core/juce_PlatformDefs.h | 2 +- src/core/juce_StandardHeader.h | 2 +- .../image_file_formats/juce_PNGLoader.cpp | 57 ++++++++-------- .../imaging/image_file_formats/pnglib/png.h | 4 +- .../juce_GZIPDecompressorInputStream.cpp | 51 +++++++------- src/io/streams/juce_MemoryOutputStream.h | 3 +- src/io/streams/zlib/zlib.h | 4 +- src/native/juce_mac_NativeCode.mm | 1 + src/native/linux/juce_linux_Clipboard.cpp | 4 -- src/native/windows/juce_win32_WASAPI.cpp | 2 +- 13 files changed, 98 insertions(+), 111 deletions(-) diff --git a/extras/Jucer (experimental)/Source/Project/jucer_ProjectTreeViewBase.cpp b/extras/Jucer (experimental)/Source/Project/jucer_ProjectTreeViewBase.cpp index eae2853345..43477eaca2 100644 --- a/extras/Jucer (experimental)/Source/Project/jucer_ProjectTreeViewBase.cpp +++ b/extras/Jucer (experimental)/Source/Project/jucer_ProjectTreeViewBase.cpp @@ -242,8 +242,12 @@ void ProjectTreeViewBase::deleteAllSelectedItems() for (i = itemsToRemove.size(); --i >= 0;) { ProjectTreeViewBase* itemToRemove = treeRootItem->findTreeViewItem (*itemsToRemove.getUnchecked(i)); + if (itemToRemove != 0) + { + OpenDocumentManager::getInstance()->closeFile (itemToRemove->getFile(), false); itemToRemove->deleteItem(); + } } } } diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 0b921e9dc7..6f8fb61cd6 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -96140,7 +96140,7 @@ typedef uLong FAR uLongf; /*** End of inlined file: zconf.h ***/ #ifdef __cplusplus -extern "C" { +//extern "C" { #endif #define ZLIB_VERSION "1.2.3" @@ -97448,7 +97448,7 @@ ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); #ifdef __cplusplus -} +//} #endif #endif /* ZLIB_H */ @@ -97633,12 +97633,10 @@ END_JUCE_NAMESPACE namespace zlibNamespace { #if JUCE_INCLUDE_ZLIB_CODE - extern "C" - { - #undef OS_CODE - #undef fdopen - #define ZLIB_INTERNAL - #define NO_DUMMY_DECL + #undef OS_CODE + #undef fdopen + #define ZLIB_INTERNAL + #define NO_DUMMY_DECL /*** Start of inlined file: adler32.c ***/ @@ -97849,8 +97847,8 @@ uLong ZEXPORT compressBound (uLong sourceLen) } /*** End of inlined file: compress.c ***/ - #undef DO1 - #undef DO8 + #undef DO1 + #undef DO8 /*** Start of inlined file: crc32.c ***/ /* @(#) $Id: crc32.c,v 1.1 2007/06/07 17:54:37 jules_rms Exp $ */ @@ -101458,13 +101456,13 @@ void inflate_fast (z_streamp strm, unsigned start) #endif /* !ASMINF */ /*** End of inlined file: inffast.c ***/ - #undef PULLBYTE - #undef LOAD - #undef RESTORE - #undef INITBITS - #undef NEEDBITS - #undef DROPBITS - #undef BYTEBITS + #undef PULLBYTE + #undef LOAD + #undef RESTORE + #undef INITBITS + #undef NEEDBITS + #undef DROPBITS + #undef BYTEBITS /*** Start of inlined file: inflate.c ***/ /* @@ -104846,8 +104844,7 @@ void zcfree (voidpf opaque, voidpf ptr) #endif /* MY_ZCALLOC */ /*** End of inlined file: zutil.c ***/ - #undef Byte - } + #undef Byte #else #include #endif @@ -211043,18 +211040,16 @@ namespace pnglibNamespace #if JUCE_INCLUDE_PNGLIB_CODE - #if _MSC_VER != 1310 - using ::calloc; // (causes conflict in VS.NET 2003) - using ::malloc; - using ::free; - #endif + #if _MSC_VER != 1310 + using ::calloc; // (causes conflict in VS.NET 2003) + using ::malloc; + using ::free; + #endif - extern "C" - { - using ::abs; - #define PNG_INTERNAL - #define NO_DUMMY_DECL - #define PNG_SETJMP_NOT_SUPPORTED + using ::abs; + #define PNG_INTERNAL + #define NO_DUMMY_DECL + #define PNG_SETJMP_NOT_SUPPORTED /*** Start of inlined file: png.h ***/ @@ -213009,7 +213004,7 @@ typedef z_stream FAR * png_zstreamp; /* Inhibit C++ name-mangling for libpng functions but not for system calls. */ #ifdef __cplusplus -extern "C" { +//extern "C" { #endif /* __cplusplus */ /* This file is arranged in several sections. The first section contains @@ -216090,7 +216085,7 @@ png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); #endif /* PNG_INTERNAL */ #ifdef __cplusplus -} +//} #endif #endif /* PNG_VERSION_INFO_ONLY */ @@ -216098,7 +216093,7 @@ png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); #endif /* PNG_H */ /*** End of inlined file: png.h ***/ - #define PNG_NO_EXTERN + #define PNG_NO_EXTERN /*** Start of inlined file: png.c ***/ /* png.c - location for general purpose libpng functions @@ -236448,7 +236443,6 @@ png_write_filtered_row(png_structp png_ptr, png_bytep filtered_row) #endif /* PNG_WRITE_SUPPORTED */ /*** End of inlined file: pngwutil.c ***/ - } #else extern "C" { @@ -251680,7 +251674,7 @@ public: while (! threadShouldExit()) { - const DWORD result = useExclusiveMode ? WaitForSingleObject (inputDevice->clientEvent, 1000) + const DWORD result = useExclusiveMode ? (inputDevice != 0 ? WaitForSingleObject (inputDevice->clientEvent, 1000) : S_OK) : WaitForMultipleObjects (numEvents, events, true, 1000); if (result == WAIT_TIMEOUT) continue; @@ -254765,10 +254759,6 @@ void* PlatformUtilities::getProcedureEntryPoint (void* libraryHandle, const Stri // compiled on its own). #if JUCE_INCLUDED_FILE -#if JUCE_DEBUG - #define JUCE_DEBUG_XERRORS 1 -#endif - extern Display* display; extern Window juce_messageWindowHandle; diff --git a/juce_amalgamated.h b/juce_amalgamated.h index ec2991f594..09cdb26584 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -64,7 +64,7 @@ */ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 52 -#define JUCE_BUILDNUMBER 47 +#define JUCE_BUILDNUMBER 48 /** Current Juce version number. @@ -536,7 +536,7 @@ @see Logger::outputDebugString */ - #define DBG(dbgtext) JUCE_NAMESPACE::Logger::outputDebugString (dbgtext); + #define DBG(dbgtext) { String tempDbgBuf; tempDbgBuf << dbgtext; JUCE_NAMESPACE::Logger::outputDebugString (tempDbgBuf); } // Assertions.. @@ -16772,7 +16772,8 @@ private: #ifndef __JUCE_MEMORYOUTPUTSTREAM_JUCEHEADER__ #define __JUCE_MEMORYOUTPUTSTREAM_JUCEHEADER__ -/** Writes data to an internal memory buffer, which grows as required. +/** + Writes data to an internal memory buffer, which grows as required. The data that was written into the stream can then be accessed later as a contiguous block of memory. diff --git a/src/core/juce_PlatformDefs.h b/src/core/juce_PlatformDefs.h index 6cfd1e4e31..e676788e63 100644 --- a/src/core/juce_PlatformDefs.h +++ b/src/core/juce_PlatformDefs.h @@ -68,7 +68,7 @@ @see Logger::outputDebugString */ - #define DBG(dbgtext) JUCE_NAMESPACE::Logger::outputDebugString (dbgtext); + #define DBG(dbgtext) { String tempDbgBuf; tempDbgBuf << dbgtext; JUCE_NAMESPACE::Logger::outputDebugString (tempDbgBuf); } //============================================================================== // Assertions.. diff --git a/src/core/juce_StandardHeader.h b/src/core/juce_StandardHeader.h index 59d1e31290..fab164423d 100644 --- a/src/core/juce_StandardHeader.h +++ b/src/core/juce_StandardHeader.h @@ -33,7 +33,7 @@ */ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 52 -#define JUCE_BUILDNUMBER 47 +#define JUCE_BUILDNUMBER 48 /** Current Juce version number. diff --git a/src/gui/graphics/imaging/image_file_formats/juce_PNGLoader.cpp b/src/gui/graphics/imaging/image_file_formats/juce_PNGLoader.cpp index 1efe035ba9..b90714a7ba 100644 --- a/src/gui/graphics/imaging/image_file_formats/juce_PNGLoader.cpp +++ b/src/gui/graphics/imaging/image_file_formats/juce_PNGLoader.cpp @@ -48,39 +48,36 @@ namespace pnglibNamespace #if JUCE_INCLUDE_PNGLIB_CODE - #if _MSC_VER != 1310 - using ::calloc; // (causes conflict in VS.NET 2003) - using ::malloc; - using ::free; - #endif + #if _MSC_VER != 1310 + using ::calloc; // (causes conflict in VS.NET 2003) + using ::malloc; + using ::free; + #endif - extern "C" - { - using ::abs; - #define PNG_INTERNAL - #define NO_DUMMY_DECL - #define PNG_SETJMP_NOT_SUPPORTED + using ::abs; + #define PNG_INTERNAL + #define NO_DUMMY_DECL + #define PNG_SETJMP_NOT_SUPPORTED - #include "pnglib/png.h" - #include "pnglib/pngconf.h" + #include "pnglib/png.h" + #include "pnglib/pngconf.h" - #define PNG_NO_EXTERN - #include "pnglib/png.c" - #include "pnglib/pngerror.c" - #include "pnglib/pngget.c" - #include "pnglib/pngmem.c" - #include "pnglib/pngread.c" - #include "pnglib/pngpread.c" - #include "pnglib/pngrio.c" - #include "pnglib/pngrtran.c" - #include "pnglib/pngrutil.c" - #include "pnglib/pngset.c" - #include "pnglib/pngtrans.c" - #include "pnglib/pngwio.c" - #include "pnglib/pngwrite.c" - #include "pnglib/pngwtran.c" - #include "pnglib/pngwutil.c" - } + #define PNG_NO_EXTERN + #include "pnglib/png.c" + #include "pnglib/pngerror.c" + #include "pnglib/pngget.c" + #include "pnglib/pngmem.c" + #include "pnglib/pngread.c" + #include "pnglib/pngpread.c" + #include "pnglib/pngrio.c" + #include "pnglib/pngrtran.c" + #include "pnglib/pngrutil.c" + #include "pnglib/pngset.c" + #include "pnglib/pngtrans.c" + #include "pnglib/pngwio.c" + #include "pnglib/pngwrite.c" + #include "pnglib/pngwtran.c" + #include "pnglib/pngwutil.c" #else extern "C" { diff --git a/src/gui/graphics/imaging/image_file_formats/pnglib/png.h b/src/gui/graphics/imaging/image_file_formats/pnglib/png.h index 367dfb47e5..4dda801bf0 100644 --- a/src/gui/graphics/imaging/image_file_formats/pnglib/png.h +++ b/src/gui/graphics/imaging/image_file_formats/pnglib/png.h @@ -448,7 +448,7 @@ /* Inhibit C++ name-mangling for libpng functions but not for system calls. */ #ifdef __cplusplus -extern "C" { +//extern "C" { #endif /* __cplusplus */ /* This file is arranged in several sections. The first section contains @@ -3531,7 +3531,7 @@ png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); #endif /* PNG_INTERNAL */ #ifdef __cplusplus -} +//} #endif #endif /* PNG_VERSION_INFO_ONLY */ diff --git a/src/io/streams/juce_GZIPDecompressorInputStream.cpp b/src/io/streams/juce_GZIPDecompressorInputStream.cpp index ed9aeb9b21..e6a4ea3b8a 100644 --- a/src/io/streams/juce_GZIPDecompressorInputStream.cpp +++ b/src/io/streams/juce_GZIPDecompressorInputStream.cpp @@ -33,33 +33,30 @@ namespace zlibNamespace { #if JUCE_INCLUDE_ZLIB_CODE - extern "C" - { - #undef OS_CODE - #undef fdopen - #define ZLIB_INTERNAL - #define NO_DUMMY_DECL - #include "zlib/zlib.h" - #include "zlib/adler32.c" - #include "zlib/compress.c" - #undef DO1 - #undef DO8 - #include "zlib/crc32.c" - #include "zlib/deflate.c" - #include "zlib/inffast.c" - #undef PULLBYTE - #undef LOAD - #undef RESTORE - #undef INITBITS - #undef NEEDBITS - #undef DROPBITS - #undef BYTEBITS - #include "zlib/inflate.c" - #include "zlib/inftrees.c" - #include "zlib/trees.c" - #include "zlib/zutil.c" - #undef Byte - } + #undef OS_CODE + #undef fdopen + #define ZLIB_INTERNAL + #define NO_DUMMY_DECL + #include "zlib/zlib.h" + #include "zlib/adler32.c" + #include "zlib/compress.c" + #undef DO1 + #undef DO8 + #include "zlib/crc32.c" + #include "zlib/deflate.c" + #include "zlib/inffast.c" + #undef PULLBYTE + #undef LOAD + #undef RESTORE + #undef INITBITS + #undef NEEDBITS + #undef DROPBITS + #undef BYTEBITS + #include "zlib/inflate.c" + #include "zlib/inftrees.c" + #include "zlib/trees.c" + #include "zlib/zutil.c" + #undef Byte #else #include #endif diff --git a/src/io/streams/juce_MemoryOutputStream.h b/src/io/streams/juce_MemoryOutputStream.h index 1f65919819..3d8eb24738 100644 --- a/src/io/streams/juce_MemoryOutputStream.h +++ b/src/io/streams/juce_MemoryOutputStream.h @@ -32,7 +32,8 @@ //============================================================================== -/** Writes data to an internal memory buffer, which grows as required. +/** + Writes data to an internal memory buffer, which grows as required. The data that was written into the stream can then be accessed later as a contiguous block of memory. diff --git a/src/io/streams/zlib/zlib.h b/src/io/streams/zlib/zlib.h index 6c4a89d962..bdf8af7d02 100644 --- a/src/io/streams/zlib/zlib.h +++ b/src/io/streams/zlib/zlib.h @@ -34,7 +34,7 @@ #include "zconf.h" #ifdef __cplusplus -extern "C" { +//extern "C" { #endif #define ZLIB_VERSION "1.2.3" @@ -1352,7 +1352,7 @@ ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); #ifdef __cplusplus -} +//} #endif #endif /* ZLIB_H */ diff --git a/src/native/juce_mac_NativeCode.mm b/src/native/juce_mac_NativeCode.mm index 8e4f5e18a0..47e6356afc 100644 --- a/src/native/juce_mac_NativeCode.mm +++ b/src/native/juce_mac_NativeCode.mm @@ -53,6 +53,7 @@ BEGIN_JUCE_NAMESPACE #include "../io/streams/juce_MemoryInputStream.h" #include "../io/streams/juce_BufferedInputStream.h" #include "../core/juce_PlatformUtilities.h" +#include "../core/juce_Initialisation.h" #include "../text/juce_LocalisedStrings.h" #include "../text/juce_XmlDocument.h" #include "../utilities/juce_DeletedAtShutdown.h" diff --git a/src/native/linux/juce_linux_Clipboard.cpp b/src/native/linux/juce_linux_Clipboard.cpp index 12af4f5328..5294385686 100644 --- a/src/native/linux/juce_linux_Clipboard.cpp +++ b/src/native/linux/juce_linux_Clipboard.cpp @@ -28,10 +28,6 @@ #if JUCE_INCLUDED_FILE //============================================================================== -#if JUCE_DEBUG - #define JUCE_DEBUG_XERRORS 1 -#endif - extern Display* display; extern Window juce_messageWindowHandle; diff --git a/src/native/windows/juce_win32_WASAPI.cpp b/src/native/windows/juce_win32_WASAPI.cpp index 2e44320d74..cd0a470ed8 100644 --- a/src/native/windows/juce_win32_WASAPI.cpp +++ b/src/native/windows/juce_win32_WASAPI.cpp @@ -841,7 +841,7 @@ public: while (! threadShouldExit()) { - const DWORD result = useExclusiveMode ? WaitForSingleObject (inputDevice->clientEvent, 1000) + const DWORD result = useExclusiveMode ? (inputDevice != 0 ? WaitForSingleObject (inputDevice->clientEvent, 1000) : S_OK) : WaitForMultipleObjects (numEvents, events, true, 1000); if (result == WAIT_TIMEOUT) continue;