diff --git a/extras/Introjucer/Source/Application/jucer_Application.h b/extras/Introjucer/Source/Application/jucer_Application.h index a941b0c0fb..f0586fb2d6 100644 --- a/extras/Introjucer/Source/Application/jucer_Application.h +++ b/extras/Introjucer/Source/Application/jucer_Application.h @@ -80,16 +80,16 @@ public: if (mainWindows.size() == 0) createNewMainWindow()->makeVisible(); - #if JUCE_MAC + #if JUCE_MAC MenuBarModel::setMacMainMenu (menuModel); - #endif + #endif } void shutdown() { - #if JUCE_MAC + #if JUCE_MAC MenuBarModel::setMacMainMenu (nullptr); - #endif + #endif menuModel = nullptr; StoredSettings::deleteInstance(); diff --git a/extras/Introjucer/Source/Project/jucer_ProjectInformationComponent.cpp b/extras/Introjucer/Source/Project/jucer_ProjectInformationComponent.cpp index 0ae0940c52..1829c7c529 100644 --- a/extras/Introjucer/Source/Project/jucer_ProjectInformationComponent.cpp +++ b/extras/Introjucer/Source/Project/jucer_ProjectInformationComponent.cpp @@ -232,7 +232,7 @@ private: public: MissingDependenciesComponent (Project& project_, ModuleList& moduleList_, const String& moduleID_) : PropertyComponent ("Dependencies", 100), - project (project_), moduleList (moduleList), moduleID (moduleID_), + project (project_), moduleList (moduleList_), moduleID (moduleID_), fixButton ("Enable Required Modules") { const ModuleList::Module* module = moduleList.findModuleInfo (moduleID); diff --git a/modules/juce_audio_formats/format/juce_AudioFormatReader.h b/modules/juce_audio_formats/format/juce_AudioFormatReader.h index 32660d3572..9532a8d5e1 100644 --- a/modules/juce_audio_formats/format/juce_AudioFormatReader.h +++ b/modules/juce_audio_formats/format/juce_AudioFormatReader.h @@ -118,7 +118,7 @@ public: and the buffer. */ void read (AudioSampleBuffer* buffer, - int startSample, + int startSampleInDestBuffer, int numSamples, int64 readerStartSample, bool useReaderLeftChan, diff --git a/modules/juce_core/containers/juce_Array.h b/modules/juce_core/containers/juce_Array.h index c23ccca4b8..6f6a63bf90 100644 --- a/modules/juce_core/containers/juce_Array.h +++ b/modules/juce_core/containers/juce_Array.h @@ -88,6 +88,7 @@ public: : data (static_cast &&> (other.data)), numUsed (other.numUsed) { + other.numUsed = 0; } #endif @@ -141,14 +142,7 @@ public: #if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS Array& operator= (Array&& other) noexcept { - if (this != &other) - { - deleteAllElements(); - - data = static_cast &&> (other.data); - numUsed = other.numUsed; - } - + swapWithArray (other); return *this; } #endif diff --git a/modules/juce_core/containers/juce_LinkedListPointer.h b/modules/juce_core/containers/juce_LinkedListPointer.h index 19b58a4598..a9dfb2648a 100644 --- a/modules/juce_core/containers/juce_LinkedListPointer.h +++ b/modules/juce_core/containers/juce_LinkedListPointer.h @@ -322,6 +322,12 @@ public: *destArray++ = i; } + /** Swaps this pointer with another one */ + void swapWith (LinkedListPointer& other) noexcept + { + std::swap (item, other.item); + } + //============================================================================== /** Allows efficient repeated insertions into a list. diff --git a/modules/juce_core/containers/juce_NamedValueSet.cpp b/modules/juce_core/containers/juce_NamedValueSet.cpp index 7e7e611218..b5f2e024e7 100644 --- a/modules/juce_core/containers/juce_NamedValueSet.cpp +++ b/modules/juce_core/containers/juce_NamedValueSet.cpp @@ -94,9 +94,7 @@ NamedValueSet::NamedValueSet (NamedValueSet&& other) noexcept NamedValueSet& NamedValueSet::operator= (NamedValueSet&& other) noexcept { - if (this != &other) - values = static_cast &&> (other.values); - + other.values.swapWith (values); return *this; } #endif diff --git a/modules/juce_core/containers/juce_Variant.cpp b/modules/juce_core/containers/juce_Variant.cpp index 4487758ee5..5f10260ec2 100644 --- a/modules/juce_core/containers/juce_Variant.cpp +++ b/modules/juce_core/containers/juce_Variant.cpp @@ -421,14 +421,7 @@ var::var (var&& other) noexcept var& var::operator= (var&& other) noexcept { - if (this != &other) - { - type->cleanUp (value); - type = other.type; - value = other.value; - other.type = &VariantType_Void::instance; - } - + swapWith (other); return *this; } #endif diff --git a/modules/juce_core/maths/juce_BigInteger.cpp b/modules/juce_core/maths/juce_BigInteger.cpp index 0e5abd7b47..51866a7aa8 100644 --- a/modules/juce_core/maths/juce_BigInteger.cpp +++ b/modules/juce_core/maths/juce_BigInteger.cpp @@ -577,7 +577,7 @@ BigInteger& BigInteger::operator&= (const BigInteger& other) int n = (int) numValues; - while (n > other.numValues) + while (n > (int) other.numValues) values[--n] = 0; while (--n >= 0) diff --git a/modules/juce_core/system/juce_PlatformDefs.h b/modules/juce_core/system/juce_PlatformDefs.h index b9b5c88b2d..06b0394864 100644 --- a/modules/juce_core/system/juce_PlatformDefs.h +++ b/modules/juce_core/system/juce_PlatformDefs.h @@ -270,16 +270,21 @@ #endif //============================================================================== -// Here, we'll check for C++2011 compiler support, and if it's not available, define -// a few workarounds, so that we can still use a few of the newer language features. +// Here, we'll check for C++11 compiler support, and if it's not available, define +// a few workarounds, so that we can still use some of the newer language features. #if defined (__GXX_EXPERIMENTAL_CXX0X__) && defined (__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)) - #define JUCE_COMPILER_SUPPORTS_CXX2011 1 + #define JUCE_COMPILER_SUPPORTS_NOEXCEPT 1 + #define JUCE_COMPILER_SUPPORTS_NULLPTR 1 #define JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS 1 #endif #if defined (__clang__) && defined (__has_feature) - #if __has_feature (cxx_noexcept) // (NB: do not add this test to the previous line) - #define JUCE_COMPILER_SUPPORTS_CXX2011 1 + #if __has_feature (cxx_nullptr) + #define JUCE_COMPILER_SUPPORTS_NULLPTR 1 + #endif + + #if __has_feature (cxx_noexcept) + #define JUCE_COMPILER_SUPPORTS_NOEXCEPT 1 #endif #if __has_feature (cxx_rvalue_references) @@ -288,13 +293,19 @@ #endif #if defined (_MSC_VER) && _MSC_VER >= 1600 - //#define JUCE_COMPILER_SUPPORTS_CXX2011 1 - //#define JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS 1 + #define JUCE_COMPILER_SUPPORTS_NOEXCEPT 0 + #define JUCE_COMPILER_SUPPORTS_NULLPTR 1 + #define JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS 1 #endif -#if ! (DOXYGEN || JUCE_COMPILER_SUPPORTS_CXX2011) - #define noexcept throw() // for c++98 compilers, we can fake these newer language features. - #define nullptr (0) +//============================================================================== +// Declare some fake versions of nullptr and noexcept, for older compilers: +#if ! (DOXYGEN || JUCE_COMPILER_SUPPORTS_NOEXCEPT) + #define noexcept throw() +#endif + +#if ! (DOXYGEN || JUCE_COMPILER_SUPPORTS_NULLPTR) + #define nullptr (0) #endif #endif // __JUCE_PLATFORMDEFS_JUCEHEADER__ diff --git a/modules/juce_graphics/geometry/juce_RectangleList.cpp b/modules/juce_graphics/geometry/juce_RectangleList.cpp index 50f269bca2..e969e0cc5a 100644 --- a/modules/juce_graphics/geometry/juce_RectangleList.cpp +++ b/modules/juce_graphics/geometry/juce_RectangleList.cpp @@ -47,6 +47,19 @@ RectangleList& RectangleList::operator= (const RectangleList& other) return *this; } +#if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS +RectangleList::RectangleList (RectangleList&& other) noexcept + : rects (static_cast >&&> (other.rects)) +{ +} + +RectangleList& RectangleList::operator= (RectangleList&& other) noexcept +{ + rects = static_cast >&&> (other.rects); + return *this; +} +#endif + RectangleList::~RectangleList() { } diff --git a/modules/juce_graphics/geometry/juce_RectangleList.h b/modules/juce_graphics/geometry/juce_RectangleList.h index 135d06a80a..c7c4cb8f91 100644 --- a/modules/juce_graphics/geometry/juce_RectangleList.h +++ b/modules/juce_graphics/geometry/juce_RectangleList.h @@ -56,6 +56,11 @@ public: /** Copies this list from another one. */ RectangleList& operator= (const RectangleList& other); + #if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS + RectangleList (RectangleList&& other) noexcept; + RectangleList& operator= (RectangleList&& other) noexcept; + #endif + /** Destructor. */ ~RectangleList(); diff --git a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm index 3d15b35897..c139a61205 100644 --- a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm @@ -1749,7 +1749,7 @@ void Desktop::setKioskComponent (Component* kioskModeComponent, bool enableOrDis { [NSApp setPresentationOptions: NSApplicationPresentationDefault]; } - #else + #elif JUCE_SUPPORT_CARBON if (enableOrDisable) { SetSystemUIMode (kUIModeAllSuppressed, allowMenusAndBars ? kUIOptionAutoShowMenuBar : 0); @@ -1759,6 +1759,10 @@ void Desktop::setKioskComponent (Component* kioskModeComponent, bool enableOrDis { SetSystemUIMode (kUIModeNormal, 0); } + #else + // If you're targeting OSes earlier than 10.6 and want to use this feature, + // you'll need to enable JUCE_SUPPORT_CARBON. + jassertfalse; #endif } diff --git a/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.cpp b/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.cpp index 3ec1e03e82..deac225d51 100644 --- a/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.cpp +++ b/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.cpp @@ -71,6 +71,19 @@ RelativeCoordinate& RelativeCoordinate::operator= (const RelativeCoordinate& oth return *this; } +#if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS +RelativeCoordinate::RelativeCoordinate (RelativeCoordinate&& other) noexcept + : term (static_cast (other.term)) +{ +} + +RelativeCoordinate& RelativeCoordinate::operator= (RelativeCoordinate&& other) noexcept +{ + term = static_cast (other.term); + return *this; +} +#endif + RelativeCoordinate::RelativeCoordinate (const double absoluteDistanceFromOrigin) : term (absoluteDistanceFromOrigin) { @@ -82,7 +95,7 @@ RelativeCoordinate::RelativeCoordinate (const String& s) { term = Expression (s); } - catch (...) + catch (Expression::ParseError&) {} } @@ -109,7 +122,7 @@ double RelativeCoordinate::resolve (const Expression::Scope* scope) const else return term.evaluate(); } - catch (...) + catch (Expression::ParseError&) {} return 0.0; @@ -124,7 +137,7 @@ bool RelativeCoordinate::isRecursive (const Expression::Scope* scope) const else term.evaluate(); } - catch (...) + catch (Expression::ParseError&) { return true; } @@ -146,7 +159,7 @@ void RelativeCoordinate::moveToAbsolute (double newPos, const Expression::Scope* term = term.adjustedToGiveNewResult (newPos, defaultScope); } } - catch (...) + catch (Expression::ParseError&) {} } @@ -160,6 +173,4 @@ String RelativeCoordinate::toString() const return term.toString(); } - - END_JUCE_NAMESPACE diff --git a/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.h b/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.h index caed6803c4..f10666a71a 100644 --- a/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.h +++ b/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.h @@ -43,6 +43,11 @@ public: RelativeCoordinate (const RelativeCoordinate& other); RelativeCoordinate& operator= (const RelativeCoordinate& other); + #if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS + RelativeCoordinate (RelativeCoordinate&& other) noexcept; + RelativeCoordinate& operator= (RelativeCoordinate&& other) noexcept; + #endif + /** Creates an absolute position from the parent origin on either the X or Y axis. @param absoluteDistanceFromOrigin the distance from the origin