Browse Source

Minor code clean-ups.

tags/2021-05-28
Julian Storer 15 years ago
parent
commit
23e07daec7
23 changed files with 1736 additions and 1782 deletions
  1. +3
    -4
      extras/audio plugins/wrapper/AU/juce_AU_Wrapper.mm
  2. +25
    -27
      extras/audio plugins/wrapper/RTAS/juce_RTAS_Wrapper.cpp
  3. +8
    -14
      extras/audio plugins/wrapper/Standalone/juce_StandaloneFilterWindow.cpp
  4. +3
    -3
      extras/audio plugins/wrapper/Standalone/juce_StandaloneFilterWindow.h
  5. +2
    -3
      extras/audio plugins/wrapper/VST/juce_VST_Wrapper.cpp
  6. +86
    -105
      juce_amalgamated.cpp
  7. +7
    -6
      juce_amalgamated.h
  8. +1525
    -1528
      src/audio/plugins/formats/juce_AudioUnitPluginFormat.mm
  9. +1
    -1
      src/core/juce_StandardHeader.h
  10. +34
    -37
      src/gui/components/filebrowser/juce_FileChooserDialogBox.cpp
  11. +3
    -5
      src/gui/components/filebrowser/juce_FileChooserDialogBox.h
  12. +3
    -0
      src/gui/components/juce_Component.h
  13. +2
    -3
      src/gui/components/layout/juce_MultiDocumentPanel.cpp
  14. +1
    -1
      src/gui/components/layout/juce_MultiDocumentPanel.h
  15. +3
    -4
      src/gui/components/windows/juce_ResizableWindow.cpp
  16. +2
    -2
      src/gui/graphics/drawables/juce_SVGParser.cpp
  17. +1
    -1
      src/io/network/juce_Socket.cpp
  18. +5
    -5
      src/native/common/juce_posix_NamedPipe.cpp
  19. +5
    -7
      src/native/linux/juce_linux_Midi.cpp
  20. +5
    -5
      src/native/mac/juce_mac_CoreMidi.cpp
  21. +3
    -4
      src/native/windows/juce_win32_OpenGLComponent.cpp
  22. +5
    -8
      src/native/windows/juce_win32_WASAPI.cpp
  23. +4
    -9
      src/native/windows/juce_win32_Windowing.cpp

+ 3
- 4
extras/audio plugins/wrapper/AU/juce_AU_Wrapper.mm View File

@@ -1139,13 +1139,12 @@ public:
class JuceAUView : public AUCarbonViewBase class JuceAUView : public AUCarbonViewBase
{ {
AudioProcessor* juceFilter; AudioProcessor* juceFilter;
Component* windowComp;
ScopedPointer<Component> windowComp;
public: public:
JuceAUView (AudioUnitCarbonView auview) JuceAUView (AudioUnitCarbonView auview)
: AUCarbonViewBase (auview), : AUCarbonViewBase (auview),
juceFilter (0),
windowComp (0)
juceFilter (0)
{ {
} }
@@ -1206,7 +1205,7 @@ private:
if (windowComp != 0 && windowComp->getChildComponent(0) != 0) if (windowComp != 0 && windowComp->getChildComponent(0) != 0)
juceFilter->editorBeingDeleted ((AudioProcessorEditor*) windowComp->getChildComponent(0)); juceFilter->editorBeingDeleted ((AudioProcessorEditor*) windowComp->getChildComponent(0));
deleteAndZero (windowComp);
windowComp = 0;
} }
} }


+ 25
- 27
extras/audio plugins/wrapper/RTAS/juce_RTAS_Wrapper.cpp View File

@@ -157,9 +157,7 @@ class JucePlugInProcess : public CEffectProcessMIDI,
public: public:
//============================================================================== //==============================================================================
JucePlugInProcess() JucePlugInProcess()
: midiBufferNode (0),
midiTransport (0),
prepared (false),
: prepared (false),
sampleRate (44100.0) sampleRate (44100.0)
{ {
juceFilter = createPluginFilter(); juceFilter = createPluginFilter();
@@ -175,8 +173,8 @@ public:
if (mLoggedIn) if (mLoggedIn)
MIDILogOut(); MIDILogOut();
deleteAndZero (midiBufferNode);
deleteAndZero (midiTransport);
midiBufferNode = 0;
midiTransport = 0;
if (prepared) if (prepared)
juceFilter->releaseResources(); juceFilter->releaseResources();
@@ -204,9 +202,7 @@ public:
JuceCustomUIView (AudioProcessor* const filter_, JuceCustomUIView (AudioProcessor* const filter_,
JucePlugInProcess* const process_) JucePlugInProcess* const process_)
: filter (filter_), : filter (filter_),
process (process_),
wrapper (0),
editorComp (0)
process (process_)
{ {
// setting the size in here crashes PT for some reason, so keep it simple.. // setting the size in here crashes PT for some reason, so keep it simple..
} }
@@ -262,8 +258,7 @@ public:
#else #else
void* const hostWindow = (void*) GetWindowFromPort (port); void* const hostWindow = (void*) GetWindowFromPort (port);
#endif #endif
deleteAndZero (wrapper);
wrapper = 0;
wrapper = new EditorCompWrapper (hostWindow, editorComp, this); wrapper = new EditorCompWrapper (hostWindow, editorComp, this);
process->touchAllParameters(); process->touchAllParameters();
@@ -296,8 +291,8 @@ public:
private: private:
AudioProcessor* const filter; AudioProcessor* const filter;
JucePlugInProcess* const process; JucePlugInProcess* const process;
JUCE_NAMESPACE::Component* wrapper;
AudioProcessorEditor* editorComp;
ScopedPointer<JUCE_NAMESPACE::Component> wrapper;
ScopedPointer<AudioProcessorEditor> editorComp;
void deleteEditorComp() void deleteEditorComp()
{ {
@@ -314,8 +309,8 @@ public:
filter->editorBeingDeleted (editorComp); filter->editorBeingDeleted (editorComp);
deleteAndZero (editorComp);
deleteAndZero (wrapper);
editorComp = 0;
wrapper = 0;
} }
} }
@@ -550,22 +545,25 @@ protected:
const Cmn_UInt32 bufferSize = mRTGlobals->mHWBufferSizeInSamples; const Cmn_UInt32 bufferSize = mRTGlobals->mHWBufferSizeInSamples;
if (midiBufferNode->GetAdvanceScheduleTime() != bufferSize)
midiBufferNode->SetAdvanceScheduleTime (bufferSize);
if (midiBufferNode->FillMIDIBuffer (mRTGlobals->mRunningTime, numSamples) == noErr)
if (midiBufferNode != 0)
{ {
jassert (midiBufferNode->GetBufferPtr() != 0);
const int numMidiEvents = midiBufferNode->GetBufferSize();
if (midiBufferNode->GetAdvanceScheduleTime() != bufferSize)
midiBufferNode->SetAdvanceScheduleTime (bufferSize);
for (int i = 0; i < numMidiEvents; ++i)
if (midiBufferNode->FillMIDIBuffer (mRTGlobals->mRunningTime, numSamples) == noErr)
{ {
const DirectMidiPacket& m = midiBuffer[i];
jassert (midiBufferNode->GetBufferPtr() != 0);
const int numMidiEvents = midiBufferNode->GetBufferSize();
jassert ((int) m.mTimestamp < numSamples);
for (int i = 0; i < numMidiEvents; ++i)
{
const DirectMidiPacket& m = midiBuffer[i];
midiEvents.addEvent (m.mData, m.mLength,
jlimit (0, (int) numSamples - 1, (int) m.mTimestamp));
jassert ((int) m.mTimestamp < numSamples);
midiEvents.addEvent (m.mData, m.mLength,
jlimit (0, (int) numSamples - 1, (int) m.mTimestamp));
}
} }
} }
#endif #endif
@@ -809,8 +807,8 @@ protected:
private: private:
AudioProcessor* juceFilter; AudioProcessor* juceFilter;
MidiBuffer midiEvents; MidiBuffer midiEvents;
CEffectMIDIOtherBufferedNode* midiBufferNode;
CEffectMIDITransport* midiTransport;
ScopedPointer<CEffectMIDIOtherBufferedNode> midiBufferNode;
ScopedPointer<CEffectMIDITransport> midiTransport;
DirectMidiPacket midiBuffer [midiBufferSize]; DirectMidiPacket midiBuffer [midiBufferSize];
JUCE_NAMESPACE::MemoryBlock tempFilterData; JUCE_NAMESPACE::MemoryBlock tempFilterData;


+ 8
- 14
extras/audio plugins/wrapper/Standalone/juce_StandaloneFilterWindow.cpp View File

