diff --git a/extras/Introjucer/Source/ComponentEditor/jucer_BinaryResources.cpp b/extras/Introjucer/Source/ComponentEditor/jucer_BinaryResources.cpp index c8211dcdb1..40e25ca2f5 100644 --- a/extras/Introjucer/Source/ComponentEditor/jucer_BinaryResources.cpp +++ b/extras/Introjucer/Source/ComponentEditor/jucer_BinaryResources.cpp @@ -112,7 +112,7 @@ void BinaryResources::add (const String& name, const String& originalFileName, c { BinaryResource* r = findResource (name); - if (r == 0) + if (r == nullptr) { resources.add (r = new BinaryResource()); r->name = name; @@ -120,7 +120,7 @@ void BinaryResources::add (const String& name, const String& originalFileName, c r->originalFilename = originalFileName; r->data = data; - deleteAndZero (r->drawable); + r->drawable = nullptr; changed(); } @@ -187,15 +187,16 @@ void BinaryResources::remove (const int i) const Drawable* BinaryResources::getDrawable (const String& name) const { - BinaryResources::BinaryResource* const res = const_cast (getResource (name)); - - if (res == 0) - return 0; + if (BinaryResources::BinaryResource* const res = const_cast (getResource (name))) + { + if (res->drawable == nullptr && res->data.getSize() > 0) + res->drawable = Drawable::createFromImageData (res->data.getData(), + res->data.getSize()); - if (res->drawable == 0 && res->data.getSize() > 0) - res->drawable = Drawable::createFromImageData (res->data.getData(), res->data.getSize()); + return res->drawable; + } - return res->drawable; + return nullptr; } Image BinaryResources::getImageFromCache (const String& name) const @@ -277,7 +278,8 @@ void BinaryResources::fillInGeneratedCode (GeneratedCode& code) const { code.publicMemberDeclarations << "// Binary resources:\n"; - String defs; + MemoryOutputStream defs; + defs << "//==============================================================================\n"; defs << "// Binary resources - be careful not to edit any of these sections!\n\n"; @@ -304,35 +306,29 @@ void BinaryResources::fillInGeneratedCode (GeneratedCode& code) const line1 << "static const unsigned char resource_" << code.className << "_" << name << "[] = { "; - defs += line1; + defs << line1; - MemoryOutputStream out (65536); int charsOnLine = line1.length(); for (size_t j = 0; j < mb.getSize(); ++j) { - const int num = ((int) (unsigned char) mb[j]); - out << num << ','; + const int num = (int) (unsigned char) mb[j]; + defs << num << ','; charsOnLine += 2; - if (num >= 10) - ++charsOnLine; - if (num >= 100) - ++charsOnLine; + if (num >= 10) ++charsOnLine; + if (num >= 100) ++charsOnLine; if (charsOnLine >= 200) { charsOnLine = 0; - out << '\n'; + defs << '\n'; } } - out << (char) 0; - defs - << (const char*) out.getData() - << "0,0};\n\nconst char* " - << code.className << "::" << name + << "0,0};\n\n" + "const char* " << code.className << "::" << name << " = (const char*) resource_" << code.className << "_" << name << ";\nconst int " << code.className << "::" << name << "Size = " @@ -340,16 +336,6 @@ void BinaryResources::fillInGeneratedCode (GeneratedCode& code) const << ";\n\n"; } - code.staticMemberDefinitions += defs; + code.staticMemberDefinitions << defs.toString(); } } - -BinaryResources::BinaryResource::BinaryResource() - : drawable (0) -{ -} - -BinaryResources::BinaryResource::~BinaryResource() -{ - deleteAndZero (drawable); -} diff --git a/extras/Introjucer/Source/ComponentEditor/jucer_BinaryResources.h b/extras/Introjucer/Source/ComponentEditor/jucer_BinaryResources.h index bf4e849b3a..ad1e659c42 100644 --- a/extras/Introjucer/Source/ComponentEditor/jucer_BinaryResources.h +++ b/extras/Introjucer/Source/ComponentEditor/jucer_BinaryResources.h @@ -47,13 +47,10 @@ public: //============================================================================== struct BinaryResource { - BinaryResource(); - ~BinaryResource(); - String name; String originalFilename; MemoryBlock data; - Drawable* drawable; + ScopedPointer drawable; }; void clear(); diff --git a/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.cpp index 9a8aee2907..e942d13f7c 100644 --- a/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.cpp @@ -615,7 +615,7 @@ void LADSPAPluginFormat::findAllTypesForFile (OwnedArray & re AudioPluginInstance* LADSPAPluginFormat::createInstanceFromDescription (const PluginDescription& desc) { - LADSPAPluginInstance* result = nullptr; + ScopedPointer result; if (fileMightContainThisPluginType (desc.fileOrIdentifier)) { @@ -635,13 +635,13 @@ AudioPluginInstance* LADSPAPluginFormat::createInstanceFromDescription (const Pl if (result->plugin != nullptr && result->isValid()) result->initialise(); else - deleteAndZero (result); + result = nullptr; } previousWorkingDirectory.setAsCurrentWorkingDirectory(); } - return result; + return result.release(); } bool LADSPAPluginFormat::fileMightContainThisPluginType (const String& fileOrIdentifier) diff --git a/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp b/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp index 9f17a6ff43..45c5ca057e 100644 --- a/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp @@ -358,14 +358,14 @@ void ResizableWindow::setBoundsConstrained (const Rectangle& newBounds) //============================================================================== void ResizableWindow::paint (Graphics& g) { - getLookAndFeel().fillResizableWindowBackground (g, getWidth(), getHeight(), - getBorderThickness(), *this); + LookAndFeel& lf = getLookAndFeel(); + + lf.fillResizableWindowBackground (g, getWidth(), getHeight(), + getBorderThickness(), *this); if (! isFullScreen()) - { - getLookAndFeel().drawResizableWindowBorder (g, getWidth(), getHeight(), - getBorderThickness(), *this); - } + lf.drawResizableWindowBorder (g, getWidth(), getHeight(), + getBorderThickness(), *this); #if JUCE_DEBUG /* If this fails, then you've probably written a subclass with a resized() @@ -464,9 +464,10 @@ void ResizableWindow::setFullScreen (const bool shouldBeFullScreen) bool ResizableWindow::isMinimised() const { - ComponentPeer* const peer = getPeer(); + if (ComponentPeer* const peer = getPeer()) + return peer->isMinimised(); - return (peer != nullptr) && peer->isMinimised(); + return false; } void ResizableWindow::setMinimised (const bool shouldMinimise)