From 4e52fac18e7ce180bf3ec0dca8f8ad5f44a21d20 Mon Sep 17 00:00:00 2001 From: Julian Storer Date: Tue, 30 Nov 2010 19:23:37 +0000 Subject: [PATCH] Fixed a linux time issue. Removed a blank line from the jucer's .sln file generator. Cleaned up some jucer code. --- .../Application/jucer_OpenDocumentManager.cpp | 3 +- .../Source/Project/jucer_Project.h | 3 +- .../Source/Project/jucer_ProjectExport_MSVC.h | 17 +-- .../Source/Project/jucer_ProjectExport_Make.h | 3 +- .../Source/Project/jucer_ProjectExporter.h | 3 +- .../Source/Project/jucer_ProjectSaver.h | 2 + .../Source/Project/jucer_ResourceFile.h | 2 + extras/audio plugin host/Source/FilterGraph.h | 139 +----------------- .../Source/GraphEditorPanel.cpp | 20 +-- .../Source/InternalFilters.h | 4 +- .../audio plugin host/Source/MainHostWindow.h | 7 +- .../demo/Source/PluginProcessor.h | 6 +- .../wrapper/juce_BrowserPluginComponent.h | 3 +- extras/juce demo/Source/demos/WidgetsDemo.cpp | 4 +- juce_amalgamated.cpp | 85 ++++++----- juce_amalgamated.h | 19 ++- src/containers/juce_ScopedPointer.h | 19 ++- .../components/windows/juce_ComponentPeer.cpp | 27 +++- .../components/windows/juce_DialogWindow.cpp | 38 ++--- .../drawables/juce_DrawableComposite.h | 1 - .../juce_GZIPCompressorOutputStream.cpp | 9 +- src/native/linux/juce_linux_SystemStats.cpp | 6 +- .../mac/juce_mac_NSViewComponentPeer.mm | 4 +- src/native/windows/juce_win32_Windowing.cpp | 2 - 24 files changed, 165 insertions(+), 261 deletions(-) diff --git a/extras/Jucer (experimental)/Source/Application/jucer_OpenDocumentManager.cpp b/extras/Jucer (experimental)/Source/Application/jucer_OpenDocumentManager.cpp index 0fc19d8aca..f96e0136a7 100644 --- a/extras/Jucer (experimental)/Source/Application/jucer_OpenDocumentManager.cpp +++ b/extras/Jucer (experimental)/Source/Application/jucer_OpenDocumentManager.cpp @@ -161,8 +161,7 @@ private: File file; Time fileModificationTime; - UnknownDocument (const UnknownDocument&); - UnknownDocument& operator= (const UnknownDocument&); + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (UnknownDocument); }; diff --git a/extras/Jucer (experimental)/Source/Project/jucer_Project.h b/extras/Jucer (experimental)/Source/Project/jucer_Project.h index e08f93530e..f2422a0123 100644 --- a/extras/Jucer (experimental)/Source/Project/jucer_Project.h +++ b/extras/Jucer (experimental)/Source/Project/jucer_Project.h @@ -322,8 +322,7 @@ private: void createDefaultConfigs(); ValueTree getJuceConfigNode(); - Project (const Project&); - const Project& operator= (const Project&); + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Project); }; diff --git a/extras/Jucer (experimental)/Source/Project/jucer_ProjectExport_MSVC.h b/extras/Jucer (experimental)/Source/Project/jucer_ProjectExport_MSVC.h index 4d8171f9e5..c4cdf50614 100644 --- a/extras/Jucer (experimental)/Source/Project/jucer_ProjectExport_MSVC.h +++ b/extras/Jucer (experimental)/Source/Project/jucer_ProjectExport_MSVC.h @@ -243,7 +243,7 @@ protected: //============================================================================== void writeSolutionFile (OutputStream& out, const String& versionString, const File& vcProject) { - out << newLine << "Microsoft Visual Studio Solution File, Format Version " << versionString << newLine + out << "Microsoft Visual Studio Solution File, Format Version " << versionString << newLine << "Project(\"" << createGUID (project.getProjectName().toString() + "sln_guid") << "\") = \"" << project.getProjectName().toString() << "\", \"" << vcProject.getFileName() << "\", \"" << projectGUID << '"' << newLine << "EndProject" << newLine @@ -448,8 +448,7 @@ protected: return hasIcon; } - MSVCProjectExporterBase (const MSVCProjectExporterBase&); - MSVCProjectExporterBase& operator= (const MSVCProjectExporterBase&); + JUCE_DECLARE_NON_COPYABLE (MSVCProjectExporterBase); }; @@ -816,8 +815,7 @@ protected: } //============================================================================== - MSVCProjectExporterVC2008 (const MSVCProjectExporterVC2008&); - MSVCProjectExporterVC2008& operator= (const MSVCProjectExporterVC2008&); + JUCE_DECLARE_NON_COPYABLE (MSVCProjectExporterVC2008); }; @@ -850,8 +848,7 @@ protected: const String getProjectVersionString() const { return "8.00"; } const String getSolutionVersionString() const { return String ("8.00") + newLine + "# Visual C++ Express 2005"; } - MSVCProjectExporterVC2005 (const MSVCProjectExporterVC2005&); - MSVCProjectExporterVC2005& operator= (const MSVCProjectExporterVC2005&); + JUCE_DECLARE_NON_COPYABLE (MSVCProjectExporterVC2005); }; @@ -1121,8 +1118,7 @@ private: << "}}}" << newLine; } - MSVCProjectExporterVC6 (const MSVCProjectExporterVC6&); - MSVCProjectExporterVC6& operator= (const MSVCProjectExporterVC6&); + JUCE_DECLARE_NON_COPYABLE (MSVCProjectExporterVC6); }; @@ -1552,8 +1548,7 @@ protected: } //============================================================================== - MSVCProjectExporterVC2010 (const MSVCProjectExporterVC2010&); - MSVCProjectExporterVC2010& operator= (const MSVCProjectExporterVC2010&); + JUCE_DECLARE_NON_COPYABLE (MSVCProjectExporterVC2010); }; diff --git a/extras/Jucer (experimental)/Source/Project/jucer_ProjectExport_Make.h b/extras/Jucer (experimental)/Source/Project/jucer_ProjectExport_Make.h index 65ceb84427..458c47015d 100644 --- a/extras/Jucer (experimental)/Source/Project/jucer_ProjectExport_Make.h +++ b/extras/Jucer (experimental)/Source/Project/jucer_ProjectExport_Make.h @@ -342,8 +342,7 @@ private: + "_" + String::toHexString (file.toUnixStyle().hashCode()) + ".o"; } - MakefileProjectExporter (const MakefileProjectExporter&); - MakefileProjectExporter& operator= (const MakefileProjectExporter&); + JUCE_DECLARE_NON_COPYABLE (MakefileProjectExporter); }; diff --git a/extras/Jucer (experimental)/Source/Project/jucer_ProjectExporter.h b/extras/Jucer (experimental)/Source/Project/jucer_ProjectExporter.h index 9fe7cd1972..914ad97e9f 100644 --- a/extras/Jucer (experimental)/Source/Project/jucer_ProjectExporter.h +++ b/extras/Jucer (experimental)/Source/Project/jucer_ProjectExporter.h @@ -119,8 +119,7 @@ protected: const RelativePath rebaseFromProjectFolderToBuildTarget (const RelativePath& path) const; private: - ProjectExporter (const ProjectExporter&); - ProjectExporter& operator= (const ProjectExporter&); + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ProjectExporter); }; diff --git a/extras/Jucer (experimental)/Source/Project/jucer_ProjectSaver.h b/extras/Jucer (experimental)/Source/Project/jucer_ProjectSaver.h index 83ca5ac789..98da02b571 100644 --- a/extras/Jucer (experimental)/Source/Project/jucer_ProjectSaver.h +++ b/extras/Jucer (experimental)/Source/Project/jucer_ProjectSaver.h @@ -535,6 +535,8 @@ private: return project.getWrapperFolder().getChildFile (project.getJuceSourceFilenameRoot() + (fileIndex != 0 ? String (fileIndex) : String::empty)) .withFileExtension (".cpp"); } + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ProjectSaver); }; diff --git a/extras/Jucer (experimental)/Source/Project/jucer_ResourceFile.h b/extras/Jucer (experimental)/Source/Project/jucer_ResourceFile.h index b3745c3f29..2cd84cdec8 100644 --- a/extras/Jucer (experimental)/Source/Project/jucer_ResourceFile.h +++ b/extras/Jucer (experimental)/Source/Project/jucer_ResourceFile.h @@ -60,6 +60,8 @@ private: String className; void addResourcesFromProjectItem (const Project::Item& node); + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ResourceFile); }; diff --git a/extras/audio plugin host/Source/FilterGraph.h b/extras/audio plugin host/Source/FilterGraph.h index 424d1f6c14..458a4704e9 100644 --- a/extras/audio plugin host/Source/FilterGraph.h +++ b/extras/audio plugin host/Source/FilterGraph.h @@ -59,67 +59,6 @@ private: FilterConnection& operator= (const FilterConnection&); }; - -//============================================================================== -/** - Represents one of the filters in a FilterGraph. -*/ -/*class FilterInGraph : public ReferenceCountedObject -{ -public: - //============================================================================== - FilterInGraph (FilterGraph& owner, AudioPluginInstance* const plugin); - ~FilterInGraph(); - - //============================================================================== - AudioPluginInstance* const filter; - uint32 uid; - - //============================================================================== - void showUI (bool useGenericUI); - - double getX() const throw() { return x; } - double getY() const throw() { return y; } - void setPosition (double x, double y) throw(); - - XmlElement* createXml() const; - - static FilterInGraph* createForDescription (FilterGraph& owner, - const PluginDescription& desc, - String& errorMessage); - - static FilterInGraph* createFromXml (FilterGraph& owner, const XmlElement& xml); - - //============================================================================== - typedef ReferenceCountedObjectPtr Ptr; - - //============================================================================== - juce_UseDebuggingNewOperator - -private: - friend class FilterGraphPlayer; - FilterGraph& owner; - double x, y; - - friend class PluginWindow; - Component* activeUI; - Component* activeGenericUI; - int lastX, lastY; - - MidiBuffer outputMidi; - AudioSampleBuffer processedAudio; - MidiBuffer processedMidi; - - void prepareBuffers (int blockSize); - void renderBlock (int numSamples, - const ReferenceCountedArray & filters, - const OwnedArray & connections); - - FilterInGraph (const FilterInGraph&); - FilterInGraph& operator= (const FilterInGraph&); -}; -*/ - //============================================================================== /** A collection of filters and some connections between them. @@ -185,14 +124,8 @@ public: */ static const int midiChannelNumber; - //============================================================================== - juce_UseDebuggingNewOperator - private: - //friend class FilterGraphPlayer; - //ReferenceCountedArray filters; - //OwnedArray connections; - + //============================================================================== AudioProcessorGraph graph; AudioProcessorPlayer player; @@ -201,76 +134,8 @@ private: void createNodeFromXml (const XmlElement& xml); - FilterGraph (const FilterGraph&); - FilterGraph& operator= (const FilterGraph&); + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FilterGraph); }; -//============================================================================== -/** - -*/ -/*class FilterGraphPlayer : public AudioIODeviceCallback, - public MidiInputCallback, - public ChangeListener - -{ -public: - //============================================================================== - FilterGraphPlayer (FilterGraph& graph); - ~FilterGraphPlayer(); - - //============================================================================== - void setAudioDeviceManager (AudioDeviceManager* dm); - AudioDeviceManager* getAudioDeviceManager() const throw() { return deviceManager; } - - //============================================================================== - void audioDeviceIOCallback (const float** inputChannelData, - int totalNumInputChannels, - float** outputChannelData, - int totalNumOutputChannels, - int numSamples); - void audioDeviceAboutToStart (double sampleRate, int numSamplesPerBlock); - void audioDeviceStopped(); - - void handleIncomingMidiMessage (MidiInput* source, const MidiMessage& message); - - void changeListenerCallback (ChangeBroadcaster*); - - //============================================================================== - static int compareElements (FilterInGraph* const first, FilterInGraph* const second) throw(); - - const float** inputChannelData; - int totalNumInputChannels; - float** outputChannelData; - int totalNumOutputChannels; - MidiBuffer incomingMidi; - - MidiKeyboardState keyState; - MidiMessageCollector messageCollector; - - //============================================================================== - class PlayerAwareFilter - { - public: - virtual void setPlayer (FilterGraphPlayer* newPlayer) = 0; - }; - -private: - FilterGraph& graph; - CriticalSection processLock; - double sampleRate; - int blockSize; - AudioDeviceManager* deviceManager; - - ReferenceCountedArray filters; - OwnedArray connections; - - void update(); - - FilterGraphPlayer (const FilterGraphPlayer&); - FilterGraphPlayer& operator= (const FilterGraphPlayer&); -}; -*/ - #endif diff --git a/extras/audio plugin host/Source/GraphEditorPanel.cpp b/extras/audio plugin host/Source/GraphEditorPanel.cpp index c2c9237e10..5b4339c759 100644 --- a/extras/audio plugin host/Source/GraphEditorPanel.cpp +++ b/extras/audio plugin host/Source/GraphEditorPanel.cpp @@ -192,8 +192,6 @@ public: getGraphPanel()->endDraggingConnector (e); } - juce_UseDebuggingNewOperator - const uint32 filterID; const int index; const bool isInput; @@ -201,13 +199,12 @@ public: private: FilterGraph& graph; - PinComponent (const PinComponent&); - PinComponent& operator= (const PinComponent&); - GraphEditorPanel* getGraphPanel() const throw() { return findParentComponentOfClass ((GraphEditorPanel*) 0); } + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PinComponent); }; //============================================================================== @@ -679,8 +676,6 @@ public: linePath.setUsingNonZeroWinding (true); } - juce_UseDebuggingNewOperator - uint32 sourceFilterID, destFilterID; int sourceFilterChannel, destFilterChannel; @@ -704,8 +699,7 @@ private: distanceFromEnd = juce_hypot (x - (x2 - getX()), y - (y2 - getY())); } - ConnectorComponent (const ConnectorComponent&); - ConnectorComponent& operator= (const ConnectorComponent&); + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ConnectorComponent); }; @@ -990,10 +984,6 @@ public: startTimer (100); } - ~TooltipBar() - { - } - void paint (Graphics& g) { g.setFont (getHeight() * 0.7f, Font::bold); @@ -1018,10 +1008,10 @@ public: } } - juce_UseDebuggingNewOperator - private: String tip; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TooltipBar); }; //============================================================================== diff --git a/extras/audio plugin host/Source/InternalFilters.h b/extras/audio plugin host/Source/InternalFilters.h index de317edc52..b928134128 100644 --- a/extras/audio plugin host/Source/InternalFilters.h +++ b/extras/audio plugin host/Source/InternalFilters.h @@ -64,10 +64,8 @@ public: const StringArray searchPathsForPlugins (const FileSearchPath&, bool) { return StringArray(); } AudioPluginInstance* createInstanceFromDescription (const PluginDescription& desc); - //============================================================================== - juce_UseDebuggingNewOperator - private: + //============================================================================== PluginDescription audioInDesc; PluginDescription audioOutDesc; PluginDescription midiInDesc; diff --git a/extras/audio plugin host/Source/MainHostWindow.h b/extras/audio plugin host/Source/MainHostWindow.h index e2e3dd6d66..1c167822b3 100644 --- a/extras/audio plugin host/Source/MainHostWindow.h +++ b/extras/audio plugin host/Source/MainHostWindow.h @@ -83,11 +83,8 @@ public: void addPluginsToMenu (PopupMenu& m) const; const PluginDescription* getChosenType (const int menuID) const; - - //============================================================================== - juce_UseDebuggingNewOperator - private: + //============================================================================== AudioDeviceManager deviceManager; OwnedArray internalTypes; @@ -96,6 +93,8 @@ private: void showAudioSettings(); GraphDocumentComponent* getGraphEditor() const; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainHostWindow); }; diff --git a/extras/audio plugins/demo/Source/PluginProcessor.h b/extras/audio plugins/demo/Source/PluginProcessor.h index 083fff0410..07f2291116 100644 --- a/extras/audio plugins/demo/Source/PluginProcessor.h +++ b/extras/audio plugins/demo/Source/PluginProcessor.h @@ -92,15 +92,15 @@ public: float gain, delay; - //============================================================================== - juce_UseDebuggingNewOperator - private: + //============================================================================== AudioSampleBuffer delayBuffer; int delayPosition; // the synth! Synthesiser synth; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (JuceDemoPluginAudioProcessor); }; #endif // __PLUGINPROCESSOR_H_526ED7A9__ diff --git a/extras/browser plugins/wrapper/juce_BrowserPluginComponent.h b/extras/browser plugins/wrapper/juce_BrowserPluginComponent.h index f227d4797c..6f97b454f7 100644 --- a/extras/browser plugins/wrapper/juce_BrowserPluginComponent.h +++ b/extras/browser plugins/wrapper/juce_BrowserPluginComponent.h @@ -68,8 +68,9 @@ public: */ virtual const var getJavascriptObject() = 0; +private: //============================================================================== - juce_UseDebuggingNewOperator + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (BrowserPluginComponent); }; diff --git a/extras/juce demo/Source/demos/WidgetsDemo.cpp b/extras/juce demo/Source/demos/WidgetsDemo.cpp index 47f5f4763a..17f60854b3 100644 --- a/extras/juce demo/Source/demos/WidgetsDemo.cpp +++ b/extras/juce demo/Source/demos/WidgetsDemo.cpp @@ -120,11 +120,9 @@ public: } else { - MouseEvent e2 (e.getEventRelativeTo (parent)); - // if the mouse is inside the parent component, we'll make that the // parent - otherwise, we'll put this comp on the desktop. - if (e2.x >= 0 && e2.y >= 0 && e2.x < parent->getWidth() && e2.y < parent->getHeight()) + if (parent->getLocalBounds().contains (e.getEventRelativeTo (parent).getPosition())) { // re-add this component to a parent component, which will // remove it from the desktop.. diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 795c5ee73a..61e251ca46 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -77609,8 +77609,31 @@ void ComponentPeer::handleFileDragDrop (const StringArray& files, const Point pos (targetComp->getLocalPoint (component, position)); - target->filesDropped (files, pos.getX(), pos.getY()); + // We'll use an async message to deliver the drop, because if the target decides + // to run a modal loop, it can gum-up the operating system.. + class AsyncFileDropMessage : public CallbackMessage + { + public: + AsyncFileDropMessage (Component* target_, const Point& position_, const StringArray& files_) + : target (target_), position (position_), files (files_) + { + } + + void messageCallback() + { + if (target != 0) + target->filesDropped (files, position.getX(), position.getY()); + } + + private: + Component::SafePointer target; + Point position; + StringArray files; + + JUCE_DECLARE_NON_COPYABLE (AsyncFileDropMessage); + }; + + (new AsyncFileDropMessage (targetComp, targetComp->getLocalPoint (component, position), files))->post(); } } } @@ -77681,25 +77704,6 @@ void DialogWindow::resized() } } -class TempDialogWindow : public DialogWindow -{ -public: - TempDialogWindow (const String& title, const Colour& colour, const bool escapeCloses) - : DialogWindow (title, colour, escapeCloses, true) - { - if (! JUCEApplication::isStandaloneApp()) - setAlwaysOnTop (true); // for a plugin, make it always-on-top because the host windows are often top-level - } - - void closeButtonPressed() - { - setVisible (false); - } - -private: - JUCE_DECLARE_NON_COPYABLE (TempDialogWindow); -}; - int DialogWindow::showModalDialog (const String& dialogTitle, Component* contentComponent, Component* componentToCentreAround, @@ -77708,6 +77712,25 @@ int DialogWindow::showModalDialog (const String& dialogTitle, const bool shouldBeResizable, const bool useBottomRightCornerResizer) { + class TempDialogWindow : public DialogWindow + { + public: + TempDialogWindow (const String& title, const Colour& colour, const bool escapeCloses) + : DialogWindow (title, colour, escapeCloses, true) + { + if (! JUCEApplication::isStandaloneApp()) + setAlwaysOnTop (true); // for a plugin, make it always-on-top because the host windows are often top-level + } + + void closeButtonPressed() + { + setVisible (false); + } + + private: + JUCE_DECLARE_NON_COPYABLE (TempDialogWindow); + }; + TempDialogWindow dw (dialogTitle, colour, escapeKeyTriggersCloseButton); dw.setContentComponent (contentComponent, true, true); @@ -97999,8 +98022,6 @@ ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); BEGIN_JUCE_NAMESPACE -// internal helper object that holds the zlib structures so they don't have to be -// included publicly. class GZIPCompressorOutputStream::GZIPCompressorHelper { public: @@ -98137,11 +98158,7 @@ bool GZIPCompressorOutputStream::write (const void* destBuffer, int howMany) bool GZIPCompressorOutputStream::doNextBlock() { const int len = helper->doNextBlock (buffer, (int) GZIPCompressorHelper::gzipCompBufferSize); - - if (len > 0) - return destStream->write (buffer, len); - else - return true; + return len <= 0 || destStream->write (buffer, len); } int64 GZIPCompressorOutputStream::getPosition() @@ -242963,8 +242980,6 @@ private: { } - ~JuceDropTarget() {} - HRESULT __stdcall DragEnter (IDataObject* pDataObject, DWORD /*grfKeyState*/, POINTL mousePos, DWORD* pdwEffect) { updateFileList (pDataObject); @@ -256089,10 +256104,10 @@ double Time::getMillisecondCounterHiRes() throw() bool Time::setSystemTimeToThisTime() const { timeval t; - t.tv_sec = millisSinceEpoch % 1000000; - t.tv_usec = millisSinceEpoch - t.tv_sec; + t.tv_sec = millisSinceEpoch / 1000; + t.tv_usec = (millisSinceEpoch - t.tv_sec * 1000) * 1000; - return settimeofday (&t, 0) ? false : true; + return settimeofday (&t, 0) == 0; } #endif @@ -273227,12 +273242,12 @@ BOOL NSViewComponentPeer::sendDragCallback (int type, id sender NSPoint p = [view convertPoint: [sender draggingLocation] fromView: nil]; const Point pos ((int) p.x, (int) ([view frame].size.height - p.y)); - StringArray files; - id list = [[sender draggingPasteboard] propertyListForType: bestType]; if (list == nil) return false; + StringArray files; + if ([list isKindOfClass: [NSArray class]]) { NSArray* items = (NSArray*) list; diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 806206b873..4099502d76 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -6882,8 +6882,23 @@ private: const ScopedPointer* getAddress() const throw() { return this; } #if ! JUCE_MSVC // (MSVC can't deal with multiple copy constructors) - // This is private to stop people accidentally copying a const ScopedPointer (the compiler - // will let you do so by implicitly casting the source to its raw object pointer). + /* This is private to stop people accidentally copying a const ScopedPointer (the compiler + would let you do so by implicitly casting the source to its raw object pointer). + + A side effect of this is that you may hit a puzzling compiler error when you write something + like this: + + ScopedPointer m = new MyClass(); // Compile error: copy constructor is private. + + Even though the compiler would normally ignore the assignment here, it can't do so when the + copy constructor is private. It's very easy to fis though - just write it like this: + + ScopedPointer m (new MyClass()); // Compiles OK + + It's good practice to always use the latter form when writing your object declarations anyway, + rather than writing them as assignments and assuming (or hoping) that the compiler will be + smart enough to replace your construction + assignment with a single constructor. + */ ScopedPointer (const ScopedPointer&); #endif }; diff --git a/src/containers/juce_ScopedPointer.h b/src/containers/juce_ScopedPointer.h index 9627d2d7eb..adfcbee426 100644 --- a/src/containers/juce_ScopedPointer.h +++ b/src/containers/juce_ScopedPointer.h @@ -167,8 +167,23 @@ private: const ScopedPointer* getAddress() const throw() { return this; } #if ! JUCE_MSVC // (MSVC can't deal with multiple copy constructors) - // This is private to stop people accidentally copying a const ScopedPointer (the compiler - // will let you do so by implicitly casting the source to its raw object pointer). + /* This is private to stop people accidentally copying a const ScopedPointer (the compiler + would let you do so by implicitly casting the source to its raw object pointer). + + A side effect of this is that you may hit a puzzling compiler error when you write something + like this: + + ScopedPointer m = new MyClass(); // Compile error: copy constructor is private. + + Even though the compiler would normally ignore the assignment here, it can't do so when the + copy constructor is private. It's very easy to fis though - just write it like this: + + ScopedPointer m (new MyClass()); // Compiles OK + + It's good practice to always use the latter form when writing your object declarations anyway, + rather than writing them as assignments and assuming (or hoping) that the compiler will be + smart enough to replace your construction + assignment with a single constructor. + */ ScopedPointer (const ScopedPointer&); #endif }; diff --git a/src/gui/components/windows/juce_ComponentPeer.cpp b/src/gui/components/windows/juce_ComponentPeer.cpp index 6146c9f516..f0606d8928 100644 --- a/src/gui/components/windows/juce_ComponentPeer.cpp +++ b/src/gui/components/windows/juce_ComponentPeer.cpp @@ -507,8 +507,31 @@ void ComponentPeer::handleFileDragDrop (const StringArray& files, const Point pos (targetComp->getLocalPoint (component, position)); - target->filesDropped (files, pos.getX(), pos.getY()); + // We'll use an async message to deliver the drop, because if the target decides + // to run a modal loop, it can gum-up the operating system.. + class AsyncFileDropMessage : public CallbackMessage + { + public: + AsyncFileDropMessage (Component* target_, const Point& position_, const StringArray& files_) + : target (target_), position (position_), files (files_) + { + } + + void messageCallback() + { + if (target != 0) + target->filesDropped (files, position.getX(), position.getY()); + } + + private: + Component::SafePointer target; + Point position; + StringArray files; + + JUCE_DECLARE_NON_COPYABLE (AsyncFileDropMessage); + }; + + (new AsyncFileDropMessage (targetComp, targetComp->getLocalPoint (component, position), files))->post(); } } } diff --git a/src/gui/components/windows/juce_DialogWindow.cpp b/src/gui/components/windows/juce_DialogWindow.cpp index 70f9ef76f4..fec6e322ea 100644 --- a/src/gui/components/windows/juce_DialogWindow.cpp +++ b/src/gui/components/windows/juce_DialogWindow.cpp @@ -62,25 +62,6 @@ void DialogWindow::resized() //============================================================================== -class TempDialogWindow : public DialogWindow -{ -public: - TempDialogWindow (const String& title, const Colour& colour, const bool escapeCloses) - : DialogWindow (title, colour, escapeCloses, true) - { - if (! JUCEApplication::isStandaloneApp()) - setAlwaysOnTop (true); // for a plugin, make it always-on-top because the host windows are often top-level - } - - void closeButtonPressed() - { - setVisible (false); - } - -private: - JUCE_DECLARE_NON_COPYABLE (TempDialogWindow); -}; - int DialogWindow::showModalDialog (const String& dialogTitle, Component* contentComponent, Component* componentToCentreAround, @@ -89,6 +70,25 @@ int DialogWindow::showModalDialog (const String& dialogTitle, const bool shouldBeResizable, const bool useBottomRightCornerResizer) { + class TempDialogWindow : public DialogWindow + { + public: + TempDialogWindow (const String& title, const Colour& colour, const bool escapeCloses) + : DialogWindow (title, colour, escapeCloses, true) + { + if (! JUCEApplication::isStandaloneApp()) + setAlwaysOnTop (true); // for a plugin, make it always-on-top because the host windows are often top-level + } + + void closeButtonPressed() + { + setVisible (false); + } + + private: + JUCE_DECLARE_NON_COPYABLE (TempDialogWindow); + }; + TempDialogWindow dw (dialogTitle, colour, escapeKeyTriggersCloseButton); dw.setContentComponent (contentComponent, true, true); diff --git a/src/gui/graphics/drawables/juce_DrawableComposite.h b/src/gui/graphics/drawables/juce_DrawableComposite.h index 45d9dd51ff..71d98cbcca 100644 --- a/src/gui/graphics/drawables/juce_DrawableComposite.h +++ b/src/gui/graphics/drawables/juce_DrawableComposite.h @@ -246,7 +246,6 @@ public: ValueTree getMarkerListCreating (bool xAxis, UndoManager* undoManager); }; - private: //============================================================================== RelativeParallelogram bounds; diff --git a/src/io/streams/juce_GZIPCompressorOutputStream.cpp b/src/io/streams/juce_GZIPCompressorOutputStream.cpp index f101123a50..b35269e6d6 100644 --- a/src/io/streams/juce_GZIPCompressorOutputStream.cpp +++ b/src/io/streams/juce_GZIPCompressorOutputStream.cpp @@ -43,8 +43,6 @@ BEGIN_JUCE_NAMESPACE //============================================================================== -// internal helper object that holds the zlib structures so they don't have to be -// included publicly. class GZIPCompressorOutputStream::GZIPCompressorHelper { public: @@ -130,7 +128,6 @@ public: bool finished, shouldFinish; }; - //============================================================================== GZIPCompressorOutputStream::GZIPCompressorOutputStream (OutputStream* const destStream_, int compressionLevel, @@ -184,11 +181,7 @@ bool GZIPCompressorOutputStream::write (const void* destBuffer, int howMany) bool GZIPCompressorOutputStream::doNextBlock() { const int len = helper->doNextBlock (buffer, (int) GZIPCompressorHelper::gzipCompBufferSize); - - if (len > 0) - return destStream->write (buffer, len); - else - return true; + return len <= 0 || destStream->write (buffer, len); } int64 GZIPCompressorOutputStream::getPosition() diff --git a/src/native/linux/juce_linux_SystemStats.cpp b/src/native/linux/juce_linux_SystemStats.cpp index f4d4e2cdc5..bb8ae0c268 100644 --- a/src/native/linux/juce_linux_SystemStats.cpp +++ b/src/native/linux/juce_linux_SystemStats.cpp @@ -185,10 +185,10 @@ double Time::getMillisecondCounterHiRes() throw() bool Time::setSystemTimeToThisTime() const { timeval t; - t.tv_sec = millisSinceEpoch % 1000000; - t.tv_usec = millisSinceEpoch - t.tv_sec; + t.tv_sec = millisSinceEpoch / 1000; + t.tv_usec = (millisSinceEpoch - t.tv_sec * 1000) * 1000; - return settimeofday (&t, 0) ? false : true; + return settimeofday (&t, 0) == 0; } diff --git a/src/native/mac/juce_mac_NSViewComponentPeer.mm b/src/native/mac/juce_mac_NSViewComponentPeer.mm index 5675ad996c..934781fbee 100644 --- a/src/native/mac/juce_mac_NSViewComponentPeer.mm +++ b/src/native/mac/juce_mac_NSViewComponentPeer.mm @@ -1504,12 +1504,12 @@ BOOL NSViewComponentPeer::sendDragCallback (int type, id sender NSPoint p = [view convertPoint: [sender draggingLocation] fromView: nil]; const Point pos ((int) p.x, (int) ([view frame].size.height - p.y)); - StringArray files; - id list = [[sender draggingPasteboard] propertyListForType: bestType]; if (list == nil) return false; + StringArray files; + if ([list isKindOfClass: [NSArray class]]) { NSArray* items = (NSArray*) list; diff --git a/src/native/windows/juce_win32_Windowing.cpp b/src/native/windows/juce_win32_Windowing.cpp index 77cc579c33..dea8140dd3 100644 --- a/src/native/windows/juce_win32_Windowing.cpp +++ b/src/native/windows/juce_win32_Windowing.cpp @@ -1850,8 +1850,6 @@ private: { } - ~JuceDropTarget() {} - HRESULT __stdcall DragEnter (IDataObject* pDataObject, DWORD /*grfKeyState*/, POINTL mousePos, DWORD* pdwEffect) { updateFileList (pDataObject);