@@ -39,16 +39,13 @@ StandaloneFilterWindow::StandaloneFilterWindow (const String& title,
: DocumentWindow (title, backgroundColour, : DocumentWindow (title, backgroundColour,
DocumentWindow::minimiseButton DocumentWindow::minimiseButton
| DocumentWindow::closeButton), | DocumentWindow::closeButton),
filter (0),
deviceManager (0),
optionsButton (0)
optionsButton ("options")
{ {
setTitleBarButtonsRequired (DocumentWindow::minimiseButton | DocumentWindow::closeButton, false); setTitleBarButtonsRequired (DocumentWindow::minimiseButton | DocumentWindow::closeButton, false);
optionsButton = new TextButton ("options");
Component::addAndMakeVisible (optionsButton);
optionsButton->addButtonListener (this);
optionsButton->setTriggeredOnMouseDown (true);
Component::addAndMakeVisible (&optionsButton);
optionsButton.addButtonListener (this);
optionsButton.setTriggeredOnMouseDown (true);
JUCE_TRY JUCE_TRY
{ {
@@ -115,8 +112,6 @@ StandaloneFilterWindow::~StandaloneFilterWindow()
globalSettings->setValue ("windowX", getX()); globalSettings->setValue ("windowX", getX());
globalSettings->setValue ("windowY", getY()); globalSettings->setValue ("windowY", getY());
deleteAndZero (optionsButton);
if (globalSettings != 0 && deviceManager != 0) if (globalSettings != 0 && deviceManager != 0)
{ {
XmlElement* const xml = deviceManager->createStateXml(); XmlElement* const xml = deviceManager->createStateXml();
@@ -124,7 +119,7 @@ StandaloneFilterWindow::~StandaloneFilterWindow()
delete xml; delete xml;
} }
deleteAndZero (deviceManager);
deviceManager = 0;
if (globalSettings != 0 && filter != 0) if (globalSettings != 0 && filter != 0)
{ {
@@ -149,7 +144,7 @@ void StandaloneFilterWindow::deleteFilter()
setContentComponent (0, true); setContentComponent (0, true);
} }
deleteAndZero (filter);
filter = 0;
} }
void StandaloneFilterWindow::resetFilter() void StandaloneFilterWindow::resetFilter()
@@ -258,8 +253,7 @@ void StandaloneFilterWindow::resized()
{ {
DocumentWindow::resized(); DocumentWindow::resized();
if (optionsButton != 0)
optionsButton->setBounds (8, 6, 60, getTitleBarHeight() - 8);
optionsButton.setBounds (8, 6, 60, getTitleBarHeight() - 8);
} }
void StandaloneFilterWindow::buttonClicked (Button*) void StandaloneFilterWindow::buttonClicked (Button*)
@@ -275,7 +269,7 @@ void StandaloneFilterWindow::buttonClicked (Button*)
m.addSeparator(); m.addSeparator();
m.addItem (4, TRANS("Reset to default state")); m.addItem (4, TRANS("Reset to default state"));
switch (m.showAt (optionsButton))
switch (m.showAt (&optionsButton))
{ {
case 1: case 1:
showAudioSettingsDialog(); showAudioSettingsDialog();


+ 3
- 3
extras/audio plugins/wrapper/Standalone/juce_StandaloneFilterWindow.h View File

@@ -77,9 +77,9 @@ public:
juce_UseDebuggingNewOperator juce_UseDebuggingNewOperator
private: private:
AudioProcessor* filter;
AudioFilterStreamingDeviceManager* deviceManager;
Button* optionsButton;
ScopedPointer<AudioProcessor> filter;
ScopedPointer<AudioFilterStreamingDeviceManager> deviceManager;
TextButton optionsButton;
void deleteFilter(); void deleteFilter();


+ 2
- 3
extras/audio plugins/wrapper/VST/juce_VST_Wrapper.cpp View File

@@ -275,7 +275,6 @@ public:
filter_->getNumParameters()), filter_->getNumParameters()),
filter (filter_) filter (filter_)
{ {
editorComp = 0;
chunkMemoryTime = 0; chunkMemoryTime = 0;
isProcessing = false; isProcessing = false;
hasShutdown = false; hasShutdown = false;
@@ -1128,7 +1127,7 @@ public:
filter->editorBeingDeleted (editorComp->getEditorComp()); filter->editorBeingDeleted (editorComp->getEditorComp());
deleteAndZero (editorComp);
editorComp = 0;
// there's some kind of component currently modal, but the host // there's some kind of component currently modal, but the host
// is trying to delete our plugin. You should try to avoid this happening.. // is trying to delete our plugin. You should try to avoid this happening..
@@ -1420,7 +1419,7 @@ private:
AudioProcessor* filter; AudioProcessor* filter;
JUCE_NAMESPACE::MemoryBlock chunkMemory; JUCE_NAMESPACE::MemoryBlock chunkMemory;
JUCE_NAMESPACE::uint32 chunkMemoryTime; JUCE_NAMESPACE::uint32 chunkMemoryTime;
EditorCompWrapper* editorComp;
ScopedPointer<EditorCompWrapper> editorComp;
ERect editorSize; ERect editorSize;
MidiBuffer midiEvents; MidiBuffer midiEvents;
VSTMidiEventList outgoingEvents; VSTMidiEventList outgoingEvents;


+ 86
- 105
juce_amalgamated.cpp View File

@@ -7938,7 +7938,7 @@ DatagramSocket::~DatagramSocket()
{ {
close(); close();


delete ((struct sockaddr_in*) serverAddress);
delete static_cast <struct sockaddr_in*> (serverAddress);
serverAddress = 0; serverAddress = 0;
} }


@@ -30774,10 +30774,9 @@ class AudioUnitPluginWindowCocoa : public AudioProcessorEditor
public: public:
AudioUnitPluginWindowCocoa (AudioUnitPluginInstance& plugin_, const bool createGenericViewIfNeeded) AudioUnitPluginWindowCocoa (AudioUnitPluginInstance& plugin_, const bool createGenericViewIfNeeded)
: AudioProcessorEditor (&plugin_), : AudioProcessorEditor (&plugin_),
plugin (plugin_),
wrapper (0)
plugin (plugin_)
{ {
addAndMakeVisible (wrapper = new NSViewComponent());
addAndMakeVisible (&wrapper);


setOpaque (true); setOpaque (true);
setVisible (true); setVisible (true);
@@ -30790,15 +30789,13 @@ public:
{ {
const bool wasValid = isValid(); const bool wasValid = isValid();


wrapper->setView (0);
wrapper.setView (0);


if (wasValid) if (wasValid)
plugin.editorBeingDeleted (this); plugin.editorBeingDeleted (this);

delete wrapper;
} }


bool isValid() const { return wrapper->getView() != 0; }
bool isValid() const { return wrapper.getView() != 0; }


void paint (Graphics& g) void paint (Graphics& g)
{ {
@@ -30807,12 +30804,12 @@ public:


void resized() void resized()
{ {
wrapper->setSize (getWidth(), getHeight());
wrapper.setSize (getWidth(), getHeight());
} }


private: private:
AudioUnitPluginInstance& plugin; AudioUnitPluginInstance& plugin;
NSViewComponent* wrapper;
NSViewComponent wrapper;


bool createView (const bool createGenericViewIfNeeded) bool createView (const bool createGenericViewIfNeeded)
{ {
@@ -30858,7 +30855,7 @@ private:
if (createGenericViewIfNeeded && (pluginView == 0)) if (createGenericViewIfNeeded && (pluginView == 0))
pluginView = [[AUGenericView alloc] initWithAudioUnit: plugin.audioUnit]; pluginView = [[AUGenericView alloc] initWithAudioUnit: plugin.audioUnit];


wrapper->setView (pluginView);
wrapper.setView (pluginView);


if (pluginView != 0) if (pluginView != 0)
setSize ([pluginView frame].size.width, setSize ([pluginView frame].size.width,
@@ -57806,35 +57803,19 @@ FileChooserDialogBox::FileChooserDialogBox (const String& name,
: ResizableWindow (name, backgroundColour, true), : ResizableWindow (name, backgroundColour, true),
warnAboutOverwritingExistingFiles (warnAboutOverwritingExistingFiles_) warnAboutOverwritingExistingFiles (warnAboutOverwritingExistingFiles_)
{ {
content = new ContentComponent();
content->setName (name);
content->instructions = instructions;
content->chooserComponent = &chooserComponent;

content->addAndMakeVisible (&chooserComponent);

content->okButton = new TextButton (chooserComponent.getActionVerb());
content->addAndMakeVisible (content->okButton);
content->okButton->addButtonListener (this);
content->okButton->setEnabled (chooserComponent.currentFileIsValid());
content->okButton->addShortcut (KeyPress (KeyPress::returnKey, 0, 0));

content->cancelButton = new TextButton (TRANS("Cancel"));
content->addAndMakeVisible (content->cancelButton);
content->cancelButton->addButtonListener (this);
content->cancelButton->addShortcut (KeyPress (KeyPress::escapeKey, 0, 0));

setContentComponent (content);
setContentComponent (content = new ContentComponent (name, instructions, chooserComponent));


setResizable (true, true); setResizable (true, true);
setResizeLimits (300, 300, 1200, 1000); setResizeLimits (300, 300, 1200, 1000);


content->chooserComponent->addListener (this);
content->okButton.addButtonListener (this);
content->cancelButton.addButtonListener (this);
content->chooserComponent.addListener (this);
} }


FileChooserDialogBox::~FileChooserDialogBox() FileChooserDialogBox::~FileChooserDialogBox()
{ {
content->chooserComponent->removeListener (this);
content->chooserComponent.removeListener (this);
} }


bool FileChooserDialogBox::show (int w, int h) bool FileChooserDialogBox::show (int w, int h)
@@ -57846,7 +57827,7 @@ bool FileChooserDialogBox::showAt (int x, int y, int w, int h)
{ {
if (w <= 0) if (w <= 0)
{ {
Component* const previewComp = content->chooserComponent->getPreviewComponent();
Component* const previewComp = content->chooserComponent.getPreviewComponent();
if (previewComp != 0) if (previewComp != 0)
w = 400 + previewComp->getWidth(); w = 400 + previewComp->getWidth();
else else
@@ -57868,16 +57849,16 @@ bool FileChooserDialogBox::showAt (int x, int y, int w, int h)


void FileChooserDialogBox::buttonClicked (Button* button) void FileChooserDialogBox::buttonClicked (Button* button)
{ {
if (button == content->okButton)
if (button == &(content->okButton))
{ {
if (warnAboutOverwritingExistingFiles if (warnAboutOverwritingExistingFiles
&& content->chooserComponent->isSaveMode()
&& content->chooserComponent->getSelectedFile(0).exists())
&& content->chooserComponent.isSaveMode()
&& content->chooserComponent.getSelectedFile(0).exists())
{ {
if (! AlertWindow::showOkCancelBox (AlertWindow::WarningIcon, if (! AlertWindow::showOkCancelBox (AlertWindow::WarningIcon,
TRANS("File already exists"), TRANS("File already exists"),
TRANS("There's already a file called:") TRANS("There's already a file called:")
+ "\n\n" + content->chooserComponent->getSelectedFile(0).getFullPathName()
+ "\n\n" + content->chooserComponent.getSelectedFile(0).getFullPathName()
+ "\n\n" + TRANS("Are you sure you want to overwrite it?"), + "\n\n" + TRANS("Are you sure you want to overwrite it?"),
TRANS("overwrite"), TRANS("overwrite"),
TRANS("cancel"))) TRANS("cancel")))
@@ -57888,8 +57869,10 @@ void FileChooserDialogBox::buttonClicked (Button* button)


exitModalState (1); exitModalState (1);
} }
else if (button == content->cancelButton)
else if (button == &(content->cancelButton))
{
closeButtonPressed(); closeButtonPressed();
}
} }


void FileChooserDialogBox::closeButtonPressed() void FileChooserDialogBox::closeButtonPressed()
@@ -57899,7 +57882,7 @@ void FileChooserDialogBox::closeButtonPressed()


void FileChooserDialogBox::selectionChanged() void FileChooserDialogBox::selectionChanged()
{ {
content->okButton->setEnabled (content->chooserComponent->currentFileIsValid());
content->okButton.setEnabled (content->chooserComponent.currentFileIsValid());
} }


void FileChooserDialogBox::fileClicked (const File&, const MouseEvent&) void FileChooserDialogBox::fileClicked (const File&, const MouseEvent&)
@@ -57909,18 +57892,29 @@ void FileChooserDialogBox::fileClicked (const File&, const MouseEvent&)
void FileChooserDialogBox::fileDoubleClicked (const File&) void FileChooserDialogBox::fileDoubleClicked (const File&)
{ {
selectionChanged(); selectionChanged();
content->okButton->triggerClick();
content->okButton.triggerClick();
} }


FileChooserDialogBox::ContentComponent::ContentComponent()
FileChooserDialogBox::ContentComponent::ContentComponent (const String& name, const String& instructions_, FileBrowserComponent& chooserComponent_)
: Component (name), instructions (instructions_),
chooserComponent (chooserComponent_),
okButton (chooserComponent_.getActionVerb()),
cancelButton (TRANS ("Cancel"))
{ {
addAndMakeVisible (&chooserComponent);

addAndMakeVisible (&okButton);
okButton.setEnabled (chooserComponent.currentFileIsValid());
okButton.addShortcut (KeyPress (KeyPress::returnKey, 0, 0));

addAndMakeVisible (&cancelButton);
cancelButton.addShortcut (KeyPress (KeyPress::escapeKey, 0, 0));

setInterceptsMouseClicks (false, true); setInterceptsMouseClicks (false, true);
} }


FileChooserDialogBox::ContentComponent::~ContentComponent() FileChooserDialogBox::ContentComponent::~ContentComponent()
{ {
delete okButton;
delete cancelButton;
} }


void FileChooserDialogBox::ContentComponent::paint (Graphics& g) void FileChooserDialogBox::ContentComponent::paint (Graphics& g)
@@ -57939,13 +57933,13 @@ void FileChooserDialogBox::ContentComponent::resized()
const int buttonHeight = 26; const int buttonHeight = 26;
const int buttonY = getHeight() - buttonHeight - 8; const int buttonY = getHeight() - buttonHeight - 8;


chooserComponent->setBounds (0, y, getWidth(), buttonY - y - 20);
chooserComponent.setBounds (0, y, getWidth(), buttonY - y - 20);


okButton->setBounds (proportionOfWidth (0.25f), buttonY,
proportionOfWidth (0.2f), buttonHeight);
okButton.setBounds (proportionOfWidth (0.25f), buttonY,
proportionOfWidth (0.2f), buttonHeight);


cancelButton->setBounds (proportionOfWidth (0.55f), buttonY,
proportionOfWidth (0.2f), buttonHeight);
cancelButton.setBounds (proportionOfWidth (0.55f), buttonY,
proportionOfWidth (0.2f), buttonHeight);
} }


END_JUCE_NAMESPACE END_JUCE_NAMESPACE
@@ -61133,7 +61127,6 @@ public:


MultiDocumentPanel::MultiDocumentPanel() MultiDocumentPanel::MultiDocumentPanel()
: mode (MaximisedWindowsWithTabs), : mode (MaximisedWindowsWithTabs),
tabComponent (0),
backgroundColour (Colours::lightblue), backgroundColour (Colours::lightblue),
maximumNumDocuments (0), maximumNumDocuments (0),
numDocsBeforeTabsUsed (0) numDocsBeforeTabsUsed (0)
@@ -61326,7 +61319,7 @@ bool MultiDocumentPanel::closeDocument (Component* component,
delete component; delete component;


if (tabComponent != 0 && tabComponent->getNumTabs() <= numDocsBeforeTabsUsed) if (tabComponent != 0 && tabComponent->getNumTabs() <= numDocsBeforeTabsUsed)
deleteAndZero (tabComponent);
tabComponent = 0;


components.removeValue (component); components.removeValue (component);


@@ -61426,7 +61419,7 @@ void MultiDocumentPanel::setLayoutMode (const LayoutMode newLayoutMode)


if (mode == FloatingWindows) if (mode == FloatingWindows)
{ {
deleteAndZero (tabComponent);
tabComponent = 0;
} }
else else
{ {
@@ -77667,8 +77660,7 @@ ResizableWindow::~ResizableWindow()
{ {
resizableCorner = 0; resizableCorner = 0;
resizableBorder = 0; resizableBorder = 0;
delete static_cast <Component*> (contentComponent);
contentComponent = 0;
contentComponent.deleteAndZero();


// have you been adding your own components directly to this window..? tut tut tut. // have you been adding your own components directly to this window..? tut tut tut.
// Read the instructions for using a ResizableWindow! // Read the instructions for using a ResizableWindow!
@@ -77694,8 +77686,8 @@ void ResizableWindow::setContentComponent (Component* const newContentComponent,
if (newContentComponent != static_cast <Component*> (contentComponent)) if (newContentComponent != static_cast <Component*> (contentComponent))
{ {
if (deleteOldOne) if (deleteOldOne)
delete static_cast <Component*> (contentComponent); // (avoid using a scoped pointer for this, so that it survives
// external deletion of the content comp)
contentComponent.deleteAndZero(); // (avoid using a scoped pointer for this, so that it survives
// external deletion of the content comp)
else else
removeChildComponent (contentComponent); removeChildComponent (contentComponent);


@@ -87984,12 +87976,12 @@ private:


Path path; Path path;
Drawable* s = parseShape (*e, path); Drawable* s = parseShape (*e, path);
delete s;
delete s; // xxx not finished!
} }
else if (e->hasTagName ("tspan")) else if (e->hasTagName ("tspan"))
{ {
Drawable* s = parseText (*e); Drawable* s = parseText (*e);
delete s;
delete s; // xxx not finished!
} }
} }


@@ -239638,7 +239630,6 @@ public:
isMouseOver (false), isMouseOver (false),
hasCreatedCaret (false), hasCreatedCaret (false),
currentWindowIcon (0), currentWindowIcon (0),
taskBarIcon (0),
dropTarget (0) dropTarget (0)
{ {
callFunctionIfNotLocked (&createWindowCallback, this); callFunctionIfNotLocked (&createWindowCallback, this);
@@ -239653,16 +239644,12 @@ public:
if (shadower != 0) if (shadower != 0)
shadower->setOwner (component); shadower->setOwner (component);
} }
else
{
shadower = 0;
}
} }


~Win32ComponentPeer() ~Win32ComponentPeer()
{ {
setTaskBarIcon (Image()); setTaskBarIcon (Image());
deleteAndZero (shadower);
shadower = 0;


// do this before the next bit to avoid messages arriving for this window // do this before the next bit to avoid messages arriving for this window
// before it's destroyed // before it's destroyed
@@ -240022,7 +240009,7 @@ public:
taskBarIcon->uFlags = 0; taskBarIcon->uFlags = 0;
Shell_NotifyIcon (NIM_DELETE, taskBarIcon); Shell_NotifyIcon (NIM_DELETE, taskBarIcon);
DestroyIcon (taskBarIcon->hIcon); DestroyIcon (taskBarIcon->hIcon);
deleteAndZero (taskBarIcon);
taskBarIcon = 0;
} }
} }


@@ -240087,11 +240074,11 @@ public:


private: private:
HWND hwnd; HWND hwnd;
DropShadower* shadower;
ScopedPointer<DropShadower> shadower;
bool fullScreen, isDragging, isMouseOver, hasCreatedCaret; bool fullScreen, isDragging, isMouseOver, hasCreatedCaret;
BorderSize windowBorder; BorderSize windowBorder;
HICON currentWindowIcon; HICON currentWindowIcon;
NOTIFYICONDATA* taskBarIcon;
ScopedPointer<NOTIFYICONDATA> taskBarIcon;
IDropTarget* dropTarget; IDropTarget* dropTarget;


class TemporaryImage : public Timer class TemporaryImage : public Timer
@@ -244011,7 +243998,6 @@ public:
HGLRC contextToShareWith, HGLRC contextToShareWith,
const OpenGLPixelFormat& pixelFormat) const OpenGLPixelFormat& pixelFormat)
: renderContext (0), : renderContext (0),
nativeWindow (0),
dc (0), dc (0),
component (component_) component (component_)
{ {
@@ -244047,7 +244033,7 @@ public:
{ {
deleteContext(); deleteContext();
ReleaseDC ((HWND) nativeWindow->getNativeHandle(), dc); ReleaseDC ((HWND) nativeWindow->getNativeHandle(), dc);
delete nativeWindow;
nativeWindow = 0;
} }


void deleteContext() void deleteContext()
@@ -244200,7 +244186,7 @@ public:
// old one and create a new one.. // old one and create a new one..
jassert (nativeWindow != 0); jassert (nativeWindow != 0);
ReleaseDC ((HWND) nativeWindow->getNativeHandle(), dc); ReleaseDC ((HWND) nativeWindow->getNativeHandle(), dc);
delete nativeWindow;
nativeWindow = 0;


createNativeWindow(); createNativeWindow();


@@ -244314,7 +244300,7 @@ public:
HGLRC renderContext; HGLRC renderContext;


private: private:
Win32ComponentPeer* nativeWindow;
ScopedPointer<Win32ComponentPeer> nativeWindow;
Component* const component; Component* const component;
HDC dc; HDC dc;


@@ -251418,9 +251404,7 @@ public:
Thread ("Juce WASAPI"), Thread ("Juce WASAPI"),
isOpen_ (false), isOpen_ (false),
isStarted (false), isStarted (false),
outputDevice (0),
outputDeviceId (outputDeviceId_), outputDeviceId (outputDeviceId_),
inputDevice (0),
inputDeviceId (inputDeviceId_), inputDeviceId (inputDeviceId_),
useExclusiveMode (useExclusiveMode_), useExclusiveMode (useExclusiveMode_),
currentBufferSizeSamples (0), currentBufferSizeSamples (0),
@@ -251432,9 +251416,6 @@ public:
~WASAPIAudioIODevice() ~WASAPIAudioIODevice()
{ {
close(); close();

deleteAndZero (inputDevice);
deleteAndZero (outputDevice);
} }


bool initialise() bool initialise()
@@ -251458,7 +251439,8 @@ public:
} }
else else
{ {
WASAPIDeviceBase* const d = inputDevice != 0 ? (WASAPIDeviceBase*) inputDevice : (WASAPIDeviceBase*) outputDevice;
WASAPIDeviceBase* d = inputDevice != 0 ? static_cast<WASAPIDeviceBase*> (inputDevice)
: static_cast<WASAPIDeviceBase*> (outputDevice);
defaultSampleRate = d->defaultSampleRate; defaultSampleRate = d->defaultSampleRate;
minBufferSize = d->minBufferSize; minBufferSize = d->minBufferSize;
defaultBufferSize = d->defaultBufferSize; defaultBufferSize = d->defaultBufferSize;
@@ -251551,6 +251533,7 @@ public:


if (inputDevice != 0) if (inputDevice != 0)
ResetEvent (inputDevice->clientEvent); ResetEvent (inputDevice->clientEvent);

if (outputDevice != 0) if (outputDevice != 0)
ResetEvent (outputDevice->clientEvent); ResetEvent (outputDevice->clientEvent);


@@ -251722,8 +251705,8 @@ public:


private: private:
// Device stats... // Device stats...
WASAPIInputDevice* inputDevice;
WASAPIOutputDevice* outputDevice;
ScopedPointer<WASAPIInputDevice> inputDevice;
ScopedPointer<WASAPIOutputDevice> outputDevice;
const bool useExclusiveMode; const bool useExclusiveMode;
double defaultSampleRate; double defaultSampleRate;
int minBufferSize, defaultBufferSize; int minBufferSize, defaultBufferSize;
@@ -253747,9 +253730,9 @@ struct NamedPipeInternal


void NamedPipe::cancelPendingReads() void NamedPipe::cancelPendingReads()
{ {
while (internal != 0 && ((NamedPipeInternal*) internal)->blocked)
while (internal != 0 && static_cast <NamedPipeInternal*> (internal)->blocked)
{ {
NamedPipeInternal* const intern = (NamedPipeInternal*) internal;
NamedPipeInternal* const intern = static_cast <NamedPipeInternal*> (internal);


intern->stopReadOperation = true; intern->stopReadOperation = true;


@@ -253767,7 +253750,7 @@ void NamedPipe::cancelPendingReads()


void NamedPipe::close() void NamedPipe::close()
{ {
NamedPipeInternal* const intern = (NamedPipeInternal*) internal;
NamedPipeInternal* const intern = static_cast <NamedPipeInternal*> (internal);


if (intern != 0) if (intern != 0)
{ {
@@ -253827,7 +253810,7 @@ bool NamedPipe::openInternal (const String& pipeName, const bool createPipe)
int NamedPipe::read (void* destBuffer, int maxBytesToRead, int /*timeOutMilliseconds*/) int NamedPipe::read (void* destBuffer, int maxBytesToRead, int /*timeOutMilliseconds*/)
{ {
int bytesRead = -1; int bytesRead = -1;
NamedPipeInternal* const intern = (NamedPipeInternal*) internal;
NamedPipeInternal* const intern = static_cast <NamedPipeInternal*> (internal);


if (intern != 0) if (intern != 0)
{ {
@@ -253875,7 +253858,7 @@ int NamedPipe::read (void* destBuffer, int maxBytesToRead, int /*timeOutMillisec
int NamedPipe::write (const void* sourceBuffer, int numBytesToWrite, int timeOutMilliseconds) int NamedPipe::write (const void* sourceBuffer, int numBytesToWrite, int timeOutMilliseconds)
{ {
int bytesWritten = -1; int bytesWritten = -1;
NamedPipeInternal* const intern = (NamedPipeInternal*) internal;
NamedPipeInternal* const intern = static_cast <NamedPipeInternal*> (internal);


if (intern != 0) if (intern != 0)
{ {
@@ -261104,8 +261087,7 @@ MidiOutput* MidiOutput::createNewDevice (const String& deviceName)


MidiOutput::~MidiOutput() MidiOutput::~MidiOutput()
{ {
MidiOutputDevice* const device = (MidiOutputDevice*) internal;
delete device;
delete static_cast <MidiOutputDevice*> (internal);
} }


void MidiOutput::reset() void MidiOutput::reset()
@@ -261123,7 +261105,7 @@ void MidiOutput::setVolume (float leftVol, float rightVol)


void MidiOutput::sendMessageNow (const MidiMessage& message) void MidiOutput::sendMessageNow (const MidiMessage& message)
{ {
((MidiOutputDevice*) internal)->sendMessageNow (message);
static_cast <MidiOutputDevice*> (internal)->sendMessageNow (message);
} }


class MidiInputThread : public Thread class MidiInputThread : public Thread
@@ -261215,18 +261197,17 @@ MidiInput::MidiInput (const String& name_)
MidiInput::~MidiInput() MidiInput::~MidiInput()
{ {
stop(); stop();
MidiInputThread* const thread = (MidiInputThread*) internal;
delete thread;
delete static_cast <MidiInputThread*> (internal);
} }


void MidiInput::start() void MidiInput::start()
{ {
((MidiInputThread*) internal)->startThread();
static_cast <MidiInputThread*> (internal)->startThread();
} }


void MidiInput::stop() void MidiInput::stop()
{ {
((MidiInputThread*) internal)->stopThread (3000);
static_cast <MidiInputThread*> (internal)->stopThread (3000);
} }


int MidiInput::getDefaultDeviceIndex() int MidiInput::getDefaultDeviceIndex()
@@ -262399,9 +262380,9 @@ struct NamedPipeInternal


void NamedPipe::cancelPendingReads() void NamedPipe::cancelPendingReads()
{ {
while (internal != 0 && ((NamedPipeInternal*) internal)->blocked)
while (internal != 0 && static_cast <NamedPipeInternal*> (internal)->blocked)
{ {
NamedPipeInternal* const intern = (NamedPipeInternal*) internal;
NamedPipeInternal* const intern = static_cast <NamedPipeInternal*> (internal);


intern->stopReadOperation = true; intern->stopReadOperation = true;


@@ -262419,7 +262400,7 @@ void NamedPipe::cancelPendingReads()


void NamedPipe::close() void NamedPipe::close()
{ {
NamedPipeInternal* const intern = (NamedPipeInternal*) internal;
NamedPipeInternal* const intern = static_cast <NamedPipeInternal*> (internal);


if (intern != 0) if (intern != 0)
{ {
@@ -262479,7 +262460,7 @@ bool NamedPipe::openInternal (const String& pipeName, const bool createPipe)
int NamedPipe::read (void* destBuffer, int maxBytesToRead, int /*timeOutMilliseconds*/) int NamedPipe::read (void* destBuffer, int maxBytesToRead, int /*timeOutMilliseconds*/)
{ {
int bytesRead = -1; int bytesRead = -1;
NamedPipeInternal* const intern = (NamedPipeInternal*) internal;
NamedPipeInternal* const intern = static_cast <NamedPipeInternal*> (internal);


if (intern != 0) if (intern != 0)
{ {
@@ -262527,7 +262508,7 @@ int NamedPipe::read (void* destBuffer, int maxBytesToRead, int /*timeOutMillisec
int NamedPipe::write (const void* sourceBuffer, int numBytesToWrite, int timeOutMilliseconds) int NamedPipe::write (const void* sourceBuffer, int numBytesToWrite, int timeOutMilliseconds)
{ {
int bytesWritten = -1; int bytesWritten = -1;
NamedPipeInternal* const intern = (NamedPipeInternal*) internal;
NamedPipeInternal* const intern = static_cast <NamedPipeInternal*> (internal);


if (intern != 0) if (intern != 0)
{ {
@@ -268369,7 +268350,7 @@ MidiOutput* MidiOutput::createNewDevice (const String& deviceName)


MidiOutput::~MidiOutput() MidiOutput::~MidiOutput()
{ {
delete (MidiPortAndEndpoint*) internal;
delete static_cast<MidiPortAndEndpoint*> (internal);
} }


void MidiOutput::reset() void MidiOutput::reset()
@@ -268387,7 +268368,7 @@ void MidiOutput::setVolume (float /*leftVol*/, float /*rightVol*/)


void MidiOutput::sendMessageNow (const MidiMessage& message) void MidiOutput::sendMessageNow (const MidiMessage& message)
{ {
MidiPortAndEndpoint* const mpe = (MidiPortAndEndpoint*) internal;
MidiPortAndEndpoint* const mpe = static_cast<MidiPortAndEndpoint*> (internal);


if (message.isSysEx()) if (message.isSysEx())
{ {
@@ -268678,7 +268659,7 @@ MidiInput::MidiInput (const String& name_)


MidiInput::~MidiInput() MidiInput::~MidiInput()
{ {
MidiPortAndCallback* const mpc = (MidiPortAndCallback*) internal;
MidiPortAndCallback* const mpc = static_cast<MidiPortAndCallback*> (internal);
mpc->active = false; mpc->active = false;


{ {
@@ -268696,13 +268677,13 @@ MidiInput::~MidiInput()
void MidiInput::start() void MidiInput::start()
{ {
const ScopedLock sl (CoreMidiCallbacks::callbackLock); const ScopedLock sl (CoreMidiCallbacks::callbackLock);
((MidiPortAndCallback*) internal)->active = true;
static_cast<MidiPortAndCallback*> (internal)->active = true;
} }


void MidiInput::stop() void MidiInput::stop()
{ {
const ScopedLock sl (CoreMidiCallbacks::callbackLock); const ScopedLock sl (CoreMidiCallbacks::callbackLock);
((MidiPortAndCallback*) internal)->active = false;
static_cast<MidiPortAndCallback*> (internal)->active = false;
} }


#undef log #undef log
@@ -276825,7 +276806,7 @@ MidiOutput* MidiOutput::createNewDevice (const String& deviceName)


MidiOutput::~MidiOutput() MidiOutput::~MidiOutput()
{ {
delete (MidiPortAndEndpoint*) internal;
delete static_cast<MidiPortAndEndpoint*> (internal);
} }


void MidiOutput::reset() void MidiOutput::reset()
@@ -276843,7 +276824,7 @@ void MidiOutput::setVolume (float /*leftVol*/, float /*rightVol*/)


void MidiOutput::sendMessageNow (const MidiMessage& message) void MidiOutput::sendMessageNow (const MidiMessage& message)
{ {
MidiPortAndEndpoint* const mpe = (MidiPortAndEndpoint*) internal;
MidiPortAndEndpoint* const mpe = static_cast<MidiPortAndEndpoint*> (internal);


if (message.isSysEx()) if (message.isSysEx())
{ {
@@ -277134,7 +277115,7 @@ MidiInput::MidiInput (const String& name_)


MidiInput::~MidiInput() MidiInput::~MidiInput()
{ {
MidiPortAndCallback* const mpc = (MidiPortAndCallback*) internal;
MidiPortAndCallback* const mpc = static_cast<MidiPortAndCallback*> (internal);
mpc->active = false; mpc->active = false;


{ {
@@ -277152,13 +277133,13 @@ MidiInput::~MidiInput()
void MidiInput::start() void MidiInput::start()
{ {
const ScopedLock sl (CoreMidiCallbacks::callbackLock); const ScopedLock sl (CoreMidiCallbacks::callbackLock);
((MidiPortAndCallback*) internal)->active = true;
static_cast<MidiPortAndCallback*> (internal)->active = true;
} }


void MidiInput::stop() void MidiInput::stop()
{ {
const ScopedLock sl (CoreMidiCallbacks::callbackLock); const ScopedLock sl (CoreMidiCallbacks::callbackLock);
((MidiPortAndCallback*) internal)->active = false;
static_cast<MidiPortAndCallback*> (internal)->active = false;
} }


#undef log #undef log


+ 7
- 6
juce_amalgamated.h View File

@@ -27298,6 +27298,9 @@ public:
/** Returns the component that this pointer refers to, or null if the component no longer exists. */ /** Returns the component that this pointer refers to, or null if the component no longer exists. */
const ComponentType* operator->() const throw() { jassert (comp != 0); return comp; } const ComponentType* operator->() const throw() { jassert (comp != 0); return comp; }


/** If the component is valid, this deletes it and sets this pointer to null. */
void deleteAndZero() { delete comp; jassert (comp == 0); }

juce_UseDebuggingNewOperator juce_UseDebuggingNewOperator


private: private:
@@ -50521,7 +50524,7 @@ private:
class ContentComponent : public Component class ContentComponent : public Component
{ {
public: public:
ContentComponent();
ContentComponent (const String& name, const String& instructions, FileBrowserComponent& chooserComponent);
~ContentComponent(); ~ContentComponent();


void paint (Graphics& g); void paint (Graphics& g);
@@ -50530,10 +50533,8 @@ private:
String instructions; String instructions;
GlyphArrangement text; GlyphArrangement text;


FileBrowserComponent* chooserComponent;
FilePreviewComponent* previewComponent;
TextButton* okButton;
TextButton* cancelButton;
FileBrowserComponent& chooserComponent;
TextButton okButton, cancelButton;
}; };


ContentComponent* content; ContentComponent* content;
@@ -52830,7 +52831,7 @@ public:
private: private:
LayoutMode mode; LayoutMode mode;
Array <Component*> components; Array <Component*> components;
TabbedComponent* tabComponent;
ScopedPointer<TabbedComponent> tabComponent;
Colour backgroundColour; Colour backgroundColour;
int maximumNumDocuments, numDocsBeforeTabsUsed; int maximumNumDocuments, numDocsBeforeTabsUsed;




+ 1525
- 1528
src/audio/plugins/formats/juce_AudioUnitPluginFormat.mm
File diff suppressed because it is too large
View File


+ 1
- 1
src/core/juce_StandardHeader.h View File

@@ -33,7 +33,7 @@
*/ */
#define JUCE_MAJOR_VERSION 1 #define JUCE_MAJOR_VERSION 1
#define JUCE_MINOR_VERSION 52 #define JUCE_MINOR_VERSION 52
#define JUCE_BUILDNUMBER 48
#define JUCE_BUILDNUMBER 49
/** Current Juce version number. /** Current Juce version number.


+ 34
- 37
src/gui/components/filebrowser/juce_FileChooserDialogBox.cpp View File

@@ -42,35 +42,19 @@ FileChooserDialogBox::FileChooserDialogBox (const String& name,
: ResizableWindow (name, backgroundColour, true), : ResizableWindow (name, backgroundColour, true),
warnAboutOverwritingExistingFiles (warnAboutOverwritingExistingFiles_) warnAboutOverwritingExistingFiles (warnAboutOverwritingExistingFiles_)
{ {
content = new ContentComponent();
content->setName (name);
content->instructions = instructions;
content->chooserComponent = &chooserComponent;
content->addAndMakeVisible (&chooserComponent);
content->okButton = new TextButton (chooserComponent.getActionVerb());
content->addAndMakeVisible (content->okButton);
content->okButton->addButtonListener (this);
content->okButton->setEnabled (chooserComponent.currentFileIsValid());
content->okButton->addShortcut (KeyPress (KeyPress::returnKey, 0, 0));
content->cancelButton = new TextButton (TRANS("Cancel"));
content->addAndMakeVisible (content->cancelButton);
content->cancelButton->addButtonListener (this);
content->cancelButton->addShortcut (KeyPress (KeyPress::escapeKey, 0, 0));
setContentComponent (content);
setContentComponent (content = new ContentComponent (name, instructions, chooserComponent));
setResizable (true, true); setResizable (true, true);
setResizeLimits (300, 300, 1200, 1000); setResizeLimits (300, 300, 1200, 1000);
content->chooserComponent->addListener (this);
content->okButton.addButtonListener (this);
content->cancelButton.addButtonListener (this);
content->chooserComponent.addListener (this);
} }
FileChooserDialogBox::~FileChooserDialogBox() FileChooserDialogBox::~FileChooserDialogBox()
{ {
content->chooserComponent->removeListener (this);
content->chooserComponent.removeListener (this);
} }
//============================================================================== //==============================================================================
@@ -83,7 +67,7 @@ bool FileChooserDialogBox::showAt (int x, int y, int w, int h)
{ {
if (w <= 0) if (w <= 0)
{ {
Component* const previewComp = content->chooserComponent->getPreviewComponent();
Component* const previewComp = content->chooserComponent.getPreviewComponent();
if (previewComp != 0) if (previewComp != 0)
w = 400 + previewComp->getWidth(); w = 400 + previewComp->getWidth();
else else
@@ -106,16 +90,16 @@ bool FileChooserDialogBox::showAt (int x, int y, int w, int h)
//============================================================================== //==============================================================================
void FileChooserDialogBox::buttonClicked (Button* button) void FileChooserDialogBox::buttonClicked (Button* button)
{ {
if (button == content->okButton)
if (button == &(content->okButton))
{ {
if (warnAboutOverwritingExistingFiles if (warnAboutOverwritingExistingFiles
&& content->chooserComponent->isSaveMode()
&& content->chooserComponent->getSelectedFile(0).exists())
&& content->chooserComponent.isSaveMode()
&& content->chooserComponent.getSelectedFile(0).exists())
{ {
if (! AlertWindow::showOkCancelBox (AlertWindow::WarningIcon, if (! AlertWindow::showOkCancelBox (AlertWindow::WarningIcon,
TRANS("File already exists"), TRANS("File already exists"),
TRANS("There's already a file called:") TRANS("There's already a file called:")
+ "\n\n" + content->chooserComponent->getSelectedFile(0).getFullPathName()
+ "\n\n" + content->chooserComponent.getSelectedFile(0).getFullPathName()
+ "\n\n" + TRANS("Are you sure you want to overwrite it?"), + "\n\n" + TRANS("Are you sure you want to overwrite it?"),
TRANS("overwrite"), TRANS("overwrite"),
TRANS("cancel"))) TRANS("cancel")))
@@ -126,8 +110,10 @@ void FileChooserDialogBox::buttonClicked (Button* button)
exitModalState (1); exitModalState (1);
} }
else if (button == content->cancelButton)
else if (button == &(content->cancelButton))
{
closeButtonPressed(); closeButtonPressed();
}
} }
void FileChooserDialogBox::closeButtonPressed() void FileChooserDialogBox::closeButtonPressed()
@@ -137,7 +123,7 @@ void FileChooserDialogBox::closeButtonPressed()
void FileChooserDialogBox::selectionChanged() void FileChooserDialogBox::selectionChanged()
{ {
content->okButton->setEnabled (content->chooserComponent->currentFileIsValid());
content->okButton.setEnabled (content->chooserComponent.currentFileIsValid());
} }
void FileChooserDialogBox::fileClicked (const File&, const MouseEvent&) void FileChooserDialogBox::fileClicked (const File&, const MouseEvent&)
@@ -147,19 +133,30 @@ void FileChooserDialogBox::fileClicked (const File&, const MouseEvent&)
void FileChooserDialogBox::fileDoubleClicked (const File&) void FileChooserDialogBox::fileDoubleClicked (const File&)
{ {
selectionChanged(); selectionChanged();
content->okButton->triggerClick();
content->okButton.triggerClick();
} }
//============================================================================== //==============================================================================
FileChooserDialogBox::ContentComponent::ContentComponent()
FileChooserDialogBox::ContentComponent::ContentComponent (const String& name, const String& instructions_, FileBrowserComponent& chooserComponent_)
: Component (name), instructions (instructions_),
chooserComponent (chooserComponent_),
okButton (chooserComponent_.getActionVerb()),
cancelButton (TRANS ("Cancel"))
{ {
addAndMakeVisible (&chooserComponent);
addAndMakeVisible (&okButton);
okButton.setEnabled (chooserComponent.currentFileIsValid());
okButton.addShortcut (KeyPress (KeyPress::returnKey, 0, 0));
addAndMakeVisible (&cancelButton);
cancelButton.addShortcut (KeyPress (KeyPress::escapeKey, 0, 0));
setInterceptsMouseClicks (false, true); setInterceptsMouseClicks (false, true);
} }
FileChooserDialogBox::ContentComponent::~ContentComponent() FileChooserDialogBox::ContentComponent::~ContentComponent()
{ {
delete okButton;
delete cancelButton;
} }
void FileChooserDialogBox::ContentComponent::paint (Graphics& g) void FileChooserDialogBox::ContentComponent::paint (Graphics& g)
@@ -178,13 +175,13 @@ void FileChooserDialogBox::ContentComponent::resized()
const int buttonHeight = 26; const int buttonHeight = 26;
const int buttonY = getHeight() - buttonHeight - 8; const int buttonY = getHeight() - buttonHeight - 8;
chooserComponent->setBounds (0, y, getWidth(), buttonY - y - 20);
chooserComponent.setBounds (0, y, getWidth(), buttonY - y - 20);
okButton->setBounds (proportionOfWidth (0.25f), buttonY,
proportionOfWidth (0.2f), buttonHeight);
okButton.setBounds (proportionOfWidth (0.25f), buttonY,
proportionOfWidth (0.2f), buttonHeight);
cancelButton->setBounds (proportionOfWidth (0.55f), buttonY,
proportionOfWidth (0.2f), buttonHeight);
cancelButton.setBounds (proportionOfWidth (0.55f), buttonY,
proportionOfWidth (0.2f), buttonHeight);
} }


+ 3
- 5
src/gui/components/filebrowser/juce_FileChooserDialogBox.h View File

@@ -145,7 +145,7 @@ private:
class ContentComponent : public Component class ContentComponent : public Component
{ {
public: public:
ContentComponent();
ContentComponent (const String& name, const String& instructions, FileBrowserComponent& chooserComponent);
~ContentComponent(); ~ContentComponent();
void paint (Graphics& g); void paint (Graphics& g);
@@ -154,10 +154,8 @@ private:
String instructions; String instructions;
GlyphArrangement text; GlyphArrangement text;
FileBrowserComponent* chooserComponent;
FilePreviewComponent* previewComponent;
TextButton* okButton;
TextButton* cancelButton;
FileBrowserComponent& chooserComponent;
TextButton okButton, cancelButton;
}; };
ContentComponent* content; ContentComponent* content;


+ 3
- 0
src/gui/components/juce_Component.h View File

@@ -1978,6 +1978,9 @@ public:
/** Returns the component that this pointer refers to, or null if the component no longer exists. */ /** Returns the component that this pointer refers to, or null if the component no longer exists. */
const ComponentType* operator->() const throw() { jassert (comp != 0); return comp; } const ComponentType* operator->() const throw() { jassert (comp != 0); return comp; }
/** If the component is valid, this deletes it and sets this pointer to null. */
void deleteAndZero() { delete comp; jassert (comp == 0); }
//============================================================================== //==============================================================================
juce_UseDebuggingNewOperator juce_UseDebuggingNewOperator


+ 2
- 3
src/gui/components/layout/juce_MultiDocumentPanel.cpp View File

@@ -115,7 +115,6 @@ public:
//============================================================================== //==============================================================================
MultiDocumentPanel::MultiDocumentPanel() MultiDocumentPanel::MultiDocumentPanel()
: mode (MaximisedWindowsWithTabs), : mode (MaximisedWindowsWithTabs),
tabComponent (0),
backgroundColour (Colours::lightblue), backgroundColour (Colours::lightblue),
maximumNumDocuments (0), maximumNumDocuments (0),
numDocsBeforeTabsUsed (0) numDocsBeforeTabsUsed (0)
@@ -309,7 +308,7 @@ bool MultiDocumentPanel::closeDocument (Component* component,
delete component; delete component;
if (tabComponent != 0 && tabComponent->getNumTabs() <= numDocsBeforeTabsUsed) if (tabComponent != 0 && tabComponent->getNumTabs() <= numDocsBeforeTabsUsed)
deleteAndZero (tabComponent);
tabComponent = 0;
components.removeValue (component); components.removeValue (component);
@@ -410,7 +409,7 @@ void MultiDocumentPanel::setLayoutMode (const LayoutMode newLayoutMode)
if (mode == FloatingWindows) if (mode == FloatingWindows)
{ {
deleteAndZero (tabComponent);
tabComponent = 0;
} }
else else
{ {


+ 1
- 1
src/gui/components/layout/juce_MultiDocumentPanel.h View File

@@ -290,7 +290,7 @@ public:
private: private:
LayoutMode mode; LayoutMode mode;
Array <Component*> components; Array <Component*> components;
TabbedComponent* tabComponent;
ScopedPointer<TabbedComponent> tabComponent;
Colour backgroundColour; Colour backgroundColour;
int maximumNumDocuments, numDocsBeforeTabsUsed; int maximumNumDocuments, numDocsBeforeTabsUsed;


+ 3
- 4
src/gui/components/windows/juce_ResizableWindow.cpp View File

@@ -78,8 +78,7 @@ ResizableWindow::~ResizableWindow()
{ {
resizableCorner = 0; resizableCorner = 0;
resizableBorder = 0; resizableBorder = 0;
delete static_cast <Component*> (contentComponent);
contentComponent = 0;
contentComponent.deleteAndZero();
// have you been adding your own components directly to this window..? tut tut tut. // have you been adding your own components directly to this window..? tut tut tut.
// Read the instructions for using a ResizableWindow! // Read the instructions for using a ResizableWindow!
@@ -106,8 +105,8 @@ void ResizableWindow::setContentComponent (Component* const newContentComponent,
if (newContentComponent != static_cast <Component*> (contentComponent)) if (newContentComponent != static_cast <Component*> (contentComponent))
{ {
if (deleteOldOne) if (deleteOldOne)
delete static_cast <Component*> (contentComponent); // (avoid using a scoped pointer for this, so that it survives
// external deletion of the content comp)
contentComponent.deleteAndZero(); // (avoid using a scoped pointer for this, so that it survives
// external deletion of the content comp)
else else
removeChildComponent (contentComponent); removeChildComponent (contentComponent);


+ 2
- 2
src/gui/graphics/drawables/juce_SVGParser.cpp View File

@@ -830,12 +830,12 @@ private:
Path path; Path path;
Drawable* s = parseShape (*e, path); Drawable* s = parseShape (*e, path);
delete s;
delete s; // xxx not finished!
} }
else if (e->hasTagName ("tspan")) else if (e->hasTagName ("tspan"))
{ {
Drawable* s = parseText (*e); Drawable* s = parseText (*e);
delete s;
delete s; // xxx not finished!
} }
} }


+ 1
- 1
src/io/network/juce_Socket.cpp View File

@@ -546,7 +546,7 @@ DatagramSocket::~DatagramSocket()
{ {
close(); close();
delete ((struct sockaddr_in*) serverAddress);
delete static_cast <struct sockaddr_in*> (serverAddress);
serverAddress = 0; serverAddress = 0;
} }


+ 5
- 5
src/native/common/juce_posix_NamedPipe.cpp View File

@@ -40,9 +40,9 @@ struct NamedPipeInternal
void NamedPipe::cancelPendingReads() void NamedPipe::cancelPendingReads()
{ {
while (internal != 0 && ((NamedPipeInternal*) internal)->blocked)
while (internal != 0 && static_cast <NamedPipeInternal*> (internal)->blocked)
{ {
NamedPipeInternal* const intern = (NamedPipeInternal*) internal;
NamedPipeInternal* const intern = static_cast <NamedPipeInternal*> (internal);
intern->stopReadOperation = true; intern->stopReadOperation = true;
@@ -60,7 +60,7 @@ void NamedPipe::cancelPendingReads()
void NamedPipe::close() void NamedPipe::close()
{ {
NamedPipeInternal* const intern = (NamedPipeInternal*) internal;
NamedPipeInternal* const intern = static_cast <NamedPipeInternal*> (internal);
if (intern != 0) if (intern != 0)
{ {
@@ -120,7 +120,7 @@ bool NamedPipe::openInternal (const String& pipeName, const bool createPipe)
int NamedPipe::read (void* destBuffer, int maxBytesToRead, int /*timeOutMilliseconds*/) int NamedPipe::read (void* destBuffer, int maxBytesToRead, int /*timeOutMilliseconds*/)
{ {
int bytesRead = -1; int bytesRead = -1;
NamedPipeInternal* const intern = (NamedPipeInternal*) internal;
NamedPipeInternal* const intern = static_cast <NamedPipeInternal*> (internal);
if (intern != 0) if (intern != 0)
{ {
@@ -168,7 +168,7 @@ int NamedPipe::read (void* destBuffer, int maxBytesToRead, int /*timeOutMillisec
int NamedPipe::write (const void* sourceBuffer, int numBytesToWrite, int timeOutMilliseconds) int NamedPipe::write (const void* sourceBuffer, int numBytesToWrite, int timeOutMilliseconds)
{ {
int bytesWritten = -1; int bytesWritten = -1;
NamedPipeInternal* const intern = (NamedPipeInternal*) internal;
NamedPipeInternal* const intern = static_cast <NamedPipeInternal*> (internal);
if (intern != 0) if (intern != 0)
{ {


+ 5
- 7
src/native/linux/juce_linux_Midi.cpp View File

@@ -250,8 +250,7 @@ MidiOutput* MidiOutput::createNewDevice (const String& deviceName)
MidiOutput::~MidiOutput() MidiOutput::~MidiOutput()
{ {
MidiOutputDevice* const device = (MidiOutputDevice*) internal;
delete device;
delete static_cast <MidiOutputDevice*> (internal);
} }
void MidiOutput::reset() void MidiOutput::reset()
@@ -269,7 +268,7 @@ void MidiOutput::setVolume (float leftVol, float rightVol)
void MidiOutput::sendMessageNow (const MidiMessage& message) void MidiOutput::sendMessageNow (const MidiMessage& message)
{ {
((MidiOutputDevice*) internal)->sendMessageNow (message);
static_cast <MidiOutputDevice*> (internal)->sendMessageNow (message);
} }
@@ -365,18 +364,17 @@ MidiInput::MidiInput (const String& name_)
MidiInput::~MidiInput() MidiInput::~MidiInput()
{ {
stop(); stop();
MidiInputThread* const thread = (MidiInputThread*) internal;
delete thread;
delete static_cast <MidiInputThread*> (internal);
} }
void MidiInput::start() void MidiInput::start()
{ {
((MidiInputThread*) internal)->startThread();
static_cast <MidiInputThread*> (internal)->startThread();
} }
void MidiInput::stop() void MidiInput::stop()
{ {
((MidiInputThread*) internal)->stopThread (3000);
static_cast <MidiInputThread*> (internal)->stopThread (3000);
} }
int MidiInput::getDefaultDeviceIndex() int MidiInput::getDefaultDeviceIndex()


+ 5
- 5
src/native/mac/juce_mac_CoreMidi.cpp View File

@@ -308,7 +308,7 @@ MidiOutput* MidiOutput::createNewDevice (const String& deviceName)
MidiOutput::~MidiOutput() MidiOutput::~MidiOutput()
{ {
delete (MidiPortAndEndpoint*) internal;
delete static_cast<MidiPortAndEndpoint*> (internal);
} }
void MidiOutput::reset() void MidiOutput::reset()
@@ -326,7 +326,7 @@ void MidiOutput::setVolume (float /*leftVol*/, float /*rightVol*/)
void MidiOutput::sendMessageNow (const MidiMessage& message) void MidiOutput::sendMessageNow (const MidiMessage& message)
{ {
MidiPortAndEndpoint* const mpe = (MidiPortAndEndpoint*) internal;
MidiPortAndEndpoint* const mpe = static_cast<MidiPortAndEndpoint*> (internal);
if (message.isSysEx()) if (message.isSysEx())
{ {
@@ -619,7 +619,7 @@ MidiInput::MidiInput (const String& name_)
MidiInput::~MidiInput() MidiInput::~MidiInput()
{ {
MidiPortAndCallback* const mpc = (MidiPortAndCallback*) internal;
MidiPortAndCallback* const mpc = static_cast<MidiPortAndCallback*> (internal);
mpc->active = false; mpc->active = false;
{ {
@@ -637,13 +637,13 @@ MidiInput::~MidiInput()
void MidiInput::start() void MidiInput::start()
{ {
const ScopedLock sl (CoreMidiCallbacks::callbackLock); const ScopedLock sl (CoreMidiCallbacks::callbackLock);
((MidiPortAndCallback*) internal)->active = true;
static_cast<MidiPortAndCallback*> (internal)->active = true;
} }
void MidiInput::stop() void MidiInput::stop()
{ {
const ScopedLock sl (CoreMidiCallbacks::callbackLock); const ScopedLock sl (CoreMidiCallbacks::callbackLock);
((MidiPortAndCallback*) internal)->active = false;
static_cast<MidiPortAndCallback*> (internal)->active = false;
} }
#undef log #undef log


+ 3
- 4
src/native/windows/juce_win32_OpenGLComponent.cpp View File

@@ -81,7 +81,6 @@ public:
HGLRC contextToShareWith, HGLRC contextToShareWith,
const OpenGLPixelFormat& pixelFormat) const OpenGLPixelFormat& pixelFormat)
: renderContext (0), : renderContext (0),
nativeWindow (0),
dc (0), dc (0),
component (component_) component (component_)
{ {
@@ -117,7 +116,7 @@ public:
{ {
deleteContext(); deleteContext();
ReleaseDC ((HWND) nativeWindow->getNativeHandle(), dc); ReleaseDC ((HWND) nativeWindow->getNativeHandle(), dc);
delete nativeWindow;
nativeWindow = 0;
} }
void deleteContext() void deleteContext()
@@ -270,7 +269,7 @@ public:
// old one and create a new one.. // old one and create a new one..
jassert (nativeWindow != 0); jassert (nativeWindow != 0);
ReleaseDC ((HWND) nativeWindow->getNativeHandle(), dc); ReleaseDC ((HWND) nativeWindow->getNativeHandle(), dc);
delete nativeWindow;
nativeWindow = 0;
createNativeWindow(); createNativeWindow();
@@ -385,7 +384,7 @@ public:
HGLRC renderContext; HGLRC renderContext;
private: private:
Win32ComponentPeer* nativeWindow;
ScopedPointer<Win32ComponentPeer> nativeWindow;
Component* const component; Component* const component;
HDC dc; HDC dc;


+ 5
- 8
src/native/windows/juce_win32_WASAPI.cpp View File

@@ -584,9 +584,7 @@ public:
Thread ("Juce WASAPI"), Thread ("Juce WASAPI"),
isOpen_ (false), isOpen_ (false),
isStarted (false), isStarted (false),
outputDevice (0),
outputDeviceId (outputDeviceId_), outputDeviceId (outputDeviceId_),
inputDevice (0),
inputDeviceId (inputDeviceId_), inputDeviceId (inputDeviceId_),
useExclusiveMode (useExclusiveMode_), useExclusiveMode (useExclusiveMode_),
currentBufferSizeSamples (0), currentBufferSizeSamples (0),
@@ -598,9 +596,6 @@ public:
~WASAPIAudioIODevice() ~WASAPIAudioIODevice()
{ {
close(); close();
deleteAndZero (inputDevice);
deleteAndZero (outputDevice);
} }
bool initialise() bool initialise()
@@ -624,7 +619,8 @@ public:
} }
else else
{ {
WASAPIDeviceBase* const d = inputDevice != 0 ? (WASAPIDeviceBase*) inputDevice : (WASAPIDeviceBase*) outputDevice;
WASAPIDeviceBase* d = inputDevice != 0 ? static_cast<WASAPIDeviceBase*> (inputDevice)
: static_cast<WASAPIDeviceBase*> (outputDevice);
defaultSampleRate = d->defaultSampleRate; defaultSampleRate = d->defaultSampleRate;
minBufferSize = d->minBufferSize; minBufferSize = d->minBufferSize;
defaultBufferSize = d->defaultBufferSize; defaultBufferSize = d->defaultBufferSize;
@@ -718,6 +714,7 @@ public:
if (inputDevice != 0) if (inputDevice != 0)
ResetEvent (inputDevice->clientEvent); ResetEvent (inputDevice->clientEvent);
if (outputDevice != 0) if (outputDevice != 0)
ResetEvent (outputDevice->clientEvent); ResetEvent (outputDevice->clientEvent);
@@ -891,8 +888,8 @@ public:
private: private:
// Device stats... // Device stats...
WASAPIInputDevice* inputDevice;
WASAPIOutputDevice* outputDevice;
ScopedPointer<WASAPIInputDevice> inputDevice;
ScopedPointer<WASAPIOutputDevice> outputDevice;
const bool useExclusiveMode; const bool useExclusiveMode;
double defaultSampleRate; double defaultSampleRate;
int minBufferSize, defaultBufferSize; int minBufferSize, defaultBufferSize;


+ 4
- 9
src/native/windows/juce_win32_Windowing.cpp View File

@@ -392,7 +392,6 @@ public:
isMouseOver (false), isMouseOver (false),
hasCreatedCaret (false), hasCreatedCaret (false),
currentWindowIcon (0), currentWindowIcon (0),
taskBarIcon (0),
dropTarget (0) dropTarget (0)
{ {
callFunctionIfNotLocked (&createWindowCallback, this); callFunctionIfNotLocked (&createWindowCallback, this);
@@ -407,16 +406,12 @@ public:
if (shadower != 0) if (shadower != 0)
shadower->setOwner (component); shadower->setOwner (component);
} }
else
{
shadower = 0;
}
} }
~Win32ComponentPeer() ~Win32ComponentPeer()
{ {
setTaskBarIcon (Image()); setTaskBarIcon (Image());
deleteAndZero (shadower);
shadower = 0;
// do this before the next bit to avoid messages arriving for this window // do this before the next bit to avoid messages arriving for this window
// before it's destroyed // before it's destroyed
@@ -779,7 +774,7 @@ public:
taskBarIcon->uFlags = 0; taskBarIcon->uFlags = 0;
Shell_NotifyIcon (NIM_DELETE, taskBarIcon); Shell_NotifyIcon (NIM_DELETE, taskBarIcon);
DestroyIcon (taskBarIcon->hIcon); DestroyIcon (taskBarIcon->hIcon);
deleteAndZero (taskBarIcon);
taskBarIcon = 0;
} }
} }
@@ -846,11 +841,11 @@ public:
private: private:
HWND hwnd; HWND hwnd;
DropShadower* shadower;
ScopedPointer<DropShadower> shadower;
bool fullScreen, isDragging, isMouseOver, hasCreatedCaret; bool fullScreen, isDragging, isMouseOver, hasCreatedCaret;
BorderSize windowBorder; BorderSize windowBorder;
HICON currentWindowIcon; HICON currentWindowIcon;
NOTIFYICONDATA* taskBarIcon;
ScopedPointer<NOTIFYICONDATA> taskBarIcon;
IDropTarget* dropTarget; IDropTarget* dropTarget;
//============================================================================== //==============================================================================


Loading…
Cancel
Save