From 9332efc10d8be148ad7aaa5f51accf6d866696ea Mon Sep 17 00:00:00 2001 From: Julian Storer Date: Tue, 13 Sep 2011 18:12:24 +0100 Subject: [PATCH] Fix for subtle win32 mouse-button issue. Minor bwav fix. --- .../codecs/juce_WavAudioFormat.cpp | 12 ++++++---- modules/juce_core/files/juce_TemporaryFile.h | 1 - .../zip/juce_GZIPCompressorOutputStream.cpp | 8 +++---- .../native/juce_win32_Windowing.cpp | 24 +++++++++---------- 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp index 48d2c89e69..ae70f36637 100644 --- a/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp @@ -1083,10 +1083,14 @@ bool WavAudioFormat::replaceMetadataInFile (const File& wavFile, const StringPai const int64 oldSize = wavFile.getSize(); { - ScopedPointer out (wavFile.createOutputStream()); - out->setPosition (bwavPos); - *out << chunk; - out->setPosition (oldSize); + FileOutputStream out (wavFile); + + if (! out.failedToOpen()) + { + out.setPosition (bwavPos); + out << chunk; + out.setPosition (oldSize); + } } jassert (wavFile.getSize() == oldSize); diff --git a/modules/juce_core/files/juce_TemporaryFile.h b/modules/juce_core/files/juce_TemporaryFile.h index ef09ebe482..38e0982853 100644 --- a/modules/juce_core/files/juce_TemporaryFile.h +++ b/modules/juce_core/files/juce_TemporaryFile.h @@ -52,7 +52,6 @@ if (out != nullptr) { out->write ( ...etc ) - out->flush(); out = nullptr; // (deletes the stream) // ..now we've finished writing, this will rename the temp file to diff --git a/modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp b/modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp index e7bbe6840b..57293bbce2 100644 --- a/modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp +++ b/modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp @@ -214,11 +214,11 @@ public: { GZIPCompressorOutputStream zipper (&compressed, rng.nextInt (10), false); - + for (int j = rng.nextInt (100); --j >= 0;) { MemoryBlock data (rng.nextInt (2000) + 1); - + for (int k = data.getSize(); --k >= 0;) data[k] = (char) rng.nextInt (255); @@ -233,10 +233,10 @@ public: uncompressed.writeFromInputStream (unzipper, -1); } - + expectEquals ((int) uncompressed.getDataSize(), (int) original.getDataSize()); - + if (original.getDataSize() == uncompressed.getDataSize()) expect (memcmp (uncompressed.getData(), original.getData(), diff --git a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp index b69f8d66b7..b9e8962626 100644 --- a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp @@ -144,7 +144,6 @@ const int KeyPress::rewindKey = 0x30003; class WindowsBitmapImage : public Image::SharedImage { public: - //============================================================================== WindowsBitmapImage (const Image::PixelFormat format_, const int w, const int h, const bool clearImage) : Image::SharedImage (format_, w, h) @@ -155,24 +154,24 @@ public: lineStride = -((w * pixelStride + 3) & ~3); zerostruct (bitmapInfo); - bitmapInfo.bV4Size = sizeof (BITMAPV4HEADER); - bitmapInfo.bV4Width = w; - bitmapInfo.bV4Height = h; - bitmapInfo.bV4Planes = 1; - bitmapInfo.bV4CSType = 1; + bitmapInfo.bV4Size = sizeof (BITMAPV4HEADER); + bitmapInfo.bV4Width = w; + bitmapInfo.bV4Height = h; + bitmapInfo.bV4Planes = 1; + bitmapInfo.bV4CSType = 1; bitmapInfo.bV4BitCount = (unsigned short) (pixelStride * 8); if (format_ == Image::ARGB) { - bitmapInfo.bV4AlphaMask = 0xff000000; - bitmapInfo.bV4RedMask = 0xff0000; - bitmapInfo.bV4GreenMask = 0xff00; - bitmapInfo.bV4BlueMask = 0xff; - bitmapInfo.bV4V4Compression = BI_BITFIELDS; + bitmapInfo.bV4AlphaMask = 0xff000000; + bitmapInfo.bV4RedMask = 0xff0000; + bitmapInfo.bV4GreenMask = 0xff00; + bitmapInfo.bV4BlueMask = 0xff; + bitmapInfo.bV4V4Compression = BI_BITFIELDS; } else { - bitmapInfo.bV4V4Compression = BI_RGB; + bitmapInfo.bV4V4Compression = BI_RGB; } HDC dc = GetDC (0); @@ -1379,6 +1378,7 @@ private: if (! isMouseOver) { isMouseOver = true; + ModifierKeys::getCurrentModifiersRealtime(); // (This avoids a rare stuck-button problem when focus is lost unexpectedly) updateKeyModifiers(); TRACKMOUSEEVENT tme;