diff --git a/source/modules/juce_audio_devices/native/juce_win32_ASIO.cpp b/source/modules/juce_audio_devices/native/juce_win32_ASIO.cpp index 321abdc44..e6d802a98 100644 --- a/source/modules/juce_audio_devices/native/juce_win32_ASIO.cpp +++ b/source/modules/juce_audio_devices/native/juce_win32_ASIO.cpp @@ -941,9 +941,7 @@ private: } bufferSizes.addIfNotAlreadyThere (preferredSize); - - DefaultElementComparator comparator; - bufferSizes.sort (comparator); + bufferSizes.sort(); } double getSampleRate() const diff --git a/source/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp b/source/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp index 6c9d6c858..6a631ddb9 100644 --- a/source/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp +++ b/source/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp @@ -889,17 +889,11 @@ public: void readMaxLevels (int64 startSampleInFile, int64 numSamples, Range* results, int numChannelsToRead) override { - if (numSamples <= 0) - { - for (int i = 0; i < numChannelsToRead; ++i) - results[i] = Range(); + numSamples = jmin (numSamples, lengthInSamples - startSampleInFile); - return; - } - - if (map == nullptr || ! mappedSection.contains (Range (startSampleInFile, startSampleInFile + numSamples))) + if (map == nullptr || numSamples <= 0 || ! mappedSection.contains (Range (startSampleInFile, startSampleInFile + numSamples))) { - jassertfalse; // you must make sure that the window contains all the samples you're going to attempt to read. + jassert (numSamples <= 0); // you must make sure that the window contains all the samples you're going to attempt to read. for (int i = 0; i < numChannelsToRead; ++i) results[i] = Range(); diff --git a/source/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp b/source/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp index 28b494ff4..a1f8323d2 100644 --- a/source/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp +++ b/source/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp @@ -650,17 +650,23 @@ namespace WavFileHelpers { while (input.getPosition() < chunkEnd) { - const int infoType = input.readInt(); - const int64 infoLength = jlimit ((int64) 0, chunkEnd - input.getPosition(), (int64) input.readInt()); + const int infoType = input.readInt(); - for (int i = 0; i < numElementsInArray (types); ++i) + int64 infoLength = chunkEnd - input.getPosition(); + + if (infoLength > 0) { - if (isMatchingTypeIgnoringCase (infoType, types[i])) + infoLength = jlimit ((int64) 0, infoLength, (int64) input.readInt()); + + for (int i = 0; i < numElementsInArray (types); ++i) { - MemoryBlock mb; - input.readIntoMemoryBlock (mb, (ssize_t) infoLength); - values.set (types[i], mb.toString()); - break; + if (isMatchingTypeIgnoringCase (infoType, types[i])) + { + MemoryBlock mb; + input.readIntoMemoryBlock (mb, (ssize_t) infoLength); + values.set (types[i], mb.toString()); + break; + } } } } @@ -1513,17 +1519,11 @@ public: void readMaxLevels (int64 startSampleInFile, int64 numSamples, Range* results, int numChannelsToRead) override { - if (numSamples <= 0) - { - for (int i = 0; i < numChannelsToRead; ++i) - results[i] = Range(); - - return; - } + numSamples = jmin (numSamples, lengthInSamples - startSampleInFile); - if (map == nullptr || ! mappedSection.contains (Range (startSampleInFile, startSampleInFile + numSamples))) + if (map == nullptr || numSamples <= 0 || ! mappedSection.contains (Range (startSampleInFile, startSampleInFile + numSamples))) { - jassertfalse; // you must make sure that the window contains all the samples you're going to attempt to read. + jassert (numSamples <= 0); // you must make sure that the window contains all the samples you're going to attempt to read. for (int i = 0; i < numChannelsToRead; ++i) results[i] = Range(); diff --git a/source/modules/juce_core/containers/juce_Array.h b/source/modules/juce_core/containers/juce_Array.h index 2211fcf85..6eb62dd2b 100644 --- a/source/modules/juce_core/containers/juce_Array.h +++ b/source/modules/juce_core/containers/juce_Array.h @@ -1053,6 +1053,16 @@ public: } //============================================================================== + /** Sorts the array using a default comparison operation. + If the type of your elements isn't supported by the DefaultElementComparator class + then you may need to use the other version of sort, which takes a custom comparator. + */ + void sort() + { + DefaultElementComparator comparator; + sort (comparator); + } + /** Sorts the elements in the array. This will use a comparator object to sort the elements into order. The object @@ -1081,7 +1091,7 @@ public: */ template void sort (ElementComparator& comparator, - const bool retainOrderOfEquivalentItems = false) const + const bool retainOrderOfEquivalentItems = false) { const ScopedLockType lock (getLock()); (void) comparator; // if you pass in an object with a static compareElements() method, this diff --git a/source/modules/juce_core/files/juce_File.cpp b/source/modules/juce_core/files/juce_File.cpp index de6790e9c..a8c2c690f 100644 --- a/source/modules/juce_core/files/juce_File.cpp +++ b/source/modules/juce_core/files/juce_File.cpp @@ -911,7 +911,7 @@ bool File::createSymbolicLink (const File& linkFileToCreate, bool overwriteExist } return true; - #elif JUCE_WINDOWS + #elif JUCE_MSVC return CreateSymbolicLink (linkFileToCreate.getFullPathName().toWideCharPointer(), fullPath.toWideCharPointer(), isDirectory() ? SYMBOLIC_LINK_FLAG_DIRECTORY : 0) != FALSE; diff --git a/source/modules/juce_core/native/juce_BasicNativeHeaders.h b/source/modules/juce_core/native/juce_BasicNativeHeaders.h index 933285a24..c926ecf92 100644 --- a/source/modules/juce_core/native/juce_BasicNativeHeaders.h +++ b/source/modules/juce_core/native/juce_BasicNativeHeaders.h @@ -114,7 +114,7 @@ #if JUCE_MINGW #include #include - #define alloca __builtin_alloca + #define alloca(x) __builtin_alloca((x)) #else #include #include diff --git a/source/modules/juce_core/native/juce_win32_Files.cpp b/source/modules/juce_core/native/juce_win32_Files.cpp index 18a1999f5..81a0bca64 100644 --- a/source/modules/juce_core/native/juce_win32_Files.cpp +++ b/source/modules/juce_core/native/juce_win32_Files.cpp @@ -643,6 +643,7 @@ bool File::isShortcut() const File File::getLinkedTarget() const { +#if JUCE_MSVC { HANDLE h = CreateFile (getFullPathName().toWideCharPointer(), GENERIC_READ, FILE_SHARE_READ, nullptr, @@ -662,13 +663,21 @@ File File::getLinkedTarget() const if (requiredSize > 0) { CloseHandle (h); - return File (String (buffer)); + + const StringRef prefix ("\\\\?\\"); + const String path (buffer); + + // It turns out that GetFinalPathNameByHandleW prepends \\?\ to the path. + // This is not a bug, it's feature. See MSDN for more information. + return File (path.startsWith (prefix) ? path.substring (prefix.length()) + : path); } } CloseHandle (h); } } +#endif File result (*this); String p (getFullPathName()); diff --git a/source/modules/juce_core/system/juce_StandardHeader.h b/source/modules/juce_core/system/juce_StandardHeader.h index dded5d8d6..bf5d2de87 100644 --- a/source/modules/juce_core/system/juce_StandardHeader.h +++ b/source/modules/juce_core/system/juce_StandardHeader.h @@ -36,7 +36,7 @@ */ #define JUCE_MAJOR_VERSION 4 #define JUCE_MINOR_VERSION 0 -#define JUCE_BUILDNUMBER 1 +#define JUCE_BUILDNUMBER 2 /** Current Juce version number. diff --git a/source/modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp b/source/modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp index a808ab802..ec90603ac 100644 --- a/source/modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp +++ b/source/modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp @@ -30,7 +30,7 @@ class GZIPCompressorOutputStream::GZIPCompressorHelper { public: GZIPCompressorHelper (const int compressionLevel, const int windowBits) - : compLevel ((compressionLevel < 1 || compressionLevel > 9) ? -1 : compressionLevel), + : compLevel ((compressionLevel < 0 || compressionLevel > 9) ? -1 : compressionLevel), isFirstDeflate (true), streamIsValid (false), finished (false) diff --git a/source/modules/juce_core/zip/juce_GZIPCompressorOutputStream.h b/source/modules/juce_core/zip/juce_GZIPCompressorOutputStream.h index 5ce8c561a..4cc639c38 100644 --- a/source/modules/juce_core/zip/juce_GZIPCompressorOutputStream.h +++ b/source/modules/juce_core/zip/juce_GZIPCompressorOutputStream.h @@ -48,9 +48,9 @@ public: @param destStream the stream into which the compressed data should be written - @param compressionLevel how much to compress the data, between 1 and 9, where - 1 is the fastest/lowest compression, and 9 is the - slowest/highest compression. Any value outside this range + @param compressionLevel how much to compress the data, between 0 and 9, where + 0 is non-compressed storage, 1 is the fastest/lowest compression, + and 9 is the slowest/highest compression. Any value outside this range indicates that a default compression level should be used. @param deleteDestStreamWhenDestroyed whether or not to delete the destStream object when this stream is destroyed @@ -59,7 +59,7 @@ public: its value for some reason */ GZIPCompressorOutputStream (OutputStream* destStream, - int compressionLevel = 0, + int compressionLevel = -1, bool deleteDestStreamWhenDestroyed = false, int windowBits = 0); diff --git a/source/modules/juce_gui_basics/widgets/juce_TextEditor.cpp b/source/modules/juce_gui_basics/widgets/juce_TextEditor.cpp index ee7e7b50f..41b8f4d82 100644 --- a/source/modules/juce_gui_basics/widgets/juce_TextEditor.cpp +++ b/source/modules/juce_gui_basics/widgets/juce_TextEditor.cpp @@ -1084,6 +1084,7 @@ void TextEditor::colourChanged() void TextEditor::lookAndFeelChanged() { + caret = nullptr; recreateCaret(); repaint(); }