diff --git a/extras/binarybuilder/BinaryBuilder.cpp b/extras/binarybuilder/BinaryBuilder.cpp index ba55a29ee4..238397c6c0 100644 --- a/extras/binarybuilder/BinaryBuilder.cpp +++ b/extras/binarybuilder/BinaryBuilder.cpp @@ -126,7 +126,7 @@ int main (int argc, char* argv[]) << " from files in " << (const char*) sourceDirectory.getFullPathName() << "..." << std::endl << std::endl; - OwnedArray files; + Array files; sourceDirectory.findChildFiles (files, File::findFiles, true, (argc > 4) ? argv[4] : "*"); @@ -171,7 +171,7 @@ int main (int argc, char* argv[]) for (int i = 0; i < files.size(); ++i) { - const File file (*(files[i])); + const File file (files[i]); // (avoid source control files and hidden files..) if (! isHiddenFile (file, sourceDirectory)) diff --git a/extras/juce demo/build/macosx/jucedemo.xcodeproj/project.pbxproj b/extras/juce demo/build/macosx/jucedemo.xcodeproj/project.pbxproj index 3771f3fe5d..df868125b5 100644 --- a/extras/juce demo/build/macosx/jucedemo.xcodeproj/project.pbxproj +++ b/extras/juce demo/build/macosx/jucedemo.xcodeproj/project.pbxproj @@ -312,6 +312,7 @@ ALWAYS_SEARCH_USER_PATHS = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_MODEL_TUNING = G5; + GCC_PREPROCESSOR_DEFINITIONS = "NDEBUG=1"; INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Applications"; PRODUCT_NAME = jucedemo; diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 7f964cb69b..6e15689045 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -5561,7 +5561,7 @@ DirectoryIterator::DirectoryIterator (const File& directory, && ((whatToLookFor_ & File::ignoreHiddenFiles) == 0 || ! isHidden)) { - dirsFound.add (new File (path + filename, 0)); + dirsFound.add (File (path + filename, 0)); } addToList = (whatToLookFor_ & File::findDirectories) != 0; @@ -5580,7 +5580,7 @@ DirectoryIterator::DirectoryIterator (const File& directory, addToList = ! isHidden; if (addToList) - filesFound.add (new File (path + filename, 0)); + filesFound.add (File (path + filename, 0)); } } while (juce_findFileNext (handle, filename, &isDirectory, &isHidden, 0, 0, 0, 0)); @@ -5610,7 +5610,7 @@ bool DirectoryIterator::next() if (index >= filesFound.size()) { - subIterator = new DirectoryIterator (*(dirsFound [index - filesFound.size()]), + subIterator = new DirectoryIterator (dirsFound.getReference (index - filesFound.size()), true, wildCard, whatToLookFor); return next(); } @@ -5623,10 +5623,7 @@ const File DirectoryIterator::getFile() const if (subIterator != 0) return subIterator->getFile(); - const File* const f = filesFound [index]; - - return (f != 0) ? *f - : File::nonexistent; + return filesFound [index]; } float DirectoryIterator::getEstimatedProgress() const @@ -5899,11 +5896,11 @@ bool File::setReadOnly (const bool shouldBeReadOnly, if (applyRecursively && isDirectory()) { - OwnedArray subFiles; + Array subFiles; findChildFiles (subFiles, File::findFilesAndDirectories, false); for (int i = subFiles.size(); --i >= 0;) - worked = subFiles[i]->setReadOnly (shouldBeReadOnly, true) && worked; + worked = subFiles.getReference(i).setReadOnly (shouldBeReadOnly, true) && worked; } return juce_setFileReadOnly (fullPath, shouldBeReadOnly) && worked; @@ -5921,11 +5918,11 @@ bool File::deleteRecursively() const if (isDirectory()) { - OwnedArray subFiles; + Array subFiles; findChildFiles (subFiles, File::findFilesAndDirectories, false); for (int i = subFiles.size(); --i >= 0;) - worked = subFiles[i]->deleteRecursively() && worked; + worked = subFiles.getReference(i).deleteRecursively() && worked; } return deleteFile() && worked; @@ -5960,19 +5957,19 @@ bool File::copyDirectoryTo (const File& newDirectory) const { if (isDirectory() && newDirectory.createDirectory()) { - OwnedArray subFiles; + Array subFiles; findChildFiles (subFiles, File::findFiles, false); int i; for (i = 0; i < subFiles.size(); ++i) - if (! subFiles[i]->copyFileTo (newDirectory.getChildFile (subFiles[i]->getFileName()))) + if (! subFiles.getReference(i).copyFileTo (newDirectory.getChildFile (subFiles.getReference(i).getFileName()))) return false; subFiles.clear(); findChildFiles (subFiles, File::findDirectories, false); for (i = 0; i < subFiles.size(); ++i) - if (! subFiles[i]->copyDirectoryTo (newDirectory.getChildFile (subFiles[i]->getFileName()))) + if (! subFiles.getReference(i).copyDirectoryTo (newDirectory.getChildFile (subFiles.getReference(i).getFileName()))) return false; return true; @@ -6247,7 +6244,7 @@ static inline bool fileTypeMatches (const int whatToLookFor, || (whatToLookFor & File::ignoreHiddenFiles) == 0); } -int File::findChildFiles (OwnedArray& results, +int File::findChildFiles (Array& results, const int whatToLookFor, const bool searchRecursively, const String& wildCardPattern) const @@ -6276,7 +6273,7 @@ int File::findChildFiles (OwnedArray& results, if (fileTypeMatches (whatToLookFor, itemIsDirectory, itemIsHidden) && ! filename.containsOnly (T("."))) { - results.add (new File (path + filename, 0)); + results.add (File (path + filename, 0)); ++total; } @@ -6294,16 +6291,13 @@ int File::findChildFiles (OwnedArray& results, // and recurse down if required. if (searchRecursively) { - OwnedArray subDirectories; + Array subDirectories; findChildFiles (subDirectories, File::findDirectories, false); for (int i = 0; i < subDirectories.size(); ++i) { - total += subDirectories.getUnchecked(i) - ->findChildFiles (results, - whatToLookFor, - true, - wildCardPattern); + total += subDirectories.getReference(i).findChildFiles (results, whatToLookFor, + true, wildCardPattern); } } @@ -6683,12 +6677,12 @@ const String File::getRelativePathFrom (const File& dir) const return thisPath; } -void File::findFileSystemRoots (OwnedArray& destArray) +void File::findFileSystemRoots (Array& destArray) { const StringArray roots (juce_getFileSystemRoots()); for (int i = 0; i < roots.size(); ++i) - destArray.add (new File (roots[i])); + destArray.add (File (roots[i])); } const String File::getVolumeLabel() const @@ -7009,7 +7003,7 @@ void FileSearchPath::removeNonExistentPaths() directories.remove (i); } -int FileSearchPath::findChildFiles (OwnedArray& results, +int FileSearchPath::findChildFiles (Array& results, const int whatToLookFor, const bool searchRecursively, const String& wildCardPattern) const @@ -19638,36 +19632,36 @@ BEGIN_JUCE_NAMESPACE // Mac version doesn't need any native code because it's all done with files.. // Windows + Linux versions are in the platform-dependent code sections. -static void findCDs (OwnedArray& cds) +static void findCDs (Array& cds) { File volumes ("/Volumes"); volumes.findChildFiles (cds, File::findDirectories, false); for (int i = cds.size(); --i >= 0;) - if (! cds[i]->getChildFile (".TOC.plist").exists()) + if (! cds.getReference(i).getChildFile (".TOC.plist").exists()) cds.remove (i); } const StringArray AudioCDReader::getAvailableCDNames() { - OwnedArray cds; + Array cds; findCDs (cds); StringArray names; for (int i = 0; i < cds.size(); ++i) - names.add (cds[i]->getFileName()); + names.add (cds.getReference(i).getFileName()); return names; } AudioCDReader* AudioCDReader::createReaderForCD (const int index) { - OwnedArray cds; + Array cds; findCDs (cds); - if (cds[index] != 0) - return new AudioCDReader (*cds[index]); + if (cds[index] != File::nonexistent) + return new AudioCDReader (cds[index]); else return 0; } @@ -19697,10 +19691,10 @@ static int getTrackNumber (const File& file) .getIntValue(); } -int AudioCDReader::compareElements (const File* const first, const File* const second) throw() +int AudioCDReader::compareElements (const File& first, const File& second) { - const int firstTrack = getTrackNumber (*first); - const int secondTrack = getTrackNumber (*second); + const int firstTrack = getTrackNumber (first); + const int secondTrack = getTrackNumber (second); jassert (firstTrack > 0 && secondTrack > 0); @@ -19722,7 +19716,7 @@ void AudioCDReader::refreshTrackLengths() { trackStartSamples.add (sample); - FileInputStream* const in = tracks[i]->createInputStream(); + FileInputStream* const in = tracks.getReference(i).createInputStream(); if (in != 0) { @@ -19760,22 +19754,19 @@ bool AudioCDReader::readSamples (int** destSamples, int numDestChannels, int sta { reader = 0; - if (tracks [track] != 0) - { - FileInputStream* const in = tracks [track]->createInputStream(); + FileInputStream* const in = tracks [track].createInputStream(); - if (in != 0) - { - BufferedInputStream* const bin = new BufferedInputStream (in, 65536, true); + if (in != 0) + { + BufferedInputStream* const bin = new BufferedInputStream (in, 65536, true); - AiffAudioFormat format; - reader = format.createReaderFor (bin, true); + AiffAudioFormat format; + reader = format.createReaderFor (bin, true); - if (reader == 0) - currentReaderTrack = -1; - else - currentReaderTrack = track; - } + if (reader == 0) + currentReaderTrack = -1; + else + currentReaderTrack = track; } } @@ -19811,7 +19802,7 @@ int AudioCDReader::getPositionOfTrackStart (int trackNum) const bool AudioCDReader::isTrackAudio (int trackNum) const { - return tracks [trackNum] != 0; + return tracks [trackNum] != File::nonexistent; } void AudioCDReader::enableIndexScanning (bool b) @@ -29153,11 +29144,11 @@ void KnownPluginList::scanAndAddDragAndDroppedFiles (const StringArray& files, StringArray s; { - OwnedArray subFiles; + Array subFiles; f.findChildFiles (subFiles, File::findFilesAndDirectories, false); for (int j = 0; j < subFiles.size(); ++j) - s.add (subFiles.getUnchecked (j)->getFullPathName()); + s.add (subFiles.getReference(j).getFullPathName()); } scanAndAddDragAndDroppedFiles (s, typesFound); @@ -44742,7 +44733,7 @@ public: } }; -class CodeEditorLine +class CodeEditorComponent::CodeEditorLine { public: CodeEditorLine() throw() @@ -44759,11 +44750,12 @@ public: const CodeDocument::Position& selectionStart, const CodeDocument::Position& selectionEnd) { - OwnedArray newTokens; + Array newTokens; + newTokens.ensureStorageAllocated (8); if (analyser == 0) { - newTokens.add (new SyntaxToken (document.getLine (lineNum), -1)); + newTokens.add (SyntaxToken (document.getLine (lineNum), -1)); } else if (lineNum < document.getNumLines()) { @@ -44801,7 +44793,7 @@ public: for (int i = newTokens.size(); --i >= 0;) { - if (*tokens.getUnchecked(i) != *newTokens.getUnchecked(i)) + if (tokens.getReference(i) != newTokens.getReference(i)) { allTheSame = false; break; @@ -44832,22 +44824,22 @@ public: for (int i = 0; i < tokens.size(); ++i) { - SyntaxToken* const token = tokens.getUnchecked(i); + SyntaxToken& token = tokens.getReference(i); - if (lastType != token->tokenType) + if (lastType != token.tokenType) { - lastType = token->tokenType; + lastType = token.tokenType; g.setColour (owner.getColourForTokenType (lastType)); } - g.drawSingleLineText (token->text, roundToInt (x), y + baselineOffset); + g.drawSingleLineText (token.text, roundToInt (x), y + baselineOffset); if (i < tokens.size() - 1) { - if (token->width < 0) - token->width = font.getStringWidthFloat (token->text); + if (token.width < 0) + token.width = font.getStringWidthFloat (token.text); - x += token->width; + x += token.width; } } } @@ -44870,13 +44862,13 @@ private: } }; - OwnedArray tokens; + Array tokens; int highlightColumnStart, highlightColumnEnd; static void createTokens (int startPosition, const String& lineText, CodeDocument::Iterator& source, CodeTokeniser* analyser, - OwnedArray & newTokens) + Array & newTokens) { CodeDocument::Iterator lastIterator (source); const int lineLength = lineText.length(); @@ -44895,8 +44887,8 @@ private: if (tokenEnd > 0) { tokenStart -= startPosition; - newTokens.add (new SyntaxToken (lineText.substring (jmax (0, tokenStart), tokenEnd), - tokenType)); + newTokens.add (SyntaxToken (lineText.substring (jmax (0, tokenStart), tokenEnd), + tokenType)); if (tokenEnd >= lineLength) break; @@ -44908,24 +44900,24 @@ private: source = lastIterator; } - static void replaceTabsWithSpaces (OwnedArray & tokens, const int spacesPerTab) throw() + static void replaceTabsWithSpaces (Array & tokens, const int spacesPerTab) throw() { int x = 0; for (int i = 0; i < tokens.size(); ++i) { - SyntaxToken* const t = tokens.getUnchecked(i); + SyntaxToken& t = tokens.getReference(i); for (;;) { - int tabPos = t->text.indexOfChar (T('\t')); + int tabPos = t.text.indexOfChar (T('\t')); if (tabPos < 0) break; const int spacesNeeded = spacesPerTab - ((tabPos + x) % spacesPerTab); - t->text = t->text.replaceSection (tabPos, 1, String::repeatedString (T(" "), spacesNeeded)); + t.text = t.text.replaceSection (tabPos, 1, String::repeatedString (T(" "), spacesNeeded)); } - x += t->text.length(); + x += t.text.length(); } } @@ -57229,7 +57221,7 @@ FileBrowserComponent::FileBrowserComponent (int flags_, } else { - chosenFiles.add (new File (initialFileOrDirectory)); + chosenFiles.add (initialFileOrDirectory); currentRoot = initialFileOrDirectory.getParentDirectory(); filename = initialFileOrDirectory.getFileName(); } @@ -57343,7 +57335,7 @@ const File FileBrowserComponent::getSelectedFile (int index) const throw() if (! filenameBox->isReadOnly()) return currentRoot.getChildFile (filenameBox->getText()); else - return chosenFiles[index] != 0 ? *chosenFiles[index] : File::nonexistent; + return chosenFiles[index]; } bool FileBrowserComponent::currentFileIsValid() const @@ -57494,7 +57486,7 @@ void FileBrowserComponent::selectionChanged() resetChosenFiles = false; } - chosenFiles.add (new File (f)); + chosenFiles.add (f); newFilenames.add (f.getRelativePathFrom (getRoot())); } } @@ -57578,7 +57570,7 @@ void FileBrowserComponent::textEditorReturnKeyPressed (TextEditor&) { setRoot (f.getParentDirectory()); chosenFiles.clear(); - chosenFiles.add (new File (f)); + chosenFiles.add (f); filenameBox->setText (f.getFileName()); } } @@ -57644,27 +57636,27 @@ const BitArray FileBrowserComponent::getRoots (StringArray& rootNames, StringArr BitArray separators; #if JUCE_WINDOWS - OwnedArray roots; + Array roots; File::findFileSystemRoots (roots); rootPaths.clear(); for (int i = 0; i < roots.size(); ++i) { - const File* const drive = roots.getUnchecked(i); + const File& drive = roots.getReference(i); - String name (drive->getFullPathName()); + String name (drive.getFullPathName()); rootPaths.add (name); - if (drive->isOnHardDisk()) + if (drive.isOnHardDisk()) { - String volume (drive->getVolumeLabel()); + String volume (drive.getVolumeLabel()); if (volume.isEmpty()) volume = TRANS("Hard Drive"); - name << " [" << drive->getVolumeLabel() << ']'; + name << " [" << drive.getVolumeLabel() << ']'; } - else if (drive->isOnCDRomDrive()) + else if (drive.isOnCDRomDrive()) { name << TRANS(" [CD/DVD drive]"); } @@ -57690,18 +57682,18 @@ const BitArray FileBrowserComponent::getRoots (StringArray& rootNames, StringArr separators.setBit (rootPaths.size()); - OwnedArray volumes; + Array volumes; File vol ("/Volumes"); vol.findChildFiles (volumes, File::findDirectories, false); for (int i = 0; i < volumes.size(); ++i) { - const File* const volume = volumes.getUnchecked(i); + const File& volume = volumes.getReference(i); - if (volume->isDirectory() && ! volume->getFileName().startsWithChar (T('.'))) + if (volume.isDirectory() && ! volume.getFileName().startsWithChar (T('.'))) { - rootPaths.add (volume->getFullPathName()); - rootNames.add (volume->getFileName()); + rootPaths.add (volume.getFullPathName()); + rootNames.add (volume.getFileName()); } } #endif @@ -57777,15 +57769,10 @@ const File FileChooser::getResult() const // to retrieve all the files that were chosen. jassert (results.size() <= 1); - const File* const f = results.getFirst(); - - if (f != 0) - return *f; - - return File::nonexistent; + return results.getFirst(); } -const OwnedArray & FileChooser::getResults() const +const Array& FileChooser::getResults() const { return results; } @@ -57851,7 +57838,7 @@ bool FileChooser::showDialog (const bool selectsDirectories, if (box.show()) { for (int i = 0; i < browserComponent.getNumSelectedFiles(); ++i) - results.add (new File (browserComponent.getSelectedFile (i))); + results.add (browserComponent.getSelectedFile (i)); } } @@ -74153,7 +74140,9 @@ void MagnifierComponent::paint (Graphics& g) } g.setImageResamplingQuality (quality); - g.drawImageTransformed (&temp, temp.getBounds(), AffineTransform::scale (scaleFactor, scaleFactor), false); + g.drawImageTransformed (&temp, temp.getBounds(), + AffineTransform::scale ((float) scaleFactor, (float) scaleFactor), + false); } void MagnifierComponent::childBoundsChanged (Component* c) @@ -79881,6 +79870,16 @@ void EdgeTable::intersectWithEdgeTableLine (const int y, const int* otherLine) t return; } + const int right = bounds.getRight() << 8; + + // optimise for the common case where our line lies entirely within a + // single pair of points, as happens when clipping to a simple rect. + if (otherNumPoints == 2 && otherLine[2] >= 255) + { + clipEdgeTableLineToRange (dest, otherLine[1], jmin (right, otherLine[3])); + return; + } + ++otherLine; const size_t lineSizeBytes = (dest[0] * 2 + 1) * sizeof (int); int* temp = (int*) alloca (lineSizeBytes); @@ -79897,7 +79896,6 @@ void EdgeTable::intersectWithEdgeTableLine (const int y, const int* otherLine) t int destIndex = 0, destTotal = 0; int level1 = 0, level2 = 0; int lastX = INT_MIN, lastLevel = 0; - const int right = bounds.getRight() << 8; while (srcNum1 > 0 && srcNum2 > 0) { @@ -79983,6 +79981,45 @@ void EdgeTable::intersectWithEdgeTableLine (const int y, const int* otherLine) t #endif } +void EdgeTable::clipEdgeTableLineToRange (int* dest, const int x1, const int x2) throw() +{ + int* lastItem = dest + (dest[0] * 2 - 1); + + if (x2 < lastItem[0]) + { + if (x2 <= dest[1]) + { + dest[0] = 0; + return; + } + + while (x2 < lastItem[-2]) + { + --(dest[0]); + lastItem -= 2; + } + + lastItem[0] = x2; + lastItem[1] = 0; + } + + if (x1 > dest[1]) + { + while (lastItem[0] > x1) + lastItem -= 2; + + const int itemsRemoved = (lastItem - (dest + 1)) / 2; + + if (itemsRemoved > 0) + { + dest[0] -= itemsRemoved; + memmove (dest + 1, lastItem, dest[0] * (sizeof (int) * 2)); + } + + dest[1] = x1; + } +} + void EdgeTable::clipToRectangle (const Rectangle& r) throw() { const Rectangle clipped (r.getIntersection (bounds)); @@ -80008,10 +80045,17 @@ void EdgeTable::clipToRectangle (const Rectangle& r) throw() if (clipped.getX() > bounds.getX()) { - const int rectLine[] = { 2, clipped.getX() << 8, 255, clipped.getRight() << 8, 0 }; + const int x1 = clipped.getX() << 8; + const int x2 = jmin (bounds.getRight(), clipped.getRight()) << 8; + int* line = table + lineStrideElements * top; - for (int i = top; i < bottom; ++i) - intersectWithEdgeTableLine (i, rectLine); + for (int i = bottom - top; --i >= 0;) + { + if (line[0] != 0) + clipEdgeTableLineToRange (line, x1, x2); + + line += lineStrideElements; + } } needToCheckEmptinesss = true; @@ -87011,15 +87055,15 @@ Typeface::~Typeface() { } -class CustomTypefaceGlyphInfo +class CustomTypeface::GlyphInfo { public: - CustomTypefaceGlyphInfo (const juce_wchar character_, const Path& path_, const float width_) throw() + GlyphInfo (const juce_wchar character_, const Path& path_, const float width_) throw() : character (character_), path (path_), width (width_) { } - ~CustomTypefaceGlyphInfo() throw() + ~GlyphInfo() throw() { } @@ -87058,8 +87102,8 @@ public: juce_UseDebuggingNewOperator private: - CustomTypefaceGlyphInfo (const CustomTypefaceGlyphInfo&); - const CustomTypefaceGlyphInfo& operator= (const CustomTypefaceGlyphInfo&); + GlyphInfo (const GlyphInfo&); + const GlyphInfo& operator= (const GlyphInfo&); }; CustomTypeface::CustomTypeface() @@ -87136,14 +87180,14 @@ void CustomTypeface::addGlyph (const juce_wchar character, const Path& path, con if (((unsigned int) character) < (unsigned int) numElementsInArray (lookupTable)) lookupTable [character] = (short) glyphs.size(); - glyphs.add (new CustomTypefaceGlyphInfo (character, path, width)); + glyphs.add (new GlyphInfo (character, path, width)); } void CustomTypeface::addKerningPair (const juce_wchar char1, const juce_wchar char2, const float extraAmount) throw() { if (extraAmount != 0) { - CustomTypefaceGlyphInfo* const g = findGlyph (char1, true); + GlyphInfo* const g = findGlyph (char1, true); jassert (g != 0); // can only add kerning pairs for characters that exist! if (g != 0) @@ -87151,14 +87195,14 @@ void CustomTypeface::addKerningPair (const juce_wchar char1, const juce_wchar ch } } -CustomTypefaceGlyphInfo* CustomTypeface::findGlyph (const juce_wchar character, const bool loadIfNeeded) throw() +CustomTypeface::GlyphInfo* CustomTypeface::findGlyph (const juce_wchar character, const bool loadIfNeeded) throw() { if (((unsigned int) character) < (unsigned int) numElementsInArray (lookupTable) && lookupTable [character] > 0) return glyphs [(int) lookupTable [(int) character]]; for (int i = 0; i < glyphs.size(); ++i) { - CustomTypefaceGlyphInfo* const g = glyphs.getUnchecked(i); + GlyphInfo* const g = glyphs.getUnchecked(i); if (g->character == character) return g; } @@ -87169,9 +87213,9 @@ CustomTypefaceGlyphInfo* CustomTypeface::findGlyph (const juce_wchar character, return 0; } -CustomTypefaceGlyphInfo* CustomTypeface::findGlyphSubstituting (const juce_wchar character) throw() +CustomTypeface::GlyphInfo* CustomTypeface::findGlyphSubstituting (const juce_wchar character) throw() { - CustomTypefaceGlyphInfo* glyph = findGlyph (character, true); + GlyphInfo* glyph = findGlyph (character, true); if (glyph == 0) { @@ -87250,7 +87294,7 @@ bool CustomTypeface::writeToStream (OutputStream& outputStream) for (i = 0; i < glyphs.size(); ++i) { - const CustomTypefaceGlyphInfo* const g = glyphs.getUnchecked (i); + const GlyphInfo* const g = glyphs.getUnchecked (i); out.writeShort ((short) (unsigned short) g->character); out.writeFloat (g->width); g->path.writePathToStream (out); @@ -87262,11 +87306,11 @@ bool CustomTypeface::writeToStream (OutputStream& outputStream) for (i = 0; i < glyphs.size(); ++i) { - const CustomTypefaceGlyphInfo* const g = glyphs.getUnchecked (i); + const GlyphInfo* const g = glyphs.getUnchecked (i); for (int j = 0; j < g->kerningPairs.size(); ++j) { - const CustomTypefaceGlyphInfo::KerningPair& p = g->kerningPairs.getReference (j); + const GlyphInfo::KerningPair& p = g->kerningPairs.getReference (j); out.writeShort ((short) (unsigned short) g->character); out.writeShort ((short) (unsigned short) p.character2); out.writeFloat (p.kerningAmount); @@ -87293,7 +87337,7 @@ float CustomTypeface::getStringWidth (const String& text) while (*t != 0) { - const CustomTypefaceGlyphInfo* const glyph = findGlyphSubstituting (*t++); + const GlyphInfo* const glyph = findGlyphSubstituting (*t++); if (glyph != 0) x += glyph->getHorizontalSpacing (*t); @@ -87311,7 +87355,7 @@ void CustomTypeface::getGlyphPositions (const String& text, Array & resultG while (*t != 0) { const juce_wchar c = *t++; - const CustomTypefaceGlyphInfo* const glyph = findGlyphSubstituting (c); + const GlyphInfo* const glyph = findGlyphSubstituting (c); if (glyph != 0) { @@ -87324,7 +87368,7 @@ void CustomTypeface::getGlyphPositions (const String& text, Array & resultG bool CustomTypeface::getOutlineForGlyph (int glyphNumber, Path& path) { - const CustomTypefaceGlyphInfo* const glyph = findGlyphSubstituting ((juce_wchar) glyphNumber); + const GlyphInfo* const glyph = findGlyphSubstituting ((juce_wchar) glyphNumber); if (glyph != 0) { path = glyph->path; @@ -217969,7 +218013,7 @@ private: const FPComponentHolder& operator= (const FPComponentHolder&); }; -void FileChooser::showPlatformDialog (OwnedArray& results, +void FileChooser::showPlatformDialog (Array& results, const String& title, const File& currentFileOrDirectory, const String& filter, @@ -218060,7 +218104,7 @@ void FileChooser::showPlatformDialog (OwnedArray& results, { const String stringFName (fname); - results.add (new File (File (stringFName).getSiblingFile (returnedString))); + results.add (File (stringFName).getSiblingFile (returnedString)); returnedString = String::empty; return; @@ -218151,13 +218195,13 @@ void FileChooser::showPlatformDialog (OwnedArray& results, while (*filename != 0) { const String filepath (String (files) + T("\\") + String (filename)); - results.add (new File (filepath)); + results.add (File (filepath)); filename += CharacterFunctions::length (filename) + 1; } } else if (files[0] != 0) { - results.add (new File (files)); + results.add (File (files)); } } @@ -236904,7 +236948,7 @@ int AudioCDReader::getCDDBId() // compiled on its own). #if JUCE_INCLUDED_FILE -void FileChooser::showPlatformDialog (OwnedArray& results, +void FileChooser::showPlatformDialog (Array& results, const String& title, const File& file, const String& filters, @@ -236966,7 +237010,7 @@ void FileChooser::showPlatformDialog (OwnedArray& results, tokens.add (resultString); for (int i = 0; i < tokens.size(); i++) - results.add (new File (tokens[i])); + results.add (File (tokens[i])); return; } @@ -241968,7 +242012,7 @@ using namespace JUCE_NAMESPACE; BEGIN_JUCE_NAMESPACE -void FileChooser::showPlatformDialog (OwnedArray& results, +void FileChooser::showPlatformDialog (Array& results, const String& title, const File& currentFileOrDirectory, const String& filter, @@ -242022,7 +242066,7 @@ void FileChooser::showPlatformDialog (OwnedArray& results, { if (isSaveDialogue) { - results.add (new File (nsStringToJuce ([panel filename]))); + results.add (File (nsStringToJuce ([panel filename]))); } else { @@ -242031,7 +242075,7 @@ void FileChooser::showPlatformDialog (OwnedArray& results, for (unsigned int i = 0; i < [urls count]; ++i) { NSString* f = [urls objectAtIndex: i]; - results.add (new File (nsStringToJuce (f))); + results.add (File (nsStringToJuce (f))); } } } @@ -242041,7 +242085,7 @@ void FileChooser::showPlatformDialog (OwnedArray& results, #else -void FileChooser::showPlatformDialog (OwnedArray& results, +void FileChooser::showPlatformDialog (Array& results, const String& title, const File& currentFileOrDirectory, const String& filter, @@ -248168,7 +248212,7 @@ using namespace JUCE_NAMESPACE; BEGIN_JUCE_NAMESPACE -void FileChooser::showPlatformDialog (OwnedArray& results, +void FileChooser::showPlatformDialog (Array& results, const String& title, const File& currentFileOrDirectory, const String& filter, @@ -248222,7 +248266,7 @@ void FileChooser::showPlatformDialog (OwnedArray& results, { if (isSaveDialogue) { - results.add (new File (nsStringToJuce ([panel filename]))); + results.add (File (nsStringToJuce ([panel filename]))); } else { @@ -248231,7 +248275,7 @@ void FileChooser::showPlatformDialog (OwnedArray& results, for (unsigned int i = 0; i < [urls count]; ++i) { NSString* f = [urls objectAtIndex: i]; - results.add (new File (nsStringToJuce (f))); + results.add (File (nsStringToJuce (f))); } } } @@ -248241,7 +248285,7 @@ void FileChooser::showPlatformDialog (OwnedArray& results, #else -void FileChooser::showPlatformDialog (OwnedArray& results, +void FileChooser::showPlatformDialog (Array& results, const String& title, const File& currentFileOrDirectory, const String& filter, diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 890f643475..f53b9420b2 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -3962,7 +3962,7 @@ public: ignoreHiddenFiles = 4 /**< Add this flag to avoid returning any hidden files in the results. */ }; - int findChildFiles (OwnedArray& results, + int findChildFiles (Array& results, const int whatToLookFor, const bool searchRecursively, const String& wildCardPattern = JUCE_T("*")) const; @@ -3994,7 +3994,7 @@ public: const bool asUnicode = false, const bool writeUnicodeHeaderBytes = false) const; - static void findFileSystemRoots (OwnedArray& results); + static void findFileSystemRoots (Array& results); const String getVolumeLabel() const; @@ -7281,8 +7281,8 @@ public: juce_UseDebuggingNewOperator private: - OwnedArray filesFound; - OwnedArray dirsFound; + Array filesFound; + Array dirsFound; String wildCard; int index; const int whatToLookFor; @@ -7414,7 +7414,7 @@ public: void removeNonExistentPaths(); - int findChildFiles (OwnedArray& results, + int findChildFiles (Array& results, const int whatToLookFor, const bool searchRecursively, const String& wildCardPattern = JUCE_T("*")) const; @@ -9655,6 +9655,7 @@ private: void addEdgePoint (const int x, const int y, const int winding) throw(); void remapTableForNumEdges (const int newNumEdgesPerLine) throw(); void intersectWithEdgeTableLine (const int y, const int* otherLine) throw(); + void clipEdgeTableLineToRange (int* line, int x1, int x2) throw(); void sanitiseLevels (const bool useNonZeroWinding) throw(); }; @@ -9873,7 +9874,6 @@ private: /********* End of inlined file: juce_Path.h *********/ class Font; -class CustomTypefaceGlyphInfo; class JUCE_API Typeface : public ReferenceCountedObject { @@ -9952,14 +9952,16 @@ protected: private: - OwnedArray glyphs; + class GlyphInfo; + friend class OwnedArray; + OwnedArray glyphs; short lookupTable [128]; CustomTypeface (const CustomTypeface&); const CustomTypeface& operator= (const CustomTypeface&); - CustomTypefaceGlyphInfo* findGlyph (const juce_wchar character, const bool loadIfNeeded) throw(); - CustomTypefaceGlyphInfo* findGlyphSubstituting (const juce_wchar character) throw(); + GlyphInfo* findGlyph (const juce_wchar character, const bool loadIfNeeded) throw(); + GlyphInfo* findGlyphSubstituting (const juce_wchar character) throw(); }; #endif // __JUCE_TYPEFACE_JUCEHEADER__ @@ -13420,13 +13422,13 @@ private: #if JUCE_MAC File volumeDir; - OwnedArray tracks; - Array trackStartSamples; + Array tracks; + Array trackStartSamples; int currentReaderTrack; ScopedPointer reader; AudioCDReader (const File& volume); public: - static int compareElements (const File* const, const File* const) throw(); + static int compareElements (const File&, const File&); private: #elif JUCE_WINDOWS @@ -16737,7 +16739,6 @@ public: private: - friend class MidiComparator; friend class MidiFile; OwnedArray list; @@ -20109,8 +20110,6 @@ public: #endif // __JUCE_CODETOKENISER_JUCEHEADER__ /********* End of inlined file: juce_CodeTokeniser.h *********/ -class CodeEditorLine; - class JUCE_API CodeEditorComponent : public Component, public Timer, public ScrollBarListener, @@ -20251,6 +20250,7 @@ private: CodeTokeniser* codeTokeniser; Array coloursForTokenCategories; + class CodeEditorLine; OwnedArray lines; void rebuildLineTokens(); @@ -21763,7 +21763,7 @@ private: int flags; File currentRoot; - OwnedArray chosenFiles; + Array chosenFiles; SortedSet listeners; DirectoryContentsDisplayComponent* fileListComponent; @@ -21817,14 +21817,14 @@ public: const File getResult() const; - const OwnedArray & getResults() const; + const Array& getResults() const; juce_UseDebuggingNewOperator private: String title, filters; File startingFile; - OwnedArray results; + Array results; bool useNativeDialogBox; bool showDialog (const bool selectsDirectories, @@ -21834,7 +21834,7 @@ private: const bool selectMultipleFiles, FilePreviewComponent* const previewComponent); - static void showPlatformDialog (OwnedArray& results, + static void showPlatformDialog (Array& results, const String& title, const File& file, const String& filters, @@ -23862,9 +23862,9 @@ public: juce_UseDebuggingNewOperator - class Token; - private: + class Token; + friend class OwnedArray ; OwnedArray tokens; int totalLines; }; @@ -25921,6 +25921,7 @@ public: private: class OpenGLComponentWatcher; + friend class ScopedPointer ; ScopedPointer componentWatcher; OpenGLContext* context; diff --git a/src/application/juce_ApplicationProperties.h b/src/application/juce_ApplicationProperties.h index 0d2748a48b..ae625a7b2c 100644 --- a/src/application/juce_ApplicationProperties.h +++ b/src/application/juce_ApplicationProperties.h @@ -29,6 +29,7 @@ #include "../utilities/juce_PropertiesFile.h" #include "../utilities/juce_DeletedAtShutdown.h" #include "../core/juce_Singleton.h" +#include "../containers/juce_ScopedPointer.h" //============================================================================== diff --git a/src/audio/audio_file_formats/juce_AudioCDReader.cpp b/src/audio/audio_file_formats/juce_AudioCDReader.cpp index 02ec911a1b..dea9c90aac 100644 --- a/src/audio/audio_file_formats/juce_AudioCDReader.cpp +++ b/src/audio/audio_file_formats/juce_AudioCDReader.cpp @@ -39,36 +39,36 @@ BEGIN_JUCE_NAMESPACE #include "../../io/streams/juce_BufferedInputStream.h" -static void findCDs (OwnedArray& cds) +static void findCDs (Array& cds) { File volumes ("/Volumes"); volumes.findChildFiles (cds, File::findDirectories, false); for (int i = cds.size(); --i >= 0;) - if (! cds[i]->getChildFile (".TOC.plist").exists()) + if (! cds.getReference(i).getChildFile (".TOC.plist").exists()) cds.remove (i); } const StringArray AudioCDReader::getAvailableCDNames() { - OwnedArray cds; + Array cds; findCDs (cds); StringArray names; for (int i = 0; i < cds.size(); ++i) - names.add (cds[i]->getFileName()); + names.add (cds.getReference(i).getFileName()); return names; } AudioCDReader* AudioCDReader::createReaderForCD (const int index) { - OwnedArray cds; + Array cds; findCDs (cds); - if (cds[index] != 0) - return new AudioCDReader (*cds[index]); + if (cds[index] != File::nonexistent) + return new AudioCDReader (cds[index]); else return 0; } @@ -98,10 +98,10 @@ static int getTrackNumber (const File& file) .getIntValue(); } -int AudioCDReader::compareElements (const File* const first, const File* const second) throw() +int AudioCDReader::compareElements (const File& first, const File& second) { - const int firstTrack = getTrackNumber (*first); - const int secondTrack = getTrackNumber (*second); + const int firstTrack = getTrackNumber (first); + const int secondTrack = getTrackNumber (second); jassert (firstTrack > 0 && secondTrack > 0); @@ -123,7 +123,7 @@ void AudioCDReader::refreshTrackLengths() { trackStartSamples.add (sample); - FileInputStream* const in = tracks[i]->createInputStream(); + FileInputStream* const in = tracks.getReference(i).createInputStream(); if (in != 0) { @@ -161,22 +161,19 @@ bool AudioCDReader::readSamples (int** destSamples, int numDestChannels, int sta { reader = 0; - if (tracks [track] != 0) - { - FileInputStream* const in = tracks [track]->createInputStream(); + FileInputStream* const in = tracks [track].createInputStream(); - if (in != 0) - { - BufferedInputStream* const bin = new BufferedInputStream (in, 65536, true); + if (in != 0) + { + BufferedInputStream* const bin = new BufferedInputStream (in, 65536, true); - AiffAudioFormat format; - reader = format.createReaderFor (bin, true); + AiffAudioFormat format; + reader = format.createReaderFor (bin, true); - if (reader == 0) - currentReaderTrack = -1; - else - currentReaderTrack = track; - } + if (reader == 0) + currentReaderTrack = -1; + else + currentReaderTrack = track; } } @@ -212,7 +209,7 @@ int AudioCDReader::getPositionOfTrackStart (int trackNum) const bool AudioCDReader::isTrackAudio (int trackNum) const { - return tracks [trackNum] != 0; + return tracks [trackNum] != File::nonexistent; } void AudioCDReader::enableIndexScanning (bool b) diff --git a/src/audio/audio_file_formats/juce_AudioCDReader.h b/src/audio/audio_file_formats/juce_AudioCDReader.h index d1c0689ee0..915e071316 100644 --- a/src/audio/audio_file_formats/juce_AudioCDReader.h +++ b/src/audio/audio_file_formats/juce_AudioCDReader.h @@ -30,6 +30,7 @@ #include "juce_AudioFormatReader.h" #include "../../containers/juce_Array.h" +#include "../../containers/juce_ScopedPointer.h" #include "../../text/juce_StringArray.h" #if JUCE_MAC #include "../../io/files/juce_File.h" @@ -152,13 +153,13 @@ private: #if JUCE_MAC File volumeDir; - OwnedArray tracks; - Array trackStartSamples; + Array tracks; + Array trackStartSamples; int currentReaderTrack; ScopedPointer reader; AudioCDReader (const File& volume); public: - static int compareElements (const File* const, const File* const) throw(); + static int compareElements (const File&, const File&); private: #elif JUCE_WINDOWS diff --git a/src/audio/audio_file_formats/juce_AudioFormatManager.cpp b/src/audio/audio_file_formats/juce_AudioFormatManager.cpp index 1dcbc513fa..63822403de 100644 --- a/src/audio/audio_file_formats/juce_AudioFormatManager.cpp +++ b/src/audio/audio_file_formats/juce_AudioFormatManager.cpp @@ -33,6 +33,7 @@ BEGIN_JUCE_NAMESPACE #include "juce_FlacAudioFormat.h" #include "juce_OggVorbisAudioFormat.h" #include "../../io/files/juce_FileInputStream.h" +#include "../../containers/juce_ScopedPointer.h" //============================================================================== diff --git a/src/audio/audio_file_formats/juce_FlacAudioFormat.cpp b/src/audio/audio_file_formats/juce_FlacAudioFormat.cpp index a7b2a08e71..4f6ffb5bae 100644 --- a/src/audio/audio_file_formats/juce_FlacAudioFormat.cpp +++ b/src/audio/audio_file_formats/juce_FlacAudioFormat.cpp @@ -78,6 +78,7 @@ BEGIN_JUCE_NAMESPACE #include "juce_FlacAudioFormat.h" #include "../../text/juce_LocalisedStrings.h" +#include "../../containers/juce_ScopedPointer.h" using namespace FlacNamespace; diff --git a/src/audio/audio_file_formats/juce_QuickTimeAudioFormat.cpp b/src/audio/audio_file_formats/juce_QuickTimeAudioFormat.cpp index 0cd54cfc8e..f6f586927e 100644 --- a/src/audio/audio_file_formats/juce_QuickTimeAudioFormat.cpp +++ b/src/audio/audio_file_formats/juce_QuickTimeAudioFormat.cpp @@ -65,6 +65,7 @@ BEGIN_JUCE_NAMESPACE #include "../../text/juce_LocalisedStrings.h" #include "../../threads/juce_Thread.h" #include "../../io/network/juce_URL.h" +#include "../../containers/juce_ScopedPointer.h" bool juce_OpenQuickTimeMovieFromStream (InputStream* input, Movie& movie, Handle& dataHandle); diff --git a/src/audio/midi/juce_MidiMessageSequence.h b/src/audio/midi/juce_MidiMessageSequence.h index f466c40cf7..0f4630fe30 100644 --- a/src/audio/midi/juce_MidiMessageSequence.h +++ b/src/audio/midi/juce_MidiMessageSequence.h @@ -278,7 +278,6 @@ public: private: //============================================================================== - friend class MidiComparator; friend class MidiFile; OwnedArray list; diff --git a/src/audio/plugins/juce_KnownPluginList.cpp b/src/audio/plugins/juce_KnownPluginList.cpp index f5a2a68d95..b0fa22aad9 100644 --- a/src/audio/plugins/juce_KnownPluginList.cpp +++ b/src/audio/plugins/juce_KnownPluginList.cpp @@ -198,11 +198,11 @@ void KnownPluginList::scanAndAddDragAndDroppedFiles (const StringArray& files, StringArray s; { - OwnedArray subFiles; + Array subFiles; f.findChildFiles (subFiles, File::findFilesAndDirectories, false); for (int j = 0; j < subFiles.size(); ++j) - s.add (subFiles.getUnchecked (j)->getFullPathName()); + s.add (subFiles.getReference(j).getFullPathName()); } scanAndAddDragAndDroppedFiles (s, typesFound); diff --git a/src/core/juce_FileLogger.h b/src/core/juce_FileLogger.h index 58b0859b84..ec419b6d80 100644 --- a/src/core/juce_FileLogger.h +++ b/src/core/juce_FileLogger.h @@ -28,6 +28,7 @@ #include "juce_Logger.h" #include "../io/files/juce_File.h" +#include "../containers/juce_ScopedPointer.h" //============================================================================== diff --git a/src/gui/components/code_editor/juce_CodeEditorComponent.cpp b/src/gui/components/code_editor/juce_CodeEditorComponent.cpp index 9f583f31cd..6033a28bcb 100644 --- a/src/gui/components/code_editor/juce_CodeEditorComponent.cpp +++ b/src/gui/components/code_editor/juce_CodeEditorComponent.cpp @@ -69,7 +69,7 @@ public: }; //============================================================================== -class CodeEditorLine +class CodeEditorComponent::CodeEditorLine { public: CodeEditorLine() throw() @@ -86,11 +86,12 @@ public: const CodeDocument::Position& selectionStart, const CodeDocument::Position& selectionEnd) { - OwnedArray newTokens; + Array newTokens; + newTokens.ensureStorageAllocated (8); if (analyser == 0) { - newTokens.add (new SyntaxToken (document.getLine (lineNum), -1)); + newTokens.add (SyntaxToken (document.getLine (lineNum), -1)); } else if (lineNum < document.getNumLines()) { @@ -128,7 +129,7 @@ public: for (int i = newTokens.size(); --i >= 0;) { - if (*tokens.getUnchecked(i) != *newTokens.getUnchecked(i)) + if (tokens.getReference(i) != newTokens.getReference(i)) { allTheSame = false; break; @@ -159,22 +160,22 @@ public: for (int i = 0; i < tokens.size(); ++i) { - SyntaxToken* const token = tokens.getUnchecked(i); + SyntaxToken& token = tokens.getReference(i); - if (lastType != token->tokenType) + if (lastType != token.tokenType) { - lastType = token->tokenType; + lastType = token.tokenType; g.setColour (owner.getColourForTokenType (lastType)); } - g.drawSingleLineText (token->text, roundToInt (x), y + baselineOffset); + g.drawSingleLineText (token.text, roundToInt (x), y + baselineOffset); if (i < tokens.size() - 1) { - if (token->width < 0) - token->width = font.getStringWidthFloat (token->text); + if (token.width < 0) + token.width = font.getStringWidthFloat (token.text); - x += token->width; + x += token.width; } } } @@ -197,13 +198,13 @@ private: } }; - OwnedArray tokens; + Array tokens; int highlightColumnStart, highlightColumnEnd; static void createTokens (int startPosition, const String& lineText, CodeDocument::Iterator& source, CodeTokeniser* analyser, - OwnedArray & newTokens) + Array & newTokens) { CodeDocument::Iterator lastIterator (source); const int lineLength = lineText.length(); @@ -222,8 +223,8 @@ private: if (tokenEnd > 0) { tokenStart -= startPosition; - newTokens.add (new SyntaxToken (lineText.substring (jmax (0, tokenStart), tokenEnd), - tokenType)); + newTokens.add (SyntaxToken (lineText.substring (jmax (0, tokenStart), tokenEnd), + tokenType)); if (tokenEnd >= lineLength) break; @@ -235,24 +236,24 @@ private: source = lastIterator; } - static void replaceTabsWithSpaces (OwnedArray & tokens, const int spacesPerTab) throw() + static void replaceTabsWithSpaces (Array & tokens, const int spacesPerTab) throw() { int x = 0; for (int i = 0; i < tokens.size(); ++i) { - SyntaxToken* const t = tokens.getUnchecked(i); + SyntaxToken& t = tokens.getReference(i); for (;;) { - int tabPos = t->text.indexOfChar (T('\t')); + int tabPos = t.text.indexOfChar (T('\t')); if (tabPos < 0) break; const int spacesNeeded = spacesPerTab - ((tabPos + x) % spacesPerTab); - t->text = t->text.replaceSection (tabPos, 1, String::repeatedString (T(" "), spacesNeeded)); + t.text = t.text.replaceSection (tabPos, 1, String::repeatedString (T(" "), spacesNeeded)); } - x += t->text.length(); + x += t.text.length(); } } diff --git a/src/gui/components/code_editor/juce_CodeEditorComponent.h b/src/gui/components/code_editor/juce_CodeEditorComponent.h index 94ea11010b..98e25d33d8 100644 --- a/src/gui/components/code_editor/juce_CodeEditorComponent.h +++ b/src/gui/components/code_editor/juce_CodeEditorComponent.h @@ -30,7 +30,6 @@ #include "../layout/juce_ScrollBar.h" #include "juce_CodeDocument.h" #include "juce_CodeTokeniser.h" -class CodeEditorLine; //============================================================================== @@ -271,6 +270,7 @@ private: CodeTokeniser* codeTokeniser; Array coloursForTokenCategories; + class CodeEditorLine; OwnedArray lines; void rebuildLineTokens(); diff --git a/src/gui/components/filebrowser/juce_FileBrowserComponent.cpp b/src/gui/components/filebrowser/juce_FileBrowserComponent.cpp index a9fa1c0caa..24e7d6a73d 100644 --- a/src/gui/components/filebrowser/juce_FileBrowserComponent.cpp +++ b/src/gui/components/filebrowser/juce_FileBrowserComponent.cpp @@ -66,7 +66,7 @@ FileBrowserComponent::FileBrowserComponent (int flags_, } else { - chosenFiles.add (new File (initialFileOrDirectory)); + chosenFiles.add (initialFileOrDirectory); currentRoot = initialFileOrDirectory.getParentDirectory(); filename = initialFileOrDirectory.getFileName(); } @@ -182,7 +182,7 @@ const File FileBrowserComponent::getSelectedFile (int index) const throw() if (! filenameBox->isReadOnly()) return currentRoot.getChildFile (filenameBox->getText()); else - return chosenFiles[index] != 0 ? *chosenFiles[index] : File::nonexistent; + return chosenFiles[index]; } bool FileBrowserComponent::currentFileIsValid() const @@ -337,7 +337,7 @@ void FileBrowserComponent::selectionChanged() resetChosenFiles = false; } - chosenFiles.add (new File (f)); + chosenFiles.add (f); newFilenames.add (f.getRelativePathFrom (getRoot())); } } @@ -422,7 +422,7 @@ void FileBrowserComponent::textEditorReturnKeyPressed (TextEditor&) { setRoot (f.getParentDirectory()); chosenFiles.clear(); - chosenFiles.add (new File (f)); + chosenFiles.add (f); filenameBox->setText (f.getFileName()); } } @@ -490,27 +490,27 @@ const BitArray FileBrowserComponent::getRoots (StringArray& rootNames, StringArr BitArray separators; #if JUCE_WINDOWS - OwnedArray roots; + Array roots; File::findFileSystemRoots (roots); rootPaths.clear(); for (int i = 0; i < roots.size(); ++i) { - const File* const drive = roots.getUnchecked(i); + const File& drive = roots.getReference(i); - String name (drive->getFullPathName()); + String name (drive.getFullPathName()); rootPaths.add (name); - if (drive->isOnHardDisk()) + if (drive.isOnHardDisk()) { - String volume (drive->getVolumeLabel()); + String volume (drive.getVolumeLabel()); if (volume.isEmpty()) volume = TRANS("Hard Drive"); - name << " [" << drive->getVolumeLabel() << ']'; + name << " [" << drive.getVolumeLabel() << ']'; } - else if (drive->isOnCDRomDrive()) + else if (drive.isOnCDRomDrive()) { name << TRANS(" [CD/DVD drive]"); } @@ -536,18 +536,18 @@ const BitArray FileBrowserComponent::getRoots (StringArray& rootNames, StringArr separators.setBit (rootPaths.size()); - OwnedArray volumes; + Array volumes; File vol ("/Volumes"); vol.findChildFiles (volumes, File::findDirectories, false); for (int i = 0; i < volumes.size(); ++i) { - const File* const volume = volumes.getUnchecked(i); + const File& volume = volumes.getReference(i); - if (volume->isDirectory() && ! volume->getFileName().startsWithChar (T('.'))) + if (volume.isDirectory() && ! volume.getFileName().startsWithChar (T('.'))) { - rootPaths.add (volume->getFullPathName()); - rootNames.add (volume->getFileName()); + rootPaths.add (volume.getFullPathName()); + rootNames.add (volume.getFileName()); } } #endif diff --git a/src/gui/components/filebrowser/juce_FileBrowserComponent.h b/src/gui/components/filebrowser/juce_FileBrowserComponent.h index ac569c7dc2..68f207d0fa 100644 --- a/src/gui/components/filebrowser/juce_FileBrowserComponent.h +++ b/src/gui/components/filebrowser/juce_FileBrowserComponent.h @@ -212,7 +212,7 @@ private: int flags; File currentRoot; - OwnedArray chosenFiles; + Array chosenFiles; SortedSet listeners; DirectoryContentsDisplayComponent* fileListComponent; diff --git a/src/gui/components/filebrowser/juce_FileChooser.cpp b/src/gui/components/filebrowser/juce_FileChooser.cpp index be34f65ec4..87d670027b 100644 --- a/src/gui/components/filebrowser/juce_FileChooser.cpp +++ b/src/gui/components/filebrowser/juce_FileChooser.cpp @@ -87,15 +87,10 @@ const File FileChooser::getResult() const // to retrieve all the files that were chosen. jassert (results.size() <= 1); - const File* const f = results.getFirst(); - - if (f != 0) - return *f; - - return File::nonexistent; + return results.getFirst(); } -const OwnedArray & FileChooser::getResults() const +const Array& FileChooser::getResults() const { return results; } @@ -161,7 +156,7 @@ bool FileChooser::showDialog (const bool selectsDirectories, if (box.show()) { for (int i = 0; i < browserComponent.getNumSelectedFiles(); ++i) - results.add (new File (browserComponent.getSelectedFile (i))); + results.add (browserComponent.getSelectedFile (i)); } } diff --git a/src/gui/components/filebrowser/juce_FileChooser.h b/src/gui/components/filebrowser/juce_FileChooser.h index 1fa99874a7..ff467733a4 100644 --- a/src/gui/components/filebrowser/juce_FileChooser.h +++ b/src/gui/components/filebrowser/juce_FileChooser.h @@ -167,7 +167,7 @@ public: @see getResult */ - const OwnedArray & getResults() const; + const Array& getResults() const; //============================================================================== juce_UseDebuggingNewOperator @@ -175,7 +175,7 @@ public: private: String title, filters; File startingFile; - OwnedArray results; + Array results; bool useNativeDialogBox; bool showDialog (const bool selectsDirectories, @@ -185,7 +185,7 @@ private: const bool selectMultipleFiles, FilePreviewComponent* const previewComponent); - static void showPlatformDialog (OwnedArray& results, + static void showPlatformDialog (Array& results, const String& title, const File& file, const String& filters, diff --git a/src/gui/components/special/juce_MagnifierComponent.cpp b/src/gui/components/special/juce_MagnifierComponent.cpp index 22c288776d..97112689f6 100644 --- a/src/gui/components/special/juce_MagnifierComponent.cpp +++ b/src/gui/components/special/juce_MagnifierComponent.cpp @@ -275,7 +275,9 @@ void MagnifierComponent::paint (Graphics& g) } g.setImageResamplingQuality (quality); - g.drawImageTransformed (&temp, temp.getBounds(), AffineTransform::scale (scaleFactor, scaleFactor), false); + g.drawImageTransformed (&temp, temp.getBounds(), + AffineTransform::scale ((float) scaleFactor, (float) scaleFactor), + false); } void MagnifierComponent::childBoundsChanged (Component* c) diff --git a/src/gui/components/special/juce_OpenGLComponent.h b/src/gui/components/special/juce_OpenGLComponent.h index 4f30582b75..a9d978076f 100644 --- a/src/gui/components/special/juce_OpenGLComponent.h +++ b/src/gui/components/special/juce_OpenGLComponent.h @@ -332,6 +332,7 @@ public: private: class OpenGLComponentWatcher; + friend class ScopedPointer ; ScopedPointer componentWatcher; OpenGLContext* context; diff --git a/src/gui/graphics/contexts/juce_EdgeTable.cpp b/src/gui/graphics/contexts/juce_EdgeTable.cpp index 98bd74cf43..18e351faf1 100644 --- a/src/gui/graphics/contexts/juce_EdgeTable.cpp +++ b/src/gui/graphics/contexts/juce_EdgeTable.cpp @@ -435,6 +435,16 @@ void EdgeTable::intersectWithEdgeTableLine (const int y, const int* otherLine) t return; } + const int right = bounds.getRight() << 8; + + // optimise for the common case where our line lies entirely within a + // single pair of points, as happens when clipping to a simple rect. + if (otherNumPoints == 2 && otherLine[2] >= 255) + { + clipEdgeTableLineToRange (dest, otherLine[1], jmin (right, otherLine[3])); + return; + } + ++otherLine; const size_t lineSizeBytes = (dest[0] * 2 + 1) * sizeof (int); int* temp = (int*) alloca (lineSizeBytes); @@ -451,7 +461,6 @@ void EdgeTable::intersectWithEdgeTableLine (const int y, const int* otherLine) t int destIndex = 0, destTotal = 0; int level1 = 0, level2 = 0; int lastX = INT_MIN, lastLevel = 0; - const int right = bounds.getRight() << 8; while (srcNum1 > 0 && srcNum2 > 0) { @@ -537,6 +546,46 @@ void EdgeTable::intersectWithEdgeTableLine (const int y, const int* otherLine) t #endif } +void EdgeTable::clipEdgeTableLineToRange (int* dest, const int x1, const int x2) throw() +{ + int* lastItem = dest + (dest[0] * 2 - 1); + + if (x2 < lastItem[0]) + { + if (x2 <= dest[1]) + { + dest[0] = 0; + return; + } + + while (x2 < lastItem[-2]) + { + --(dest[0]); + lastItem -= 2; + } + + lastItem[0] = x2; + lastItem[1] = 0; + } + + if (x1 > dest[1]) + { + while (lastItem[0] > x1) + lastItem -= 2; + + const int itemsRemoved = (lastItem - (dest + 1)) / 2; + + if (itemsRemoved > 0) + { + dest[0] -= itemsRemoved; + memmove (dest + 1, lastItem, dest[0] * (sizeof (int) * 2)); + } + + dest[1] = x1; + } +} + + //============================================================================== void EdgeTable::clipToRectangle (const Rectangle& r) throw() { @@ -563,10 +612,17 @@ void EdgeTable::clipToRectangle (const Rectangle& r) throw() if (clipped.getX() > bounds.getX()) { - const int rectLine[] = { 2, clipped.getX() << 8, 255, clipped.getRight() << 8, 0 }; + const int x1 = clipped.getX() << 8; + const int x2 = jmin (bounds.getRight(), clipped.getRight()) << 8; + int* line = table + lineStrideElements * top; - for (int i = top; i < bottom; ++i) - intersectWithEdgeTableLine (i, rectLine); + for (int i = bottom - top; --i >= 0;) + { + if (line[0] != 0) + clipEdgeTableLineToRange (line, x1, x2); + + line += lineStrideElements; + } } needToCheckEmptinesss = true; diff --git a/src/gui/graphics/contexts/juce_EdgeTable.h b/src/gui/graphics/contexts/juce_EdgeTable.h index 9787009799..2487b661af 100644 --- a/src/gui/graphics/contexts/juce_EdgeTable.h +++ b/src/gui/graphics/contexts/juce_EdgeTable.h @@ -203,6 +203,7 @@ private: void addEdgePoint (const int x, const int y, const int winding) throw(); void remapTableForNumEdges (const int newNumEdgesPerLine) throw(); void intersectWithEdgeTableLine (const int y, const int* otherLine) throw(); + void clipEdgeTableLineToRange (int* line, int x1, int x2) throw(); void sanitiseLevels (const bool useNonZeroWinding) throw(); }; diff --git a/src/gui/graphics/fonts/juce_TextLayout.h b/src/gui/graphics/fonts/juce_TextLayout.h index e0d7ece9f0..279e55fcee 100644 --- a/src/gui/graphics/fonts/juce_TextLayout.h +++ b/src/gui/graphics/fonts/juce_TextLayout.h @@ -142,10 +142,9 @@ public: //============================================================================== juce_UseDebuggingNewOperator - /** @internal */ - class Token; - private: + class Token; + friend class OwnedArray ; OwnedArray tokens; int totalLines; }; diff --git a/src/gui/graphics/fonts/juce_Typeface.cpp b/src/gui/graphics/fonts/juce_Typeface.cpp index 7c834a2d5c..c0a5e3e540 100644 --- a/src/gui/graphics/fonts/juce_Typeface.cpp +++ b/src/gui/graphics/fonts/juce_Typeface.cpp @@ -45,15 +45,15 @@ Typeface::~Typeface() } //============================================================================== -class CustomTypefaceGlyphInfo +class CustomTypeface::GlyphInfo { public: - CustomTypefaceGlyphInfo (const juce_wchar character_, const Path& path_, const float width_) throw() + GlyphInfo (const juce_wchar character_, const Path& path_, const float width_) throw() : character (character_), path (path_), width (width_) { } - ~CustomTypefaceGlyphInfo() throw() + ~GlyphInfo() throw() { } @@ -92,8 +92,8 @@ public: juce_UseDebuggingNewOperator private: - CustomTypefaceGlyphInfo (const CustomTypefaceGlyphInfo&); - const CustomTypefaceGlyphInfo& operator= (const CustomTypefaceGlyphInfo&); + GlyphInfo (const GlyphInfo&); + const GlyphInfo& operator= (const GlyphInfo&); }; //============================================================================== @@ -172,14 +172,14 @@ void CustomTypeface::addGlyph (const juce_wchar character, const Path& path, con if (((unsigned int) character) < (unsigned int) numElementsInArray (lookupTable)) lookupTable [character] = (short) glyphs.size(); - glyphs.add (new CustomTypefaceGlyphInfo (character, path, width)); + glyphs.add (new GlyphInfo (character, path, width)); } void CustomTypeface::addKerningPair (const juce_wchar char1, const juce_wchar char2, const float extraAmount) throw() { if (extraAmount != 0) { - CustomTypefaceGlyphInfo* const g = findGlyph (char1, true); + GlyphInfo* const g = findGlyph (char1, true); jassert (g != 0); // can only add kerning pairs for characters that exist! if (g != 0) @@ -187,14 +187,14 @@ void CustomTypeface::addKerningPair (const juce_wchar char1, const juce_wchar ch } } -CustomTypefaceGlyphInfo* CustomTypeface::findGlyph (const juce_wchar character, const bool loadIfNeeded) throw() +CustomTypeface::GlyphInfo* CustomTypeface::findGlyph (const juce_wchar character, const bool loadIfNeeded) throw() { if (((unsigned int) character) < (unsigned int) numElementsInArray (lookupTable) && lookupTable [character] > 0) return glyphs [(int) lookupTable [(int) character]]; for (int i = 0; i < glyphs.size(); ++i) { - CustomTypefaceGlyphInfo* const g = glyphs.getUnchecked(i); + GlyphInfo* const g = glyphs.getUnchecked(i); if (g->character == character) return g; } @@ -205,9 +205,9 @@ CustomTypefaceGlyphInfo* CustomTypeface::findGlyph (const juce_wchar character, return 0; } -CustomTypefaceGlyphInfo* CustomTypeface::findGlyphSubstituting (const juce_wchar character) throw() +CustomTypeface::GlyphInfo* CustomTypeface::findGlyphSubstituting (const juce_wchar character) throw() { - CustomTypefaceGlyphInfo* glyph = findGlyph (character, true); + GlyphInfo* glyph = findGlyph (character, true); if (glyph == 0) { @@ -286,7 +286,7 @@ bool CustomTypeface::writeToStream (OutputStream& outputStream) for (i = 0; i < glyphs.size(); ++i) { - const CustomTypefaceGlyphInfo* const g = glyphs.getUnchecked (i); + const GlyphInfo* const g = glyphs.getUnchecked (i); out.writeShort ((short) (unsigned short) g->character); out.writeFloat (g->width); g->path.writePathToStream (out); @@ -298,11 +298,11 @@ bool CustomTypeface::writeToStream (OutputStream& outputStream) for (i = 0; i < glyphs.size(); ++i) { - const CustomTypefaceGlyphInfo* const g = glyphs.getUnchecked (i); + const GlyphInfo* const g = glyphs.getUnchecked (i); for (int j = 0; j < g->kerningPairs.size(); ++j) { - const CustomTypefaceGlyphInfo::KerningPair& p = g->kerningPairs.getReference (j); + const GlyphInfo::KerningPair& p = g->kerningPairs.getReference (j); out.writeShort ((short) (unsigned short) g->character); out.writeShort ((short) (unsigned short) p.character2); out.writeFloat (p.kerningAmount); @@ -330,7 +330,7 @@ float CustomTypeface::getStringWidth (const String& text) while (*t != 0) { - const CustomTypefaceGlyphInfo* const glyph = findGlyphSubstituting (*t++); + const GlyphInfo* const glyph = findGlyphSubstituting (*t++); if (glyph != 0) x += glyph->getHorizontalSpacing (*t); @@ -348,7 +348,7 @@ void CustomTypeface::getGlyphPositions (const String& text, Array & resultG while (*t != 0) { const juce_wchar c = *t++; - const CustomTypefaceGlyphInfo* const glyph = findGlyphSubstituting (c); + const GlyphInfo* const glyph = findGlyphSubstituting (c); if (glyph != 0) { @@ -361,7 +361,7 @@ void CustomTypeface::getGlyphPositions (const String& text, Array & resultG bool CustomTypeface::getOutlineForGlyph (int glyphNumber, Path& path) { - const CustomTypefaceGlyphInfo* const glyph = findGlyphSubstituting ((juce_wchar) glyphNumber); + const GlyphInfo* const glyph = findGlyphSubstituting ((juce_wchar) glyphNumber); if (glyph != 0) { path = glyph->path; diff --git a/src/gui/graphics/fonts/juce_Typeface.h b/src/gui/graphics/fonts/juce_Typeface.h index eb9461ab05..e995112725 100644 --- a/src/gui/graphics/fonts/juce_Typeface.h +++ b/src/gui/graphics/fonts/juce_Typeface.h @@ -32,7 +32,6 @@ #include "../../../io/streams/juce_OutputStream.h" #include "../geometry/juce_Path.h" class Font; -class CustomTypefaceGlyphInfo; //============================================================================== @@ -220,14 +219,16 @@ protected: private: //============================================================================== - OwnedArray glyphs; + class GlyphInfo; + friend class OwnedArray; + OwnedArray glyphs; short lookupTable [128]; CustomTypeface (const CustomTypeface&); const CustomTypeface& operator= (const CustomTypeface&); - CustomTypefaceGlyphInfo* findGlyph (const juce_wchar character, const bool loadIfNeeded) throw(); - CustomTypefaceGlyphInfo* findGlyphSubstituting (const juce_wchar character) throw(); + GlyphInfo* findGlyph (const juce_wchar character, const bool loadIfNeeded) throw(); + GlyphInfo* findGlyphSubstituting (const juce_wchar character) throw(); }; #endif // __JUCE_TYPEFACE_JUCEHEADER__ diff --git a/src/io/files/juce_DirectoryIterator.cpp b/src/io/files/juce_DirectoryIterator.cpp index 1d3740c029..0b97004ed4 100644 --- a/src/io/files/juce_DirectoryIterator.cpp +++ b/src/io/files/juce_DirectoryIterator.cpp @@ -77,7 +77,7 @@ DirectoryIterator::DirectoryIterator (const File& directory, && ((whatToLookFor_ & File::ignoreHiddenFiles) == 0 || ! isHidden)) { - dirsFound.add (new File (path + filename, 0)); + dirsFound.add (File (path + filename, 0)); } addToList = (whatToLookFor_ & File::findDirectories) != 0; @@ -96,7 +96,7 @@ DirectoryIterator::DirectoryIterator (const File& directory, addToList = ! isHidden; if (addToList) - filesFound.add (new File (path + filename, 0)); + filesFound.add (File (path + filename, 0)); } } while (juce_findFileNext (handle, filename, &isDirectory, &isHidden, 0, 0, 0, 0)); @@ -126,7 +126,7 @@ bool DirectoryIterator::next() if (index >= filesFound.size()) { - subIterator = new DirectoryIterator (*(dirsFound [index - filesFound.size()]), + subIterator = new DirectoryIterator (dirsFound.getReference (index - filesFound.size()), true, wildCard, whatToLookFor); return next(); } @@ -139,10 +139,7 @@ const File DirectoryIterator::getFile() const if (subIterator != 0) return subIterator->getFile(); - const File* const f = filesFound [index]; - - return (f != 0) ? *f - : File::nonexistent; + return filesFound [index]; } float DirectoryIterator::getEstimatedProgress() const diff --git a/src/io/files/juce_DirectoryIterator.h b/src/io/files/juce_DirectoryIterator.h index 9bbd8852e7..91b41da7ef 100644 --- a/src/io/files/juce_DirectoryIterator.h +++ b/src/io/files/juce_DirectoryIterator.h @@ -101,8 +101,8 @@ public: juce_UseDebuggingNewOperator private: - OwnedArray filesFound; - OwnedArray dirsFound; + Array filesFound; + Array dirsFound; String wildCard; int index; const int whatToLookFor; diff --git a/src/io/files/juce_File.cpp b/src/io/files/juce_File.cpp index 8570957daa..d0e2e71e0a 100644 --- a/src/io/files/juce_File.cpp +++ b/src/io/files/juce_File.cpp @@ -42,6 +42,7 @@ BEGIN_JUCE_NAMESPACE #include "juce_TemporaryFile.h" #include "../../core/juce_SystemStats.h" #include "../../core/juce_Random.h" +#include "../../containers/juce_ScopedPointer.h" #ifdef _MSC_VER #pragma warning (pop) @@ -292,11 +293,11 @@ bool File::setReadOnly (const bool shouldBeReadOnly, if (applyRecursively && isDirectory()) { - OwnedArray subFiles; + Array subFiles; findChildFiles (subFiles, File::findFilesAndDirectories, false); for (int i = subFiles.size(); --i >= 0;) - worked = subFiles[i]->setReadOnly (shouldBeReadOnly, true) && worked; + worked = subFiles.getReference(i).setReadOnly (shouldBeReadOnly, true) && worked; } return juce_setFileReadOnly (fullPath, shouldBeReadOnly) && worked; @@ -314,11 +315,11 @@ bool File::deleteRecursively() const if (isDirectory()) { - OwnedArray subFiles; + Array subFiles; findChildFiles (subFiles, File::findFilesAndDirectories, false); for (int i = subFiles.size(); --i >= 0;) - worked = subFiles[i]->deleteRecursively() && worked; + worked = subFiles.getReference(i).deleteRecursively() && worked; } return deleteFile() && worked; @@ -353,19 +354,19 @@ bool File::copyDirectoryTo (const File& newDirectory) const { if (isDirectory() && newDirectory.createDirectory()) { - OwnedArray subFiles; + Array subFiles; findChildFiles (subFiles, File::findFiles, false); int i; for (i = 0; i < subFiles.size(); ++i) - if (! subFiles[i]->copyFileTo (newDirectory.getChildFile (subFiles[i]->getFileName()))) + if (! subFiles.getReference(i).copyFileTo (newDirectory.getChildFile (subFiles.getReference(i).getFileName()))) return false; subFiles.clear(); findChildFiles (subFiles, File::findDirectories, false); for (i = 0; i < subFiles.size(); ++i) - if (! subFiles[i]->copyDirectoryTo (newDirectory.getChildFile (subFiles[i]->getFileName()))) + if (! subFiles.getReference(i).copyDirectoryTo (newDirectory.getChildFile (subFiles.getReference(i).getFileName()))) return false; return true; @@ -648,7 +649,7 @@ static inline bool fileTypeMatches (const int whatToLookFor, || (whatToLookFor & File::ignoreHiddenFiles) == 0); } -int File::findChildFiles (OwnedArray& results, +int File::findChildFiles (Array& results, const int whatToLookFor, const bool searchRecursively, const String& wildCardPattern) const @@ -677,7 +678,7 @@ int File::findChildFiles (OwnedArray& results, if (fileTypeMatches (whatToLookFor, itemIsDirectory, itemIsHidden) && ! filename.containsOnly (T("."))) { - results.add (new File (path + filename, 0)); + results.add (File (path + filename, 0)); ++total; } @@ -695,16 +696,13 @@ int File::findChildFiles (OwnedArray& results, // and recurse down if required. if (searchRecursively) { - OwnedArray subDirectories; + Array subDirectories; findChildFiles (subDirectories, File::findDirectories, false); for (int i = 0; i < subDirectories.size(); ++i) { - total += subDirectories.getUnchecked(i) - ->findChildFiles (results, - whatToLookFor, - true, - wildCardPattern); + total += subDirectories.getReference(i).findChildFiles (results, whatToLookFor, + true, wildCardPattern); } } @@ -1092,12 +1090,12 @@ const String File::getRelativePathFrom (const File& dir) const } //============================================================================== -void File::findFileSystemRoots (OwnedArray& destArray) +void File::findFileSystemRoots (Array& destArray) { const StringArray roots (juce_getFileSystemRoots()); for (int i = 0; i < roots.size(); ++i) - destArray.add (new File (roots[i])); + destArray.add (File (roots[i])); } const String File::getVolumeLabel() const diff --git a/src/io/files/juce_File.h b/src/io/files/juce_File.h index f380ca7a95..8308f0be8a 100644 --- a/src/io/files/juce_File.h +++ b/src/io/files/juce_File.h @@ -26,7 +26,7 @@ #ifndef __JUCE_FILE_JUCEHEADER__ #define __JUCE_FILE_JUCEHEADER__ -#include "../../containers/juce_OwnedArray.h" +#include "../../containers/juce_Array.h" #include "../../core/juce_Time.h" #include "../../text/juce_StringArray.h" #include "../../containers/juce_MemoryBlock.h" @@ -529,7 +529,7 @@ public: @see getNumberOfChildFiles, DirectoryIterator */ - int findChildFiles (OwnedArray& results, + int findChildFiles (Array& results, const int whatToLookFor, const bool searchRecursively, const String& wildCardPattern = JUCE_T("*")) const; @@ -671,7 +671,7 @@ public: to which ones are available. On the Mac/Linux, this will probably just add a single entry for "/". */ - static void findFileSystemRoots (OwnedArray& results); + static void findFileSystemRoots (Array& results); /** Finds the name of the drive on which this file lives. diff --git a/src/io/files/juce_FileSearchPath.cpp b/src/io/files/juce_FileSearchPath.cpp index 877407fee0..3ce3a0866c 100644 --- a/src/io/files/juce_FileSearchPath.cpp +++ b/src/io/files/juce_FileSearchPath.cpp @@ -138,7 +138,7 @@ void FileSearchPath::removeNonExistentPaths() directories.remove (i); } -int FileSearchPath::findChildFiles (OwnedArray& results, +int FileSearchPath::findChildFiles (Array& results, const int whatToLookFor, const bool searchRecursively, const String& wildCardPattern) const diff --git a/src/io/files/juce_FileSearchPath.h b/src/io/files/juce_FileSearchPath.h index 889d5ab408..3c38b82434 100644 --- a/src/io/files/juce_FileSearchPath.h +++ b/src/io/files/juce_FileSearchPath.h @@ -130,7 +130,7 @@ public: @returns the number of files added to the array @see File::findChildFiles */ - int findChildFiles (OwnedArray& results, + int findChildFiles (Array& results, const int whatToLookFor, const bool searchRecursively, const String& wildCardPattern = JUCE_T("*")) const; diff --git a/src/io/files/juce_ZipFile.h b/src/io/files/juce_ZipFile.h index 482bc47b94..e3ce5a36da 100644 --- a/src/io/files/juce_ZipFile.h +++ b/src/io/files/juce_ZipFile.h @@ -30,7 +30,7 @@ #include "../streams/juce_InputStream.h" #include "../streams/juce_InputSource.h" #include "../../threads/juce_CriticalSection.h" -#include "../../containers/juce_VoidArray.h" +#include "../../containers/juce_OwnedArray.h" //============================================================================== diff --git a/src/native/linux/juce_linux_FileChooser.cpp b/src/native/linux/juce_linux_FileChooser.cpp index 24fb7e0a66..7f566d181e 100644 --- a/src/native/linux/juce_linux_FileChooser.cpp +++ b/src/native/linux/juce_linux_FileChooser.cpp @@ -28,7 +28,7 @@ #if JUCE_INCLUDED_FILE //============================================================================== -void FileChooser::showPlatformDialog (OwnedArray& results, +void FileChooser::showPlatformDialog (Array& results, const String& title, const File& file, const String& filters, @@ -90,7 +90,7 @@ void FileChooser::showPlatformDialog (OwnedArray& results, tokens.add (resultString); for (int i = 0; i < tokens.size(); i++) - results.add (new File (tokens[i])); + results.add (File (tokens[i])); return; } diff --git a/src/native/mac/juce_mac_FileChooser.mm b/src/native/mac/juce_mac_FileChooser.mm index 66eaef158a..4bf6f2f6f2 100644 --- a/src/native/mac/juce_mac_FileChooser.mm +++ b/src/native/mac/juce_mac_FileChooser.mm @@ -79,7 +79,7 @@ using namespace JUCE_NAMESPACE; BEGIN_JUCE_NAMESPACE //============================================================================== -void FileChooser::showPlatformDialog (OwnedArray& results, +void FileChooser::showPlatformDialog (Array& results, const String& title, const File& currentFileOrDirectory, const String& filter, @@ -133,7 +133,7 @@ void FileChooser::showPlatformDialog (OwnedArray& results, { if (isSaveDialogue) { - results.add (new File (nsStringToJuce ([panel filename]))); + results.add (File (nsStringToJuce ([panel filename]))); } else { @@ -142,7 +142,7 @@ void FileChooser::showPlatformDialog (OwnedArray& results, for (unsigned int i = 0; i < [urls count]; ++i) { NSString* f = [urls objectAtIndex: i]; - results.add (new File (nsStringToJuce (f))); + results.add (File (nsStringToJuce (f))); } } } @@ -153,7 +153,7 @@ void FileChooser::showPlatformDialog (OwnedArray& results, #else //============================================================================== -void FileChooser::showPlatformDialog (OwnedArray& results, +void FileChooser::showPlatformDialog (Array& results, const String& title, const File& currentFileOrDirectory, const String& filter, diff --git a/src/native/windows/juce_win32_FileChooser.cpp b/src/native/windows/juce_win32_FileChooser.cpp index 1f247f138b..e41cadcc91 100644 --- a/src/native/windows/juce_win32_FileChooser.cpp +++ b/src/native/windows/juce_win32_FileChooser.cpp @@ -143,7 +143,7 @@ private: }; //============================================================================== -void FileChooser::showPlatformDialog (OwnedArray& results, +void FileChooser::showPlatformDialog (Array& results, const String& title, const File& currentFileOrDirectory, const String& filter, @@ -234,7 +234,7 @@ void FileChooser::showPlatformDialog (OwnedArray& results, { const String stringFName (fname); - results.add (new File (File (stringFName).getSiblingFile (returnedString))); + results.add (File (stringFName).getSiblingFile (returnedString)); returnedString = String::empty; return; @@ -325,13 +325,13 @@ void FileChooser::showPlatformDialog (OwnedArray& results, while (*filename != 0) { const String filepath (String (files) + T("\\") + String (filename)); - results.add (new File (filepath)); + results.add (File (filepath)); filename += CharacterFunctions::length (filename) + 1; } } else if (files[0] != 0) { - results.add (new File (files)); + results.add (File (files)); } } diff --git a/src/text/juce_XmlDocument.h b/src/text/juce_XmlDocument.h index 108f104a17..d1314d7812 100644 --- a/src/text/juce_XmlDocument.h +++ b/src/text/juce_XmlDocument.h @@ -30,6 +30,7 @@ #include "juce_StringArray.h" #include "../io/files/juce_File.h" #include "../io/streams/juce_InputSource.h" +#include "../containers/juce_ScopedPointer.h" //==============================================================================