Browse Source

Misc minor clean-ups.

tags/2021-05-28
jules 12 years ago
parent
commit
7bd867794c
4 changed files with 34 additions and 50 deletions
  1. +21
    -35
      extras/Introjucer/Source/ComponentEditor/jucer_BinaryResources.cpp
  2. +1
    -4
      extras/Introjucer/Source/ComponentEditor/jucer_BinaryResources.h
  3. +3
    -3
      modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.cpp
  4. +9
    -8
      modules/juce_gui_basics/windows/juce_ResizableWindow.cpp

+ 21
- 35
extras/Introjucer/Source/ComponentEditor/jucer_BinaryResources.cpp View File

@@ -112,7 +112,7 @@ void BinaryResources::add (const String& name, const String& originalFileName, c
{ {
BinaryResource* r = findResource (name); BinaryResource* r = findResource (name);
if (r == 0)
if (r == nullptr)
{ {
resources.add (r = new BinaryResource()); resources.add (r = new BinaryResource());
r->name = name; r->name = name;
@@ -120,7 +120,7 @@ void BinaryResources::add (const String& name, const String& originalFileName, c
r->originalFilename = originalFileName; r->originalFilename = originalFileName;
r->data = data; r->data = data;
deleteAndZero (r->drawable);
r->drawable = nullptr;
changed(); changed();
} }
@@ -187,15 +187,16 @@ void BinaryResources::remove (const int i)
const Drawable* BinaryResources::getDrawable (const String& name) const const Drawable* BinaryResources::getDrawable (const String& name) const
{ {
BinaryResources::BinaryResource* const res = const_cast <BinaryResources::BinaryResource*> (getResource (name));
if (res == 0)
return 0;
if (BinaryResources::BinaryResource* const res = const_cast <BinaryResources::BinaryResource*> (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 Image BinaryResources::getImageFromCache (const String& name) const
@@ -277,7 +278,8 @@ void BinaryResources::fillInGeneratedCode (GeneratedCode& code) const
{ {
code.publicMemberDeclarations << "// Binary resources:\n"; code.publicMemberDeclarations << "// Binary resources:\n";
String defs;
MemoryOutputStream defs;
defs << "//==============================================================================\n"; defs << "//==============================================================================\n";
defs << "// Binary resources - be careful not to edit any of these sections!\n\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_" line1 << "static const unsigned char resource_"
<< code.className << "_" << name << "[] = { "; << code.className << "_" << name << "[] = { ";
defs += line1;
defs << line1;
MemoryOutputStream out (65536);
int charsOnLine = line1.length(); int charsOnLine = line1.length();
for (size_t j = 0; j < mb.getSize(); ++j) 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; charsOnLine += 2;
if (num >= 10)
++charsOnLine;
if (num >= 100)
++charsOnLine;
if (num >= 10) ++charsOnLine;
if (num >= 100) ++charsOnLine;
if (charsOnLine >= 200) if (charsOnLine >= 200)
{ {
charsOnLine = 0; charsOnLine = 0;
out << '\n';
defs << '\n';
} }
} }
out << (char) 0;
defs 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 << " = (const char*) resource_" << code.className << "_" << name
<< ";\nconst int " << ";\nconst int "
<< code.className << "::" << name << "Size = " << code.className << "::" << name << "Size = "
@@ -340,16 +336,6 @@ void BinaryResources::fillInGeneratedCode (GeneratedCode& code) const
<< ";\n\n"; << ";\n\n";
} }
code.staticMemberDefinitions += defs;
code.staticMemberDefinitions << defs.toString();
} }
} }
BinaryResources::BinaryResource::BinaryResource()
: drawable (0)
{
}
BinaryResources::BinaryResource::~BinaryResource()
{
deleteAndZero (drawable);
}

+ 1
- 4
extras/Introjucer/Source/ComponentEditor/jucer_BinaryResources.h View File

@@ -47,13 +47,10 @@ public:
//============================================================================== //==============================================================================
struct BinaryResource struct BinaryResource
{ {
BinaryResource();
~BinaryResource();
String name; String name;
String originalFilename; String originalFilename;
MemoryBlock data; MemoryBlock data;
Drawable* drawable;
ScopedPointer<Drawable> drawable;
}; };
void clear(); void clear();


+ 3
- 3
modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.cpp View File

@@ -615,7 +615,7 @@ void LADSPAPluginFormat::findAllTypesForFile (OwnedArray <PluginDescription>& re
AudioPluginInstance* LADSPAPluginFormat::createInstanceFromDescription (const PluginDescription& desc) AudioPluginInstance* LADSPAPluginFormat::createInstanceFromDescription (const PluginDescription& desc)
{ {
LADSPAPluginInstance* result = nullptr;
ScopedPointer<LADSPAPluginInstance> result;
if (fileMightContainThisPluginType (desc.fileOrIdentifier)) if (fileMightContainThisPluginType (desc.fileOrIdentifier))
{ {
@@ -635,13 +635,13 @@ AudioPluginInstance* LADSPAPluginFormat::createInstanceFromDescription (const Pl
if (result->plugin != nullptr && result->isValid()) if (result->plugin != nullptr && result->isValid())
result->initialise(); result->initialise();
else else
deleteAndZero (result);
result = nullptr;
} }
previousWorkingDirectory.setAsCurrentWorkingDirectory(); previousWorkingDirectory.setAsCurrentWorkingDirectory();
} }
return result;
return result.release();
} }
bool LADSPAPluginFormat::fileMightContainThisPluginType (const String& fileOrIdentifier) bool LADSPAPluginFormat::fileMightContainThisPluginType (const String& fileOrIdentifier)


+ 9
- 8
modules/juce_gui_basics/windows/juce_ResizableWindow.cpp View File

@@ -358,14 +358,14 @@ void ResizableWindow::setBoundsConstrained (const Rectangle<int>& newBounds)
//============================================================================== //==============================================================================
void ResizableWindow::paint (Graphics& g) void ResizableWindow::paint (Graphics& g)
{ {
getLookAndFeel().fillResizableWindowBackground (g, getWidth(), getHeight(),
getBorderThickness(), *this);
LookAndFeel& lf = getLookAndFeel();
lf.fillResizableWindowBackground (g, getWidth(), getHeight(),
getBorderThickness(), *this);
if (! isFullScreen()) if (! isFullScreen())
{
getLookAndFeel().drawResizableWindowBorder (g, getWidth(), getHeight(),
getBorderThickness(), *this);
}
lf.drawResizableWindowBorder (g, getWidth(), getHeight(),
getBorderThickness(), *this);
#if JUCE_DEBUG #if JUCE_DEBUG
/* If this fails, then you've probably written a subclass with a resized() /* 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 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) void ResizableWindow::setMinimised (const bool shouldMinimise)


Loading…
Cancel
Save