From 626cb292cd107f541a3c168882c5cb7d1e916837 Mon Sep 17 00:00:00 2001 From: Julian Storer Date: Fri, 17 Sep 2010 18:03:49 +0100 Subject: [PATCH] Minor fix for ReferenceCountedArray. Tweak to jucer template code. --- .../JuceLibraryCode/BinaryData.cpp | 4 - .../JuceLibraryCode/BinaryData.h | 2 +- .../Source/BinaryData/jucer_MainTemplate.cpp | 4 - .../Source/Project/jucer_NewProjectWizard.cpp | 5 +- juce_amalgamated.h | 82 ++++++++++--------- src/containers/juce_Array.h | 21 +++-- src/containers/juce_ReferenceCountedArray.h | 31 +++---- src/containers/juce_SortedSet.h | 23 +++--- src/core/juce_StandardHeader.h | 2 +- src/text/juce_String.h | 5 +- 10 files changed, 93 insertions(+), 86 deletions(-) diff --git a/extras/Jucer (experimental)/JuceLibraryCode/BinaryData.cpp b/extras/Jucer (experimental)/JuceLibraryCode/BinaryData.cpp index 21d4735b20..5687b33fac 100644 --- a/extras/Jucer (experimental)/JuceLibraryCode/BinaryData.cpp +++ b/extras/Jucer (experimental)/JuceLibraryCode/BinaryData.cpp @@ -683,14 +683,10 @@ static const unsigned char temp_760350be[] = " //==============================================================================\r\n" " APPCLASSNAME()MEMBERINITIALISERS\r\n" " {\r\n" -" // Don't do anything in this constructor! It will be called before the\r\n" -" // main Juce subsystem has been initialised!\r\n" " }\r\n" "\r\n" " ~APPCLASSNAME()\r\n" " {\r\n" -" // Don't do anything in this destructor! It will be called after the\r\n" -" // main Juce subsystem has been shutdown and is no longer valid!\r\n" " }\r\n" "\r\n" " //==============================================================================\r\n" diff --git a/extras/Jucer (experimental)/JuceLibraryCode/BinaryData.h b/extras/Jucer (experimental)/JuceLibraryCode/BinaryData.h index f6f1681fde..96250974e7 100644 --- a/extras/Jucer (experimental)/JuceLibraryCode/BinaryData.h +++ b/extras/Jucer (experimental)/JuceLibraryCode/BinaryData.h @@ -29,7 +29,7 @@ namespace BinaryData const int jucer_MainConsoleAppTemplate_cppSize = 749; extern const char* jucer_MainTemplate_cpp; - const int jucer_MainTemplate_cppSize = 2106; + const int jucer_MainTemplate_cppSize = 1820; extern const char* jucer_NewCppFileTemplate_cpp; const int jucer_NewCppFileTemplate_cppSize = 232; diff --git a/extras/Jucer (experimental)/Source/BinaryData/jucer_MainTemplate.cpp b/extras/Jucer (experimental)/Source/BinaryData/jucer_MainTemplate.cpp index 70cf976bd0..ea271a63dc 100644 --- a/extras/Jucer (experimental)/Source/BinaryData/jucer_MainTemplate.cpp +++ b/extras/Jucer (experimental)/Source/BinaryData/jucer_MainTemplate.cpp @@ -18,14 +18,10 @@ public: //============================================================================== APPCLASSNAME()MEMBERINITIALISERS { - // Don't do anything in this constructor! It will be called before the - // main Juce subsystem has been initialised! } ~APPCLASSNAME() { - // Don't do anything in this destructor! It will be called after the - // main Juce subsystem has been shutdown and is no longer valid! } //============================================================================== diff --git a/extras/Jucer (experimental)/Source/Project/jucer_NewProjectWizard.cpp b/extras/Jucer (experimental)/Source/Project/jucer_NewProjectWizard.cpp index a0b535e108..f84a41ae5e 100644 --- a/extras/Jucer (experimental)/Source/Project/jucer_NewProjectWizard.cpp +++ b/extras/Jucer (experimental)/Source/Project/jucer_NewProjectWizard.cpp @@ -85,10 +85,9 @@ public: if (createWindow) { appHeaders << newLine << CodeHelpers::createIncludeStatement (mainWindowH, mainCppFile); - memberInitialisers = " : mainWindow (0)"; initCode = "mainWindow = new " + windowClassName + "();"; - shutdownCode = "deleteAndZero (mainWindow);"; - privateMembers = windowClassName + "* mainWindow;"; + shutdownCode = "mainWindow = 0;"; + privateMembers = "ScopedPointer <" + windowClassName + "> mainWindow;"; String windowH = project.getFileTemplate ("jucer_WindowTemplate_h") .replace ("INCLUDES", CodeHelpers::createIncludeStatement (project.getAppIncludeFile(), mainWindowH), false) diff --git a/juce_amalgamated.h b/juce_amalgamated.h index fd06844fd4..c1fc9e9841 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 66 +#define JUCE_BUILDNUMBER 67 /** Current Juce version number. @@ -1855,8 +1855,9 @@ public: Uses a case-sensitive comparison. - @returns true if the all the characters in the string are also found in the - string that is passed in. + @returns Returns false if any of the characters in this string do not occur in + the parameter string. If this string is empty, the return value will + always be true. */ bool containsOnly (const String& charactersItMightContain) const throw(); @@ -3996,19 +3997,22 @@ public: int numElementsToAdd = -1) { const typename OtherArrayType::ScopedLockType lock1 (arrayToAddFrom.getLock()); - const ScopedLockType lock2 (getLock()); - if (startIndex < 0) { - jassertfalse; - startIndex = 0; - } + const ScopedLockType lock2 (getLock()); - if (numElementsToAdd < 0 || startIndex + numElementsToAdd > arrayToAddFrom.size()) - numElementsToAdd = arrayToAddFrom.size() - startIndex; + if (startIndex < 0) + { + jassertfalse; + startIndex = 0; + } - while (--numElementsToAdd >= 0) - add (arrayToAddFrom.getUnchecked (startIndex++)); + if (numElementsToAdd < 0 || startIndex + numElementsToAdd > arrayToAddFrom.size()) + numElementsToAdd = arrayToAddFrom.size() - startIndex; + + while (--numElementsToAdd >= 0) + add (arrayToAddFrom.getUnchecked (startIndex++)); + } } /** Inserts a new element into the array, assuming that the array is sorted. @@ -10847,27 +10851,28 @@ public: int startIndex = 0, int numElementsToAdd = -1) throw() { - arrayToAddFrom.lockArray(); - const ScopedLockType lock (getLock()); + const ScopedLockType lock1 (arrayToAddFrom.getLock()); - if (startIndex < 0) { - jassertfalse; - startIndex = 0; - } + const ScopedLockType lock2 (getLock()); - if (numElementsToAdd < 0 || startIndex + numElementsToAdd > arrayToAddFrom.size()) - numElementsToAdd = arrayToAddFrom.size() - startIndex; + if (startIndex < 0) + { + jassertfalse; + startIndex = 0; + } - if (numElementsToAdd > 0) - { - data.ensureAllocatedSize (numUsed + numElementsToAdd); + if (numElementsToAdd < 0 || startIndex + numElementsToAdd > arrayToAddFrom.size()) + numElementsToAdd = arrayToAddFrom.size() - startIndex; - while (--numElementsToAdd >= 0) - add (arrayToAddFrom.getUnchecked (startIndex++)); - } + if (numElementsToAdd > 0) + { + data.ensureAllocatedSize (numUsed + numElementsToAdd); - arrayToAddFrom.unlockArray(); + while (--numElementsToAdd >= 0) + add (arrayToAddFrom.getUnchecked (startIndex++)); + } + } } /** Inserts a new object into the array assuming that the array is sorted. @@ -11553,21 +11558,24 @@ public: int numElementsToAdd = -1) throw() { const typename OtherSetType::ScopedLockType lock1 (setToAddFrom.getLock()); - const ScopedLockType lock2 (getLock()); - jassert (this != &setToAddFrom); - if (this != &setToAddFrom) { - if (startIndex < 0) + const ScopedLockType lock2 (getLock()); + jassert (this != &setToAddFrom); + + if (this != &setToAddFrom) { - jassertfalse; - startIndex = 0; - } + if (startIndex < 0) + { + jassertfalse; + startIndex = 0; + } - if (numElementsToAdd < 0 || startIndex + numElementsToAdd > setToAddFrom.size()) - numElementsToAdd = setToAddFrom.size() - startIndex; + if (numElementsToAdd < 0 || startIndex + numElementsToAdd > setToAddFrom.size()) + numElementsToAdd = setToAddFrom.size() - startIndex; - addArray (setToAddFrom.elements + startIndex, numElementsToAdd); + addArray (setToAddFrom.elements + startIndex, numElementsToAdd); + } } } diff --git a/src/containers/juce_Array.h b/src/containers/juce_Array.h index 634a369c6e..8b227cf074 100644 --- a/src/containers/juce_Array.h +++ b/src/containers/juce_Array.h @@ -570,19 +570,22 @@ public: int numElementsToAdd = -1) { const typename OtherArrayType::ScopedLockType lock1 (arrayToAddFrom.getLock()); - const ScopedLockType lock2 (getLock()); - if (startIndex < 0) { - jassertfalse; - startIndex = 0; - } + const ScopedLockType lock2 (getLock()); - if (numElementsToAdd < 0 || startIndex + numElementsToAdd > arrayToAddFrom.size()) - numElementsToAdd = arrayToAddFrom.size() - startIndex; + if (startIndex < 0) + { + jassertfalse; + startIndex = 0; + } - while (--numElementsToAdd >= 0) - add (arrayToAddFrom.getUnchecked (startIndex++)); + if (numElementsToAdd < 0 || startIndex + numElementsToAdd > arrayToAddFrom.size()) + numElementsToAdd = arrayToAddFrom.size() - startIndex; + + while (--numElementsToAdd >= 0) + add (arrayToAddFrom.getUnchecked (startIndex++)); + } } /** Inserts a new element into the array, assuming that the array is sorted. diff --git a/src/containers/juce_ReferenceCountedArray.h b/src/containers/juce_ReferenceCountedArray.h index fcea0f7888..a5f50519f0 100644 --- a/src/containers/juce_ReferenceCountedArray.h +++ b/src/containers/juce_ReferenceCountedArray.h @@ -339,27 +339,28 @@ public: int startIndex = 0, int numElementsToAdd = -1) throw() { - arrayToAddFrom.lockArray(); - const ScopedLockType lock (getLock()); + const ScopedLockType lock1 (arrayToAddFrom.getLock()); - if (startIndex < 0) { - jassertfalse; - startIndex = 0; - } + const ScopedLockType lock2 (getLock()); - if (numElementsToAdd < 0 || startIndex + numElementsToAdd > arrayToAddFrom.size()) - numElementsToAdd = arrayToAddFrom.size() - startIndex; + if (startIndex < 0) + { + jassertfalse; + startIndex = 0; + } - if (numElementsToAdd > 0) - { - data.ensureAllocatedSize (numUsed + numElementsToAdd); + if (numElementsToAdd < 0 || startIndex + numElementsToAdd > arrayToAddFrom.size()) + numElementsToAdd = arrayToAddFrom.size() - startIndex; - while (--numElementsToAdd >= 0) - add (arrayToAddFrom.getUnchecked (startIndex++)); - } + if (numElementsToAdd > 0) + { + data.ensureAllocatedSize (numUsed + numElementsToAdd); - arrayToAddFrom.unlockArray(); + while (--numElementsToAdd >= 0) + add (arrayToAddFrom.getUnchecked (startIndex++)); + } + } } /** Inserts a new object into the array assuming that the array is sorted. diff --git a/src/containers/juce_SortedSet.h b/src/containers/juce_SortedSet.h index 4d96dec71c..7823217763 100644 --- a/src/containers/juce_SortedSet.h +++ b/src/containers/juce_SortedSet.h @@ -376,21 +376,24 @@ public: int numElementsToAdd = -1) throw() { const typename OtherSetType::ScopedLockType lock1 (setToAddFrom.getLock()); - const ScopedLockType lock2 (getLock()); - jassert (this != &setToAddFrom); - if (this != &setToAddFrom) { - if (startIndex < 0) + const ScopedLockType lock2 (getLock()); + jassert (this != &setToAddFrom); + + if (this != &setToAddFrom) { - jassertfalse; - startIndex = 0; - } + if (startIndex < 0) + { + jassertfalse; + startIndex = 0; + } - if (numElementsToAdd < 0 || startIndex + numElementsToAdd > setToAddFrom.size()) - numElementsToAdd = setToAddFrom.size() - startIndex; + if (numElementsToAdd < 0 || startIndex + numElementsToAdd > setToAddFrom.size()) + numElementsToAdd = setToAddFrom.size() - startIndex; - addArray (setToAddFrom.elements + startIndex, numElementsToAdd); + addArray (setToAddFrom.elements + startIndex, numElementsToAdd); + } } } diff --git a/src/core/juce_StandardHeader.h b/src/core/juce_StandardHeader.h index 59e1de232b..f6d9234e77 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 66 +#define JUCE_BUILDNUMBER 67 /** Current Juce version number. diff --git a/src/text/juce_String.h b/src/text/juce_String.h index 3c3dbd85ed..a744b6ea04 100644 --- a/src/text/juce_String.h +++ b/src/text/juce_String.h @@ -291,8 +291,9 @@ public: Uses a case-sensitive comparison. - @returns true if the all the characters in the string are also found in the - string that is passed in. + @returns Returns false if any of the characters in this string do not occur in + the parameter string. If this string is empty, the return value will + always be true. */ bool containsOnly (const String& charactersItMightContain) const throw();