Browse Source

Another batch of ScopedPointer cleanups

tags/2021-05-28
jules 7 years ago
parent
commit
48a5fbd333
74 changed files with 311 additions and 292 deletions
  1. +1
    -1
      modules/juce_audio_utils/native/juce_mac_AudioCDBurner.mm
  2. +1
    -1
      modules/juce_audio_utils/native/juce_win32_AudioCDBurner.cpp
  3. +1
    -1
      modules/juce_core/containers/juce_OwnedArray.h
  4. +2
    -2
      modules/juce_core/files/juce_DirectoryIterator.cpp
  5. +41
    -41
      modules/juce_core/javascript/juce_Javascript.cpp
  6. +1
    -1
      modules/juce_core/memory/juce_OptionalScopedPointer.h
  7. +3
    -3
      modules/juce_core/native/juce_posix_NamedPipe.cpp
  8. +1
    -1
      modules/juce_core/native/juce_posix_SharedCode.h
  9. +3
    -3
      modules/juce_core/native/juce_win32_Files.cpp
  10. +3
    -3
      modules/juce_core/native/juce_win32_Threads.cpp
  11. +1
    -1
      modules/juce_core/threads/juce_HighResolutionTimer.cpp
  12. +1
    -1
      modules/juce_data_structures/app_properties/juce_PropertiesFile.cpp
  13. +1
    -1
      modules/juce_dsp/frequency/juce_Convolution.cpp
  14. +2
    -2
      modules/juce_events/interprocess/juce_ConnectedChildProcess.cpp
  15. +4
    -4
      modules/juce_events/interprocess/juce_InterprocessConnection.cpp
  16. +1
    -1
      modules/juce_events/interprocess/juce_InterprocessConnectionServer.cpp
  17. +1
    -1
      modules/juce_events/messages/juce_ApplicationBase.cpp
  18. +1
    -1
      modules/juce_events/messages/juce_MessageManager.cpp
  19. +1
    -1
      modules/juce_events/native/juce_mac_MessageManager.mm
  20. +1
    -1
      modules/juce_events/native/juce_win32_Messaging.cpp
  21. +6
    -6
      modules/juce_graphics/colour/juce_FillType.cpp
  22. +3
    -3
      modules/juce_graphics/fonts/juce_TextLayout.cpp
  23. +1
    -1
      modules/juce_graphics/fonts/juce_Typeface.cpp
  24. +2
    -2
      modules/juce_graphics/native/juce_RenderingHelpers.h
  25. +2
    -2
      modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm
  26. +10
    -9
      modules/juce_gui_basics/buttons/juce_DrawableButton.cpp
  27. +1
    -1
      modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp
  28. +1
    -1
      modules/juce_gui_basics/commands/juce_KeyPressMappingSet.cpp
  29. +6
    -6
      modules/juce_gui_basics/components/juce_Component.cpp
  30. +31
    -40
      modules/juce_gui_basics/components/juce_Desktop.cpp
  31. +4
    -4
      modules/juce_gui_basics/components/juce_Desktop.h
  32. +1
    -1
      modules/juce_gui_basics/drawables/juce_Drawable.cpp
  33. +4
    -5
      modules/juce_gui_basics/drawables/juce_SVGParser.cpp
  34. +3
    -3
      modules/juce_gui_basics/filebrowser/juce_ContentSharer.cpp
  35. +1
    -1
      modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp
  36. +5
    -4
      modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp
  37. +5
    -5
      modules/juce_gui_basics/filebrowser/juce_FileChooser.cpp
  38. +2
    -2
      modules/juce_gui_basics/filebrowser/juce_FilenameComponent.cpp
  39. +1
    -1
      modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp
  40. +1
    -1
      modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp
  41. +2
    -1
      modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp
  42. +8
    -5
      modules/juce_gui_basics/layout/juce_ScrollBar.cpp
  43. +5
    -3
      modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp
  44. +2
    -1
      modules/juce_gui_basics/layout/juce_TabbedComponent.cpp
  45. +5
    -3
      modules/juce_gui_basics/layout/juce_Viewport.cpp
  46. +15
    -15
      modules/juce_gui_basics/menus/juce_PopupMenu.cpp
  47. +2
    -3
      modules/juce_gui_basics/misc/juce_JUCESplashScreen.cpp
  48. +3
    -3
      modules/juce_gui_basics/native/juce_mac_FileChooser.mm
  49. +3
    -3
      modules/juce_gui_basics/native/juce_mac_MainMenu.mm
  50. +2
    -2
      modules/juce_gui_basics/native/juce_mac_Windowing.mm
  51. +2
    -1
      modules/juce_gui_basics/widgets/juce_Label.cpp
  52. +4
    -3
      modules/juce_gui_basics/widgets/juce_ListBox.cpp
  53. +1
    -1
      modules/juce_gui_basics/widgets/juce_Slider.cpp
  54. +3
    -2
      modules/juce_gui_basics/widgets/juce_Toolbar.cpp
  55. +5
    -2
      modules/juce_gui_basics/widgets/juce_TreeView.cpp
  56. +7
    -7
      modules/juce_gui_basics/windows/juce_DocumentWindow.cpp
  57. +6
    -2
      modules/juce_gui_basics/windows/juce_ResizableWindow.cpp
  58. +6
    -7
      modules/juce_gui_basics/windows/juce_ThreadWithProgressWindow.cpp
  59. +1
    -1
      modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp
  60. +15
    -12
      modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp
  61. +30
    -22
      modules/juce_gui_extra/misc/juce_ColourSelector.cpp
  62. +2
    -2
      modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.cpp
  63. +1
    -1
      modules/juce_gui_extra/misc/juce_PreferencesPanel.cpp
  64. +1
    -1
      modules/juce_gui_extra/misc/juce_WebBrowserComponent.h
  65. +3
    -3
      modules/juce_gui_extra/native/juce_AndroidViewComponent.cpp
  66. +3
    -3
      modules/juce_gui_extra/native/juce_ios_UIViewComponent.mm
  67. +2
    -2
      modules/juce_gui_extra/native/juce_linux_X11_SystemTrayIcon.cpp
  68. +1
    -1
      modules/juce_gui_extra/native/juce_mac_SystemTrayIcon.cpp
  69. +4
    -5
      modules/juce_gui_extra/native/juce_mac_WebBrowserComponent.mm
  70. +2
    -2
      modules/juce_gui_extra/native/juce_win32_SystemTrayIcon.cpp
  71. +1
    -1
      modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp
  72. +1
    -1
      modules/juce_osc/osc/juce_OSCReceiver.cpp
  73. +1
    -1
      modules/juce_osc/osc/juce_OSCSender.cpp
  74. +1
    -1
      modules/juce_video/capture/juce_CameraDevice.cpp

+ 1
- 1
modules/juce_audio_utils/native/juce_mac_AudioCDBurner.mm View File

@@ -371,7 +371,7 @@ private:
//============================================================================== //==============================================================================
AudioCDBurner::AudioCDBurner (const int deviceIndex) AudioCDBurner::AudioCDBurner (const int deviceIndex)
{ {
pimpl = new Pimpl (*this, deviceIndex);
pimpl.reset (new Pimpl (*this, deviceIndex));
} }
AudioCDBurner::~AudioCDBurner() AudioCDBurner::~AudioCDBurner()


+ 1
- 1
modules/juce_audio_utils/native/juce_win32_AudioCDBurner.cpp View File

@@ -236,7 +236,7 @@ AudioCDBurner::AudioCDBurner (const int deviceIndex)
IDiscRecorder* discRecorder = CDBurnerHelpers::enumCDBurners (0, deviceIndex, &discMaster); IDiscRecorder* discRecorder = CDBurnerHelpers::enumCDBurners (0, deviceIndex, &discMaster);
if (discRecorder != nullptr) if (discRecorder != nullptr)
pimpl = new Pimpl (*this, discMaster, discRecorder);
pimpl.reset (new Pimpl (*this, discMaster, discRecorder));
} }
AudioCDBurner::~AudioCDBurner() AudioCDBurner::~AudioCDBurner()


+ 1
- 1
modules/juce_core/containers/juce_OwnedArray.h View File

@@ -409,7 +409,7 @@ public:
{ {
if (deleteOldElement) if (deleteOldElement)
{ {
toDelete = data.elements[indexToChange];
toDelete.reset (data.elements[indexToChange]);
if (toDelete == newObject) if (toDelete == newObject)
toDelete.release(); toDelete.release();


+ 2
- 2
modules/juce_core/files/juce_DirectoryIterator.cpp View File

@@ -95,8 +95,8 @@ bool DirectoryIterator::next (bool* isDirResult, bool* isHiddenResult, int64* fi
if (isDirectory) if (isDirectory)
{ {
if (isRecursive && ((whatToLookFor & File::ignoreHiddenFiles) == 0 || ! isHidden)) if (isRecursive && ((whatToLookFor & File::ignoreHiddenFiles) == 0 || ! isHidden))
subIterator = new DirectoryIterator (File::createFileWithoutCheckingPath (path + filename),
true, wildCard, whatToLookFor);
subIterator.reset (new DirectoryIterator (File::createFileWithoutCheckingPath (path + filename),
true, wildCard, whatToLookFor));
matches = (whatToLookFor & File::findDirectories) != 0; matches = (whatToLookFor & File::findDirectories) != 0;
} }


+ 41
- 41
modules/juce_core/javascript/juce_Javascript.cpp View File

@@ -1149,10 +1149,10 @@ struct JavascriptEngine::RootObject : public DynamicObject
{ {
ScopedPointer<IfStatement> s (new IfStatement (location)); ScopedPointer<IfStatement> s (new IfStatement (location));
match (TokenTypes::openParen); match (TokenTypes::openParen);
s->condition = parseExpression();
s->condition.reset (parseExpression());
match (TokenTypes::closeParen); match (TokenTypes::closeParen);
s->trueBranch = parseStatement();
s->falseBranch = matchIf (TokenTypes::else_) ? parseStatement() : new Statement (location);
s->trueBranch.reset (parseStatement());
s->falseBranch.reset (matchIf (TokenTypes::else_) ? parseStatement() : new Statement (location));
return s.release(); return s.release();
} }
@@ -1170,7 +1170,7 @@ struct JavascriptEngine::RootObject : public DynamicObject
{ {
ScopedPointer<VarStatement> s (new VarStatement (location)); ScopedPointer<VarStatement> s (new VarStatement (location));
s->name = parseIdentifier(); s->name = parseIdentifier();
s->initialiser = matchIf (TokenTypes::assign) ? parseExpression() : new Expression (location);
s->initialiser.reset (matchIf (TokenTypes::assign) ? parseExpression() : new Expression (location));
if (matchIf (TokenTypes::comma)) if (matchIf (TokenTypes::comma))
{ {
@@ -1200,46 +1200,46 @@ struct JavascriptEngine::RootObject : public DynamicObject
{ {
ScopedPointer<LoopStatement> s (new LoopStatement (location, false)); ScopedPointer<LoopStatement> s (new LoopStatement (location, false));
match (TokenTypes::openParen); match (TokenTypes::openParen);
s->initialiser = parseStatement();
s->initialiser.reset (parseStatement());
if (matchIf (TokenTypes::semicolon)) if (matchIf (TokenTypes::semicolon))
s->condition = new LiteralValue (location, true);
s->condition.reset (new LiteralValue (location, true));
else else
{ {
s->condition = parseExpression();
s->condition.reset (parseExpression());
match (TokenTypes::semicolon); match (TokenTypes::semicolon);
} }
if (matchIf (TokenTypes::closeParen)) if (matchIf (TokenTypes::closeParen))
s->iterator = new Statement (location);
s->iterator.reset (new Statement (location));
else else
{ {
s->iterator = parseExpression();
s->iterator.reset (parseExpression());
match (TokenTypes::closeParen); match (TokenTypes::closeParen);
} }
s->body = parseStatement();
s->body.reset (parseStatement());
return s.release(); return s.release();
} }
Statement* parseDoOrWhileLoop (bool isDoLoop) Statement* parseDoOrWhileLoop (bool isDoLoop)
{ {
ScopedPointer<LoopStatement> s (new LoopStatement (location, isDoLoop)); ScopedPointer<LoopStatement> s (new LoopStatement (location, isDoLoop));
s->initialiser = new Statement (location);
s->iterator = new Statement (location);
s->initialiser.reset (new Statement (location));
s->iterator.reset (new Statement (location));
if (isDoLoop) if (isDoLoop)
{ {
s->body = parseBlock();
s->body.reset (parseBlock());
match (TokenTypes::while_); match (TokenTypes::while_);
} }
match (TokenTypes::openParen); match (TokenTypes::openParen);
s->condition = parseExpression();
s->condition.reset (parseExpression());
match (TokenTypes::closeParen); match (TokenTypes::closeParen);
if (! isDoLoop) if (! isDoLoop)
s->body = parseStatement();
s->body.reset (parseStatement());
return s.release(); return s.release();
} }
@@ -1297,7 +1297,7 @@ struct JavascriptEngine::RootObject : public DynamicObject
{ {
ScopedPointer<ArraySubscript> s (new ArraySubscript (location)); ScopedPointer<ArraySubscript> s (new ArraySubscript (location));
s->object = input; s->object = input;
s->index = parseExpression();
s->index.reset (parseExpression());
match (TokenTypes::closeBracket); match (TokenTypes::closeBracket);
return parseSuffixes (s.release()); return parseSuffixes (s.release());
} }
@@ -1377,7 +1377,7 @@ struct JavascriptEngine::RootObject : public DynamicObject
ExpPtr name (new UnqualifiedName (location, parseIdentifier())); ExpPtr name (new UnqualifiedName (location, parseIdentifier()));
while (matchIf (TokenTypes::dot)) while (matchIf (TokenTypes::dot))
name = new DotOperator (location, name, parseIdentifier());
name.reset (new DotOperator (location, name, parseIdentifier()));
return parseFunctionCall (new NewOperator (location), name); return parseFunctionCall (new NewOperator (location), name);
} }
@@ -1405,7 +1405,7 @@ struct JavascriptEngine::RootObject : public DynamicObject
Expression* parseTypeof() Expression* parseTypeof()
{ {
ScopedPointer<FunctionCall> f (new FunctionCall (location)); ScopedPointer<FunctionCall> f (new FunctionCall (location));
f->object = new UnqualifiedName (location, "typeof");
f->object.reset (new UnqualifiedName (location, "typeof"));
f->arguments.add (parseUnary()); f->arguments.add (parseUnary());
return f.release(); return f.release();
} }
@@ -1427,9 +1427,9 @@ struct JavascriptEngine::RootObject : public DynamicObject
for (;;) for (;;)
{ {
if (matchIf (TokenTypes::times)) { ExpPtr b (parseUnary()); a = new MultiplyOp (location, a, b); }
else if (matchIf (TokenTypes::divide)) { ExpPtr b (parseUnary()); a = new DivideOp (location, a, b); }
else if (matchIf (TokenTypes::modulo)) { ExpPtr b (parseUnary()); a = new ModuloOp (location, a, b); }
if (matchIf (TokenTypes::times)) { ExpPtr b (parseUnary()); a.reset (new MultiplyOp (location, a, b)); }
else if (matchIf (TokenTypes::divide)) { ExpPtr b (parseUnary()); a.reset (new DivideOp (location, a, b)); }
else if (matchIf (TokenTypes::modulo)) { ExpPtr b (parseUnary()); a.reset (new ModuloOp (location, a, b)); }
else break; else break;
} }
@@ -1442,8 +1442,8 @@ struct JavascriptEngine::RootObject : public DynamicObject
for (;;) for (;;)
{ {
if (matchIf (TokenTypes::plus)) { ExpPtr b (parseMultiplyDivide()); a = new AdditionOp (location, a, b); }
else if (matchIf (TokenTypes::minus)) { ExpPtr b (parseMultiplyDivide()); a = new SubtractionOp (location, a, b); }
if (matchIf (TokenTypes::plus)) { ExpPtr b (parseMultiplyDivide()); a.reset (new AdditionOp (location, a, b)); }
else if (matchIf (TokenTypes::minus)) { ExpPtr b (parseMultiplyDivide()); a.reset (new SubtractionOp (location, a, b)); }
else break; else break;
} }
@@ -1456,9 +1456,9 @@ struct JavascriptEngine::RootObject : public DynamicObject
for (;;) for (;;)
{ {
if (matchIf (TokenTypes::leftShift)) { ExpPtr b (parseExpression()); a = new LeftShiftOp (location, a, b); }
else if (matchIf (TokenTypes::rightShift)) { ExpPtr b (parseExpression()); a = new RightShiftOp (location, a, b); }
else if (matchIf (TokenTypes::rightShiftUnsigned)) { ExpPtr b (parseExpression()); a = new RightShiftUnsignedOp (location, a, b); }
if (matchIf (TokenTypes::leftShift)) { ExpPtr b (parseExpression()); a.reset (new LeftShiftOp (location, a, b)); }
else if (matchIf (TokenTypes::rightShift)) { ExpPtr b (parseExpression()); a.reset (new RightShiftOp (location, a, b)); }
else if (matchIf (TokenTypes::rightShiftUnsigned)) { ExpPtr b (parseExpression()); a.reset (new RightShiftUnsignedOp (location, a, b)); }
else break; else break;
} }
@@ -1471,14 +1471,14 @@ struct JavascriptEngine::RootObject : public DynamicObject
for (;;) for (;;)
{ {
if (matchIf (TokenTypes::equals)) { ExpPtr b (parseShiftOperator()); a = new EqualsOp (location, a, b); }
else if (matchIf (TokenTypes::notEquals)) { ExpPtr b (parseShiftOperator()); a = new NotEqualsOp (location, a, b); }
else if (matchIf (TokenTypes::typeEquals)) { ExpPtr b (parseShiftOperator()); a = new TypeEqualsOp (location, a, b); }
else if (matchIf (TokenTypes::typeNotEquals)) { ExpPtr b (parseShiftOperator()); a = new TypeNotEqualsOp (location, a, b); }
else if (matchIf (TokenTypes::lessThan)) { ExpPtr b (parseShiftOperator()); a = new LessThanOp (location, a, b); }
else if (matchIf (TokenTypes::lessThanOrEqual)) { ExpPtr b (parseShiftOperator()); a = new LessThanOrEqualOp (location, a, b); }
else if (matchIf (TokenTypes::greaterThan)) { ExpPtr b (parseShiftOperator()); a = new GreaterThanOp (location, a, b); }
else if (matchIf (TokenTypes::greaterThanOrEqual)) { ExpPtr b (parseShiftOperator()); a = new GreaterThanOrEqualOp (location, a, b); }
if (matchIf (TokenTypes::equals)) { ExpPtr b (parseShiftOperator()); a.reset (new EqualsOp (location, a, b)); }
else if (matchIf (TokenTypes::notEquals)) { ExpPtr b (parseShiftOperator()); a.reset (new NotEqualsOp (location, a, b)); }
else if (matchIf (TokenTypes::typeEquals)) { ExpPtr b (parseShiftOperator()); a.reset (new TypeEqualsOp (location, a, b)); }
else if (matchIf (TokenTypes::typeNotEquals)) { ExpPtr b (parseShiftOperator()); a.reset (new TypeNotEqualsOp (location, a, b)); }
else if (matchIf (TokenTypes::lessThan)) { ExpPtr b (parseShiftOperator()); a.reset (new LessThanOp (location, a, b)); }
else if (matchIf (TokenTypes::lessThanOrEqual)) { ExpPtr b (parseShiftOperator()); a.reset (new LessThanOrEqualOp (location, a, b)); }
else if (matchIf (TokenTypes::greaterThan)) { ExpPtr b (parseShiftOperator()); a.reset (new GreaterThanOp (location, a, b)); }
else if (matchIf (TokenTypes::greaterThanOrEqual)) { ExpPtr b (parseShiftOperator()); a.reset (new GreaterThanOrEqualOp (location, a, b)); }
else break; else break;
} }
@@ -1491,11 +1491,11 @@ struct JavascriptEngine::RootObject : public DynamicObject
for (;;) for (;;)
{ {
if (matchIf (TokenTypes::logicalAnd)) { ExpPtr b (parseComparator()); a = new LogicalAndOp (location, a, b); }
else if (matchIf (TokenTypes::logicalOr)) { ExpPtr b (parseComparator()); a = new LogicalOrOp (location, a, b); }
else if (matchIf (TokenTypes::bitwiseAnd)) { ExpPtr b (parseComparator()); a = new BitwiseAndOp (location, a, b); }
else if (matchIf (TokenTypes::bitwiseOr)) { ExpPtr b (parseComparator()); a = new BitwiseOrOp (location, a, b); }
else if (matchIf (TokenTypes::bitwiseXor)) { ExpPtr b (parseComparator()); a = new BitwiseXorOp (location, a, b); }
if (matchIf (TokenTypes::logicalAnd)) { ExpPtr b (parseComparator()); a.reset (new LogicalAndOp (location, a, b)); }
else if (matchIf (TokenTypes::logicalOr)) { ExpPtr b (parseComparator()); a.reset (new LogicalOrOp (location, a, b)); }
else if (matchIf (TokenTypes::bitwiseAnd)) { ExpPtr b (parseComparator()); a.reset (new BitwiseAndOp (location, a, b)); }
else if (matchIf (TokenTypes::bitwiseOr)) { ExpPtr b (parseComparator()); a.reset (new BitwiseOrOp (location, a, b)); }
else if (matchIf (TokenTypes::bitwiseXor)) { ExpPtr b (parseComparator()); a.reset (new BitwiseXorOp (location, a, b)); }
else break; else break;
} }
@@ -1506,9 +1506,9 @@ struct JavascriptEngine::RootObject : public DynamicObject
{ {
ScopedPointer<ConditionalOp> e (new ConditionalOp (location)); ScopedPointer<ConditionalOp> e (new ConditionalOp (location));
e->condition = condition; e->condition = condition;
e->trueBranch = parseExpression();
e->trueBranch.reset (parseExpression());
match (TokenTypes::colon); match (TokenTypes::colon);
e->falseBranch = parseExpression();
e->falseBranch.reset (parseExpression());
return e.release(); return e.release();
} }


+ 1
- 1
modules/juce_core/memory/juce_OptionalScopedPointer.h View File

@@ -139,7 +139,7 @@ public:
if (object.get() != newObject) if (object.get() != newObject)
{ {
reset(); reset();
object = newObject;
object.reset (newObject);
} }
shouldDelete = takeOwnership; shouldDelete = takeOwnership;


+ 3
- 3
modules/juce_core/native/juce_posix_NamedPipe.cpp View File

@@ -198,15 +198,15 @@ void NamedPipe::close()
bool NamedPipe::openInternal (const String& pipeName, const bool createPipe, bool mustNotExist) bool NamedPipe::openInternal (const String& pipeName, const bool createPipe, bool mustNotExist)
{ {
#if JUCE_IOS #if JUCE_IOS
pimpl = new Pimpl (File::getSpecialLocation (File::tempDirectory)
.getChildFile (File::createLegalFileName (pipeName)).getFullPathName(), createPipe);
pimpl.reset (new Pimpl (File::getSpecialLocation (File::tempDirectory)
.getChildFile (File::createLegalFileName (pipeName)).getFullPathName(), createPipe));
#else #else
String file (pipeName); String file (pipeName);
if (! File::isAbsolutePath (file)) if (! File::isAbsolutePath (file))
file = "/tmp/" + File::createLegalFileName (file); file = "/tmp/" + File::createLegalFileName (file);
pimpl = new Pimpl (file, createPipe);
pimpl.reset (new Pimpl (file, createPipe));
#endif #endif
if (createPipe && ! pimpl->createFifos (mustNotExist)) if (createPipe && ! pimpl->createFifos (mustNotExist))


+ 1
- 1
modules/juce_core/native/juce_posix_SharedCode.h View File

@@ -877,7 +877,7 @@ bool InterProcessLock::enter (const int timeOutMillisecs)
if (pimpl == nullptr) if (pimpl == nullptr)
{ {
pimpl = new Pimpl (name, timeOutMillisecs);
pimpl.reset (new Pimpl (name, timeOutMillisecs));
if (pimpl->handle == 0) if (pimpl->handle == 0)
pimpl.reset(); pimpl.reset();


+ 3
- 3
modules/juce_core/native/juce_win32_Files.cpp View File

@@ -1051,17 +1051,17 @@ void NamedPipe::close()
SetEvent (pimpl->cancelEvent); SetEvent (pimpl->cancelEvent);
ScopedWriteLock sl (lock); ScopedWriteLock sl (lock);
pimpl = nullptr;
pimpl.reset();
} }
} }
bool NamedPipe::openInternal (const String& pipeName, const bool createPipe, bool mustNotExist) bool NamedPipe::openInternal (const String& pipeName, const bool createPipe, bool mustNotExist)
{ {
pimpl = new Pimpl (pipeName, createPipe, mustNotExist);
pimpl.reset (new Pimpl (pipeName, createPipe, mustNotExist));
if (createPipe && pimpl->pipeH == INVALID_HANDLE_VALUE) if (createPipe && pimpl->pipeH == INVALID_HANDLE_VALUE)
{ {
pimpl = nullptr;
pimpl.reset();
return false; return false;
} }


+ 3
- 3
modules/juce_core/native/juce_win32_Threads.cpp View File

@@ -380,10 +380,10 @@ bool InterProcessLock::enter (const int timeOutMillisecs)
if (pimpl == nullptr) if (pimpl == nullptr)
{ {
pimpl = new Pimpl (name, timeOutMillisecs);
pimpl.reset (new Pimpl (name, timeOutMillisecs));
if (pimpl->handle == 0) if (pimpl->handle == 0)
pimpl = nullptr;
pimpl.reset();
} }
else else
{ {
@@ -401,7 +401,7 @@ void InterProcessLock::exit()
jassert (pimpl != nullptr); jassert (pimpl != nullptr);
if (pimpl != nullptr && --(pimpl->refCount) == 0) if (pimpl != nullptr && --(pimpl->refCount) == 0)
pimpl = nullptr;
pimpl.reset();
} }
//============================================================================== //==============================================================================


+ 1
- 1
modules/juce_core/threads/juce_HighResolutionTimer.cpp View File

@@ -23,7 +23,7 @@
namespace juce namespace juce
{ {
HighResolutionTimer::HighResolutionTimer() { pimpl = new Pimpl (*this); }
HighResolutionTimer::HighResolutionTimer() { pimpl.reset (new Pimpl (*this)); }
HighResolutionTimer::~HighResolutionTimer() { stopTimer(); } HighResolutionTimer::~HighResolutionTimer() { stopTimer(); }
void HighResolutionTimer::startTimer (int periodMs) { pimpl->start (jmax (1, periodMs)); } void HighResolutionTimer::startTimer (int periodMs) { pimpl->start (jmax (1, periodMs)); }


+ 1
- 1
modules/juce_data_structures/app_properties/juce_PropertiesFile.cpp View File

@@ -188,7 +188,7 @@ bool PropertiesFile::loadAsXml()
if (doc != nullptr && doc->hasTagName (PropertyFileConstants::fileTag)) if (doc != nullptr && doc->hasTagName (PropertyFileConstants::fileTag))
{ {
doc = parser.getDocumentElement();
doc.reset (parser.getDocumentElement());
if (doc != nullptr) if (doc != nullptr)
{ {


+ 1
- 1
modules/juce_dsp/frequency/juce_Convolution.cpp View File

@@ -1004,7 +1004,7 @@ private:
//============================================================================== //==============================================================================
Convolution::Convolution() Convolution::Convolution()
{ {
pimpl = new Pimpl();
pimpl.reset (new Pimpl());
pimpl->addToFifo (Convolution::Pimpl::ChangeRequest::changeEngine, juce::var (0)); pimpl->addToFifo (Convolution::Pimpl::ChangeRequest::changeEngine, juce::var (0));
} }


+ 2
- 2
modules/juce_events/interprocess/juce_ConnectedChildProcess.cpp View File

@@ -153,7 +153,7 @@ bool ChildProcessMaster::launchSlaveProcess (const File& executable, const Strin
if (childProcess->start (args, streamFlags)) if (childProcess->start (args, streamFlags))
{ {
connection = new Connection (*this, pipeName, timeoutMs <= 0 ? defaultTimeoutMs : timeoutMs);
connection.reset (new Connection (*this, pipeName, timeoutMs <= 0 ? defaultTimeoutMs : timeoutMs));
if (connection->isConnected()) if (connection->isConnected())
{ {
@@ -254,7 +254,7 @@ bool ChildProcessSlave::initialiseFromCommandLine (const String& commandLine,
if (pipeName.isNotEmpty()) if (pipeName.isNotEmpty())
{ {
connection = new Connection (*this, pipeName, timeoutMs <= 0 ? defaultTimeoutMs : timeoutMs);
connection.reset (new Connection (*this, pipeName, timeoutMs <= 0 ? defaultTimeoutMs : timeoutMs));
if (! connection->isConnected()) if (! connection->isConnected())
connection.reset(); connection.reset();


+ 4
- 4
modules/juce_events/interprocess/juce_InterprocessConnection.cpp View File

@@ -37,7 +37,7 @@ InterprocessConnection::InterprocessConnection (bool callbacksOnMessageThread, u
: useMessageThread (callbacksOnMessageThread), : useMessageThread (callbacksOnMessageThread),
magicMessageHeader (magicMessageHeaderNumber) magicMessageHeader (magicMessageHeaderNumber)
{ {
thread = new ConnectionThread (*this);
thread.reset (new ConnectionThread (*this));
} }
InterprocessConnection::~InterprocessConnection() InterprocessConnection::~InterprocessConnection()
@@ -56,7 +56,7 @@ bool InterprocessConnection::connectToSocket (const String& hostName,
disconnect(); disconnect();
const ScopedLock sl (pipeAndSocketLock); const ScopedLock sl (pipeAndSocketLock);
socket = new StreamingSocket();
socket.reset (new StreamingSocket());
if (socket->connect (hostName, portNumber, timeOutMillisecs)) if (socket->connect (hostName, portNumber, timeOutMillisecs))
{ {
@@ -179,7 +179,7 @@ int InterprocessConnection::writeData (void* data, int dataSize)
void InterprocessConnection::initialiseWithSocket (StreamingSocket* newSocket) void InterprocessConnection::initialiseWithSocket (StreamingSocket* newSocket)
{ {
jassert (socket == nullptr && pipe == nullptr); jassert (socket == nullptr && pipe == nullptr);
socket = newSocket;
socket.reset (newSocket);
connectionMadeInt(); connectionMadeInt();
thread->startThread(); thread->startThread();
} }
@@ -187,7 +187,7 @@ void InterprocessConnection::initialiseWithSocket (StreamingSocket* newSocket)
void InterprocessConnection::initialiseWithPipe (NamedPipe* newPipe) void InterprocessConnection::initialiseWithPipe (NamedPipe* newPipe)
{ {
jassert (socket == nullptr && pipe == nullptr); jassert (socket == nullptr && pipe == nullptr);
pipe = newPipe;
pipe.reset (newPipe);
connectionMadeInt(); connectionMadeInt();
thread->startThread(); thread->startThread();
} }


+ 1
- 1
modules/juce_events/interprocess/juce_InterprocessConnectionServer.cpp View File

@@ -37,7 +37,7 @@ bool InterprocessConnectionServer::beginWaitingForSocket (const int portNumber,
{ {
stop(); stop();
socket = new StreamingSocket();
socket.reset (new StreamingSocket());
if (socket->createListener (portNumber, bindAddress)) if (socket->createListener (portNumber, bindAddress))
{ {


+ 1
- 1
modules/juce_events/messages/juce_ApplicationBase.cpp View File

@@ -134,7 +134,7 @@ bool JUCEApplicationBase::sendCommandLineToPreexistingInstance()
{ {
jassert (multipleInstanceHandler == nullptr); // this must only be called once! jassert (multipleInstanceHandler == nullptr); // this must only be called once!
multipleInstanceHandler = new MultipleInstanceHandler (getApplicationName());
multipleInstanceHandler.reset (new MultipleInstanceHandler (getApplicationName()));
return multipleInstanceHandler->sendCommandLineToPreexistingInstance(); return multipleInstanceHandler->sendCommandLineToPreexistingInstance();
} }


+ 1
- 1
modules/juce_events/messages/juce_MessageManager.cpp View File

@@ -194,7 +194,7 @@ void MessageManager::deliverBroadcastMessage (const String& value)
void MessageManager::registerBroadcastListener (ActionListener* const listener) void MessageManager::registerBroadcastListener (ActionListener* const listener)
{ {
if (broadcaster == nullptr) if (broadcaster == nullptr)
broadcaster = new ActionBroadcaster();
broadcaster.reset (new ActionBroadcaster());
broadcaster->addActionListener (listener); broadcaster->addActionListener (listener);
} }


+ 1
- 1
modules/juce_events/native/juce_mac_MessageManager.mm View File

@@ -514,7 +514,7 @@ private:
}; };
}; };
MountedVolumeListChangeDetector::MountedVolumeListChangeDetector() { pimpl = new Pimpl (*this); }
MountedVolumeListChangeDetector::MountedVolumeListChangeDetector() { pimpl.reset (new Pimpl (*this)); }
MountedVolumeListChangeDetector::~MountedVolumeListChangeDetector() {} MountedVolumeListChangeDetector::~MountedVolumeListChangeDetector() {}
#endif #endif


+ 1
- 1
modules/juce_events/native/juce_win32_Messaging.cpp View File

@@ -234,7 +234,7 @@ struct MountedVolumeListChangeDetector::Pimpl : private DeviceChangeDetector
Array<File> lastVolumeList; Array<File> lastVolumeList;
}; };
MountedVolumeListChangeDetector::MountedVolumeListChangeDetector() { pimpl = new Pimpl (*this); }
MountedVolumeListChangeDetector::MountedVolumeListChangeDetector() { pimpl.reset (new Pimpl (*this)); }
MountedVolumeListChangeDetector::~MountedVolumeListChangeDetector() {} MountedVolumeListChangeDetector::~MountedVolumeListChangeDetector() {}
} // namespace juce } // namespace juce

+ 6
- 6
modules/juce_graphics/colour/juce_FillType.cpp View File

@@ -65,7 +65,7 @@ FillType& FillType::operator= (const FillType& other)
if (this != &other) if (this != &other)
{ {
colour = other.colour; colour = other.colour;
gradient = other.gradient.createCopy();
gradient.reset (other.gradient.createCopy());
image = other.image; image = other.image;
transform = other.transform; transform = other.transform;
} }
@@ -75,7 +75,7 @@ FillType& FillType::operator= (const FillType& other)
FillType::FillType (FillType&& other) noexcept FillType::FillType (FillType&& other) noexcept
: colour (other.colour), : colour (other.colour),
gradient (other.gradient.release()),
gradient (static_cast<ScopedPointer<ColourGradient>&&> (other.gradient)),
image (static_cast<Image&&> (other.image)), image (static_cast<Image&&> (other.image)),
transform (other.transform) transform (other.transform)
{ {
@@ -86,7 +86,7 @@ FillType& FillType::operator= (FillType&& other) noexcept
jassert (this != &other); // hopefully the compiler should make this situation impossible! jassert (this != &other); // hopefully the compiler should make this situation impossible!
colour = other.colour; colour = other.colour;
gradient = other.gradient.release();
gradient = static_cast<ScopedPointer<ColourGradient>&&> (other.gradient);
image = static_cast<Image&&> (other.image); image = static_cast<Image&&> (other.image);
transform = other.transform; transform = other.transform;
return *this; return *this;
@@ -112,7 +112,7 @@ bool FillType::operator!= (const FillType& other) const
void FillType::setColour (Colour newColour) noexcept void FillType::setColour (Colour newColour) noexcept
{ {
gradient.reset(); gradient.reset();
image = Image();
image = {};
colour = newColour; colour = newColour;
} }
@@ -124,8 +124,8 @@ void FillType::setGradient (const ColourGradient& newGradient)
} }
else else
{ {
image = Image();
gradient = new ColourGradient (newGradient);
image = {};
gradient.reset (new ColourGradient (newGradient));
colour = Colours::black; colour = Colours::black;
} }
} }


+ 3
- 3
modules/juce_graphics/fonts/juce_TextLayout.cpp View File

@@ -363,8 +363,8 @@ namespace TextLayoutHelpers
Array<float> xOffsets; Array<float> xOffsets;
t.font.getGlyphPositions (getTrimmedEndIfNotAllWhitespace (t.text), newGlyphs, xOffsets); t.font.getGlyphPositions (getTrimmedEndIfNotAllWhitespace (t.text), newGlyphs, xOffsets);
if (currentRun == nullptr) currentRun = new TextLayout::Run();
if (currentLine == nullptr) currentLine = new TextLayout::Line();
if (currentRun == nullptr) currentRun .reset (new TextLayout::Run());
if (currentLine == nullptr) currentLine.reset (new TextLayout::Line());
if (newGlyphs.size() > 0) if (newGlyphs.size() > 0)
{ {
@@ -404,7 +404,7 @@ namespace TextLayoutHelpers
if (t.line != nextToken->line) if (t.line != nextToken->line)
{ {
if (currentRun == nullptr) if (currentRun == nullptr)
currentRun = new TextLayout::Run();
currentRun.reset (new TextLayout::Run());
addRun (*currentLine, currentRun.release(), t, runStartPosition, charPosition); addRun (*currentLine, currentRun.release(), t, runStartPosition, charPosition);
currentLine->stringRange = { lineStartPosition, charPosition }; currentLine->stringRange = { lineStartPosition, charPosition };


+ 1
- 1
modules/juce_graphics/fonts/juce_Typeface.cpp View File

@@ -258,7 +258,7 @@ void Typeface::applyVerticalHintingTransform (float fontSize, Path& path)
ScopedLock sl (hintingLock); ScopedLock sl (hintingLock);
if (hintingParams == nullptr) if (hintingParams == nullptr)
hintingParams = new HintingParams (*this);
hintingParams.reset (new HintingParams (*this));
return hintingParams->applyVerticalHintingTransform (fontSize, path); return hintingParams->applyVerticalHintingTransform (fontSize, path);
} }


+ 2
- 2
modules/juce_graphics/native/juce_RenderingHelpers.h View File

@@ -2676,7 +2676,7 @@ public:
{ {
if (auto* top = stack.getLast()) if (auto* top = stack.getLast())
{ {
currentState = top;
currentState.reset (top);
stack.removeLast (1, false); stack.removeLast (1, false);
} }
else else
@@ -2688,7 +2688,7 @@ public:
void beginTransparencyLayer (float opacity) void beginTransparencyLayer (float opacity)
{ {
save(); save();
currentState = currentState->beginTransparencyLayer (opacity);
currentState.reset (currentState->beginTransparencyLayer (opacity));
} }
void endTransparencyLayer() void endTransparencyLayer()


+ 2
- 2
modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm View File

@@ -341,9 +341,9 @@ void CoreGraphicsContext::restoreState()
{ {
CGContextRestoreGState (context); CGContextRestoreGState (context);
if (SavedState* const top = stateStack.getLast())
if (auto* top = stateStack.getLast())
{ {
state = top;
state.reset (top);
stateStack.removeLast (1, false); stateStack.removeLast (1, false);
lastClipRectIsValid = false; lastClipRectIsValid = false;
} }


+ 10
- 9
modules/juce_gui_basics/buttons/juce_DrawableButton.cpp View File

@@ -53,15 +53,16 @@ void DrawableButton::setImages (const Drawable* normal,
{ {
jassert (normal != nullptr); // you really need to give it at least a normal image.. jassert (normal != nullptr); // you really need to give it at least a normal image..
normalImage = copyDrawableIfNotNull (normal);
overImage = copyDrawableIfNotNull (over);
downImage = copyDrawableIfNotNull (down);
disabledImage = copyDrawableIfNotNull (disabled);
normalImageOn = copyDrawableIfNotNull (normalOn);
overImageOn = copyDrawableIfNotNull (overOn);
downImageOn = copyDrawableIfNotNull (downOn);
disabledImageOn = copyDrawableIfNotNull (disabledOn);
currentImage = nullptr;
normalImage .reset (copyDrawableIfNotNull (normal));
overImage .reset (copyDrawableIfNotNull (over));
downImage .reset (copyDrawableIfNotNull (down));
disabledImage .reset (copyDrawableIfNotNull (disabled));
normalImageOn .reset (copyDrawableIfNotNull (normalOn));
overImageOn .reset (copyDrawableIfNotNull (overOn));
downImageOn .reset (copyDrawableIfNotNull (downOn));
disabledImageOn .reset (copyDrawableIfNotNull (disabledOn));
currentImage = nullptr;
buttonStateChanged(); buttonStateChanged();
} }


+ 1
- 1
modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp View File

@@ -29,7 +29,7 @@ namespace juce
ApplicationCommandManager::ApplicationCommandManager() ApplicationCommandManager::ApplicationCommandManager()
{ {
keyMappings = new KeyPressMappingSet (*this);
keyMappings.reset (new KeyPressMappingSet (*this));
Desktop::getInstance().addFocusChangeListener (this); Desktop::getInstance().addFocusChangeListener (this);
} }


+ 1
- 1
modules/juce_gui_basics/commands/juce_KeyPressMappingSet.cpp View File

@@ -261,7 +261,7 @@ XmlElement* KeyPressMappingSet::createXml (const bool saveDifferencesFromDefault
if (saveDifferencesFromDefaultSet) if (saveDifferencesFromDefaultSet)
{ {
defaultSet = new KeyPressMappingSet (commandManager);
defaultSet.reset (new KeyPressMappingSet (commandManager));
defaultSet->resetToDefaultMappings(); defaultSet->resetToDefaultMappings();
} }


+ 6
- 6
modules/juce_gui_basics/components/juce_Component.cpp View File

@@ -832,7 +832,7 @@ void Component::setCachedComponentImage (CachedComponentImage* newCachedImage)
{ {
if (cachedImage != newCachedImage) if (cachedImage != newCachedImage)
{ {
cachedImage = newCachedImage;
cachedImage.reset (newCachedImage);
repaint(); repaint();
} }
} }
@@ -848,7 +848,7 @@ void Component::setBufferedToImage (bool shouldBeBuffered)
if (shouldBeBuffered) if (shouldBeBuffered)
{ {
if (cachedImage == nullptr) if (cachedImage == nullptr)
cachedImage = new StandardCachedComponentImage (*this);
cachedImage.reset (new StandardCachedComponentImage (*this));
} }
else else
{ {
@@ -1267,7 +1267,7 @@ void Component::setTransform (const AffineTransform& newTransform)
else if (affineTransform == nullptr) else if (affineTransform == nullptr)
{ {
repaint(); repaint();
affineTransform = new AffineTransform (newTransform);
affineTransform.reset (new AffineTransform (newTransform));
repaint(); repaint();
sendMovedResizedMessages (false, false); sendMovedResizedMessages (false, false);
} }
@@ -2154,7 +2154,7 @@ void Component::setPositioner (Positioner* newPositioner)
{ {
// You can only assign a positioner to the component that it was created for! // You can only assign a positioner to the component that it was created for!
jassert (newPositioner == nullptr || this == &(newPositioner->getComponent())); jassert (newPositioner == nullptr || this == &(newPositioner->getComponent()));
positioner = newPositioner;
positioner.reset (newPositioner);
} }
//============================================================================== //==============================================================================
@@ -2263,7 +2263,7 @@ void Component::addMouseListener (MouseListener* newListener,
jassert ((newListener != this) || wantsEventsForAllNestedChildComponents); jassert ((newListener != this) || wantsEventsForAllNestedChildComponents);
if (mouseListeners == nullptr) if (mouseListeners == nullptr)
mouseListeners = new MouseListenerList();
mouseListeners.reset (new MouseListenerList());
mouseListeners->addListener (newListener, wantsEventsForAllNestedChildComponents); mouseListeners->addListener (newListener, wantsEventsForAllNestedChildComponents);
} }
@@ -2928,7 +2928,7 @@ Point<int> Component::getMouseXYRelative() const
void Component::addKeyListener (KeyListener* newListener) void Component::addKeyListener (KeyListener* newListener)
{ {
if (keyListeners == nullptr) if (keyListeners == nullptr)
keyListeners = new Array<KeyListener*>();
keyListeners.reset (new Array<KeyListener*>());
keyListeners->addIfNotAlreadyThere (newListener); keyListeners->addIfNotAlreadyThere (newListener);
} }


+ 31
- 40
modules/juce_gui_basics/components/juce_Desktop.cpp View File

@@ -29,13 +29,9 @@ namespace juce
Desktop::Desktop() Desktop::Desktop()
: mouseSources (new MouseInputSource::SourceList()), : mouseSources (new MouseInputSource::SourceList()),
mouseClickCounter (0), mouseWheelCounter (0),
kioskModeComponent (nullptr),
kioskModeReentrant (false),
allowedOrientations (allOrientations),
masterScaleFactor ((float) getDefaultMasterScale()) masterScaleFactor ((float) getDefaultMasterScale())
{ {
displays = new Displays (*this);
displays.reset (new Displays (*this));
} }
Desktop::~Desktop() Desktop::~Desktop()
@@ -67,7 +63,7 @@ int Desktop::getNumComponents() const noexcept
return desktopComponents.size(); return desktopComponents.size();
} }
Component* Desktop::getComponent (const int index) const noexcept
Component* Desktop::getComponent (int index) const noexcept
{ {
return desktopComponents [index]; return desktopComponents [index];
} }
@@ -78,11 +74,11 @@ Component* Desktop::findComponentAt (Point<int> screenPosition) const
for (int i = desktopComponents.size(); --i >= 0;) for (int i = desktopComponents.size(); --i >= 0;)
{ {
Component* const c = desktopComponents.getUnchecked(i);
auto* c = desktopComponents.getUnchecked(i);
if (c->isVisible()) if (c->isVisible())
{ {
const Point<int> relative (c->getLocalPoint (nullptr, screenPosition));
auto relative = c->getLocalPoint (nullptr, screenPosition);
if (c->contains (relative)) if (c->contains (relative))
return c->getComponentAt (relative); return c->getComponentAt (relative);
@@ -98,7 +94,7 @@ LookAndFeel& Desktop::getDefaultLookAndFeel() noexcept
if (currentLookAndFeel == nullptr) if (currentLookAndFeel == nullptr)
{ {
if (defaultLookAndFeel == nullptr) if (defaultLookAndFeel == nullptr)
defaultLookAndFeel = new LookAndFeel_V4();
defaultLookAndFeel.reset (new LookAndFeel_V4());
currentLookAndFeel = defaultLookAndFeel; currentLookAndFeel = defaultLookAndFeel;
} }
@@ -112,26 +108,26 @@ void Desktop::setDefaultLookAndFeel (LookAndFeel* newDefaultLookAndFeel)
currentLookAndFeel = newDefaultLookAndFeel; currentLookAndFeel = newDefaultLookAndFeel;
for (int i = getNumComponents(); --i >= 0;) for (int i = getNumComponents(); --i >= 0;)
if (Component* const c = getComponent (i))
if (auto* c = getComponent (i))
c->sendLookAndFeelChange(); c->sendLookAndFeelChange();
} }
//============================================================================== //==============================================================================
void Desktop::addDesktopComponent (Component* const c)
void Desktop::addDesktopComponent (Component* c)
{ {
jassert (c != nullptr); jassert (c != nullptr);
jassert (! desktopComponents.contains (c)); jassert (! desktopComponents.contains (c));
desktopComponents.addIfNotAlreadyThere (c); desktopComponents.addIfNotAlreadyThere (c);
} }
void Desktop::removeDesktopComponent (Component* const c)
void Desktop::removeDesktopComponent (Component* c)
{ {
desktopComponents.removeFirstMatchingValue (c); desktopComponents.removeFirstMatchingValue (c);
} }
void Desktop::componentBroughtToFront (Component* const c)
void Desktop::componentBroughtToFront (Component* c)
{ {
const int index = desktopComponents.indexOf (c);
auto index = desktopComponents.indexOf (c);
jassert (index >= 0); jassert (index >= 0);
if (index >= 0) if (index >= 0)
@@ -179,18 +175,18 @@ int Desktop::getMouseWheelMoveCounter() const noexcept { return mouseWheelC
void Desktop::incrementMouseClickCounter() noexcept { ++mouseClickCounter; } void Desktop::incrementMouseClickCounter() noexcept { ++mouseClickCounter; }
void Desktop::incrementMouseWheelCounter() noexcept { ++mouseWheelCounter; } void Desktop::incrementMouseWheelCounter() noexcept { ++mouseWheelCounter; }
const Array<MouseInputSource>& Desktop::getMouseSources() const noexcept { return mouseSources->sourceArray; }
int Desktop::getNumMouseSources() const noexcept { return mouseSources->sources.size(); }
int Desktop::getNumDraggingMouseSources() const noexcept { return mouseSources->getNumDraggingMouseSources(); }
MouseInputSource* Desktop::getMouseSource (int index) const noexcept { return mouseSources->getMouseSource (index); }
MouseInputSource* Desktop::getDraggingMouseSource (int index) const noexcept { return mouseSources->getDraggingMouseSource (index); }
MouseInputSource Desktop::getMainMouseSource() const noexcept { return MouseInputSource (mouseSources->sources.getUnchecked(0)); }
void Desktop::beginDragAutoRepeat (int interval) { mouseSources->beginDragAutoRepeat (interval); }
const Array<MouseInputSource>& Desktop::getMouseSources() const noexcept { return mouseSources->sourceArray; }
int Desktop::getNumMouseSources() const noexcept { return mouseSources->sources.size(); }
int Desktop::getNumDraggingMouseSources() const noexcept { return mouseSources->getNumDraggingMouseSources(); }
MouseInputSource* Desktop::getMouseSource (int index) const noexcept { return mouseSources->getMouseSource (index); }
MouseInputSource* Desktop::getDraggingMouseSource (int index) const noexcept { return mouseSources->getDraggingMouseSource (index); }
MouseInputSource Desktop::getMainMouseSource() const noexcept { return MouseInputSource (mouseSources->sources.getUnchecked(0)); }
void Desktop::beginDragAutoRepeat (int interval) { mouseSources->beginDragAutoRepeat (interval); }
//============================================================================== //==============================================================================
void Desktop::addFocusChangeListener (FocusChangeListener* const listener) { focusListeners.add (listener); }
void Desktop::removeFocusChangeListener (FocusChangeListener* const listener) { focusListeners.remove (listener); }
void Desktop::triggerFocusCallback() { triggerAsyncUpdate(); }
void Desktop::addFocusChangeListener (FocusChangeListener* l) { focusListeners.add (l); }
void Desktop::removeFocusChangeListener (FocusChangeListener* l) { focusListeners.remove (l); }
void Desktop::triggerFocusCallback() { triggerAsyncUpdate(); }
void Desktop::handleAsyncUpdate() void Desktop::handleAsyncUpdate()
{ {
@@ -217,14 +213,14 @@ ListenerList<MouseListener>& Desktop::getMouseListeners()
return mouseListeners; return mouseListeners;
} }
void Desktop::addGlobalMouseListener (MouseListener* const listener)
void Desktop::addGlobalMouseListener (MouseListener* listener)
{ {
ASSERT_MESSAGE_MANAGER_IS_LOCKED ASSERT_MESSAGE_MANAGER_IS_LOCKED
mouseListeners.add (listener); mouseListeners.add (listener);
resetTimer(); resetTimer();
} }
void Desktop::removeGlobalMouseListener (MouseListener* const listener)
void Desktop::removeGlobalMouseListener (MouseListener* listener)
{ {
ASSERT_MESSAGE_MANAGER_IS_LOCKED ASSERT_MESSAGE_MANAGER_IS_LOCKED
mouseListeners.remove (listener); mouseListeners.remove (listener);
@@ -279,20 +275,18 @@ const Desktop::Displays::Display& Desktop::Displays::getMainDisplay() const noex
const Desktop::Displays::Display& Desktop::Displays::getDisplayContaining (Point<int> position) const noexcept const Desktop::Displays::Display& Desktop::Displays::getDisplayContaining (Point<int> position) const noexcept
{ {
ASSERT_MESSAGE_MANAGER_IS_LOCKED ASSERT_MESSAGE_MANAGER_IS_LOCKED
const Display* best = &displays.getReference(0);
auto* best = &displays.getReference(0);
double bestDistance = 1.0e10; double bestDistance = 1.0e10;
for (int i = displays.size(); --i >= 0;)
for (auto& d : displays)
{ {
const Display& d = displays.getReference(i);
if (d.totalArea.contains (position)) if (d.totalArea.contains (position))
{ {
best = &d; best = &d;
break; break;
} }
const double distance = d.totalArea.getCentre().getDistanceFrom (position);
auto distance = d.totalArea.getCentre().getDistanceFrom (position);
if (distance < bestDistance) if (distance < bestDistance)
{ {
@@ -309,11 +303,8 @@ RectangleList<int> Desktop::Displays::getRectangleList (bool userAreasOnly) cons
ASSERT_MESSAGE_MANAGER_IS_LOCKED ASSERT_MESSAGE_MANAGER_IS_LOCKED
RectangleList<int> rl; RectangleList<int> rl;
for (int i = 0; i < displays.size(); ++i)
{
const Display& d = displays.getReference(i);
for (auto& d : displays)
rl.addWithoutMerging (userAreasOnly ? d.userArea : d.totalArea); rl.addWithoutMerging (userAreasOnly ? d.userArea : d.totalArea);
}
return rl; return rl;
} }
@@ -353,13 +344,13 @@ void Desktop::Displays::refresh()
if (oldDisplays != displays) if (oldDisplays != displays)
{ {
for (int i = ComponentPeer::getNumPeers(); --i >= 0;) for (int i = ComponentPeer::getNumPeers(); --i >= 0;)
if (ComponentPeer* const peer = ComponentPeer::getPeer (i))
if (auto* peer = ComponentPeer::getPeer (i))
peer->handleScreenSizeChange(); peer->handleScreenSizeChange();
} }
} }
//============================================================================== //==============================================================================
void Desktop::setKioskModeComponent (Component* componentToUse, const bool allowMenusAndBars)
void Desktop::setKioskModeComponent (Component* componentToUse, bool allowMenusAndBars)
{ {
if (kioskModeReentrant) if (kioskModeReentrant)
return; return;
@@ -371,7 +362,7 @@ void Desktop::setKioskModeComponent (Component* componentToUse, const bool allow
// agh! Don't delete or remove a component from the desktop while it's still the kiosk component! // agh! Don't delete or remove a component from the desktop while it's still the kiosk component!
jassert (kioskModeComponent == nullptr || ComponentPeer::getPeerFor (kioskModeComponent) != nullptr); jassert (kioskModeComponent == nullptr || ComponentPeer::getPeerFor (kioskModeComponent) != nullptr);
if (Component* const oldKioskComp = kioskModeComponent)
if (auto* oldKioskComp = kioskModeComponent)
{ {
kioskModeComponent = nullptr; // (to make sure that isKioskMode() returns false when resizing the old one) kioskModeComponent = nullptr; // (to make sure that isKioskMode() returns false when resizing the old one)
setKioskComponent (oldKioskComp, false, allowMenusAndBars); setKioskComponent (oldKioskComp, false, allowMenusAndBars);
@@ -392,7 +383,7 @@ void Desktop::setKioskModeComponent (Component* componentToUse, const bool allow
} }
//============================================================================== //==============================================================================
void Desktop::setOrientationsEnabled (const int newOrientations)
void Desktop::setOrientationsEnabled (int newOrientations)
{ {
if (allowedOrientations != newOrientations) if (allowedOrientations != newOrientations)
{ {
@@ -409,7 +400,7 @@ int Desktop::getOrientationsEnabled() const noexcept
return allowedOrientations; return allowedOrientations;
} }
bool Desktop::isOrientationEnabled (const DisplayOrientation orientation) const noexcept
bool Desktop::isOrientationEnabled (DisplayOrientation orientation) const noexcept
{ {
// Make sure you only pass one valid flag in here... // Make sure you only pass one valid flag in here...
jassert (orientation == upright || orientation == upsideDown jassert (orientation == upright || orientation == upsideDown


+ 4
- 4
modules/juce_gui_basics/components/juce_Desktop.h View File

@@ -430,18 +430,18 @@ private:
Point<float> lastFakeMouseMove; Point<float> lastFakeMouseMove;
void sendMouseMove(); void sendMouseMove();
int mouseClickCounter, mouseWheelCounter;
int mouseClickCounter = 0, mouseWheelCounter = 0;
void incrementMouseClickCounter() noexcept; void incrementMouseClickCounter() noexcept;
void incrementMouseWheelCounter() noexcept; void incrementMouseWheelCounter() noexcept;
ScopedPointer<LookAndFeel> defaultLookAndFeel; ScopedPointer<LookAndFeel> defaultLookAndFeel;
WeakReference<LookAndFeel> currentLookAndFeel; WeakReference<LookAndFeel> currentLookAndFeel;
Component* kioskModeComponent;
Component* kioskModeComponent = nullptr;
Rectangle<int> kioskComponentOriginalBounds; Rectangle<int> kioskComponentOriginalBounds;
bool kioskModeReentrant;
bool kioskModeReentrant = false;
int allowedOrientations;
int allowedOrientations = allOrientations;
void allowedOrientationsChanged(); void allowedOrientationsChanged();
float masterScaleFactor; float masterScaleFactor;


+ 1
- 1
modules/juce_gui_basics/drawables/juce_Drawable.cpp View File

@@ -111,7 +111,7 @@ void Drawable::setClipPath (Drawable* clipPath)
{ {
if (drawableClipPath != clipPath) if (drawableClipPath != clipPath)
{ {
drawableClipPath = clipPath;
drawableClipPath.reset (clipPath);
repaint(); repaint();
} }
} }


+ 4
- 5
modules/juce_gui_basics/drawables/juce_SVGParser.cpp View File

@@ -1170,8 +1170,7 @@ private:
{ {
const auto indexOfComma = link.indexOf (","); const auto indexOfComma = link.indexOf (",");
auto format = link.substring (5, indexOfComma).trim(); auto format = link.substring (5, indexOfComma).trim();
const auto indexOfSemi = format.indexOf (";");
auto indexOfSemi = format.indexOf (";");
if (format.substring (indexOfSemi + 1).trim().equalsIgnoreCase ("base64")) if (format.substring (indexOfSemi + 1).trim().equalsIgnoreCase ("base64"))
{ {
@@ -1179,10 +1178,10 @@ private:
if (mime.equalsIgnoreCase ("image/png") || mime.equalsIgnoreCase ("image/jpeg")) if (mime.equalsIgnoreCase ("image/png") || mime.equalsIgnoreCase ("image/jpeg"))
{ {
const String base64text = link.substring (indexOfComma + 1).removeCharacters ("\t\n\r ");
auto base64text = link.substring (indexOfComma + 1).removeCharacters ("\t\n\r ");
if (Base64::convertFromBase64 (imageStream, base64text)) if (Base64::convertFromBase64 (imageStream, base64text))
inputStream = new MemoryInputStream (imageStream.getData(), imageStream.getDataSize(), false);
inputStream.reset (new MemoryInputStream (imageStream.getData(), imageStream.getDataSize(), false));
} }
} }
} }
@@ -1191,7 +1190,7 @@ private:
auto linkedFile = originalFile.getParentDirectory().getChildFile (link); auto linkedFile = originalFile.getParentDirectory().getChildFile (link);
if (linkedFile.existsAsFile()) if (linkedFile.existsAsFile())
inputStream = linkedFile.createInputStream();
inputStream.reset (linkedFile.createInputStream());
} }
if (inputStream != nullptr) if (inputStream != nullptr)


+ 3
- 3
modules/juce_gui_basics/filebrowser/juce_ContentSharer.cpp View File

@@ -176,7 +176,7 @@ void ContentSharer::startNewShare (std::function<void (bool, const String&)> cal
// You should not start another sharing operation before the previous one is finished. // You should not start another sharing operation before the previous one is finished.
// Forcibly stopping a previous sharing operation is rarely a good idea! // Forcibly stopping a previous sharing operation is rarely a good idea!
jassert (pimpl == nullptr); jassert (pimpl == nullptr);
pimpl = nullptr;
pimpl.reset();
prepareDataThread = nullptr; prepareDataThread = nullptr;
prepareImagesThread = nullptr; prepareImagesThread = nullptr;
@@ -187,7 +187,7 @@ void ContentSharer::startNewShare (std::function<void (bool, const String&)> cal
jassert (callbackToUse); jassert (callbackToUse);
callback = static_cast<std::function<void (bool, const String&)>&&> (callbackToUse); callback = static_cast<std::function<void (bool, const String&)>&&> (callbackToUse);
pimpl = createPimpl();
pimpl.reset (createPimpl());
} }
#endif #endif
@@ -263,7 +263,7 @@ void ContentSharer::sharingFinished (bool succeeded, const String& errorDescript
std::swap (cb, callback); std::swap (cb, callback);
#if JUCE_IOS || JUCE_ANDROID #if JUCE_IOS || JUCE_ANDROID
pimpl = nullptr;
pimpl.reset();
#endif #endif
if (cb) if (cb)


+ 1
- 1
modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp View File

@@ -107,7 +107,7 @@ void DirectoryContentsList::refresh()
if (root.isDirectory()) if (root.isDirectory())
{ {
fileFindHandle = new DirectoryIterator (root, false, "*", fileTypeFlags);
fileFindHandle.reset (new DirectoryIterator (root, false, "*", fileTypeFlags));
shouldStop = false; shouldStop = false;
thread.addTimeSliceClient (this); thread.addTimeSliceClient (this);
} }


+ 5
- 4
modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp View File

@@ -64,12 +64,12 @@ FileBrowserComponent::FileBrowserComponent (int flags_,
filename = initialFileOrDirectory.getFileName(); filename = initialFileOrDirectory.getFileName();
} }
fileList = new DirectoryContentsList (this, thread);
fileList.reset (new DirectoryContentsList (this, thread));
if ((flags & useTreeView) != 0) if ((flags & useTreeView) != 0)
{ {
auto tree = new FileTreeComponent (*fileList); auto tree = new FileTreeComponent (*fileList);
fileListComponent = tree;
fileListComponent.reset (tree);
if ((flags & canSelectMultipleItems) != 0) if ((flags & canSelectMultipleItems) != 0)
tree->setMultiSelectEnabled (true); tree->setMultiSelectEnabled (true);
@@ -79,7 +79,7 @@ FileBrowserComponent::FileBrowserComponent (int flags_,
else else
{ {
auto list = new FileListComponent (*fileList); auto list = new FileListComponent (*fileList);
fileListComponent = list;
fileListComponent.reset (list);
list->setOutlineThickness (1); list->setOutlineThickness (1);
if ((flags & canSelectMultipleItems) != 0) if ((flags & canSelectMultipleItems) != 0)
@@ -105,7 +105,8 @@ FileBrowserComponent::FileBrowserComponent (int flags_,
addAndMakeVisible (fileLabel); addAndMakeVisible (fileLabel);
fileLabel.attachToComponent (&filenameBox, true); fileLabel.attachToComponent (&filenameBox, true);
addAndMakeVisible (goUpButton = getLookAndFeel().createFileBrowserGoUpButton());
goUpButton.reset (getLookAndFeel().createFileBrowserGoUpButton());
addAndMakeVisible (goUpButton.get());
goUpButton->onClick = [this] { goUp(); }; goUpButton->onClick = [this] { goUp(); };
goUpButton->setTooltip (TRANS ("Go up to parent directory")); goUpButton->setTooltip (TRANS ("Go up to parent directory"));


+ 5
- 5
modules/juce_gui_basics/filebrowser/juce_FileChooser.cpp View File

@@ -156,7 +156,7 @@ bool FileChooser::showDialog (const int flags, FilePreviewComponent* const previ
{ {
FocusRestorer focusRestorer; FocusRestorer focusRestorer;
pimpl = createPimpl (flags, previewComp);
pimpl.reset (createPimpl (flags, previewComp));
pimpl->runModally(); pimpl->runModally();
// ensure that the finished function was invoked // ensure that the finished function was invoked
@@ -177,7 +177,7 @@ void FileChooser::launchAsync (int flags, std::function<void (const FileChooser&
asyncCallback = static_cast<std::function<void (const FileChooser&)>&&> (callback); asyncCallback = static_cast<std::function<void (const FileChooser&)>&&> (callback);
pimpl = createPimpl (flags, previewComp);
pimpl.reset (createPimpl (flags, previewComp));
pimpl->launch(); pimpl->launch();
} }
@@ -194,9 +194,9 @@ FileChooser::Pimpl* FileChooser::createPimpl (int flags, FilePreviewComponent* p
{ {
// you cannot run two file chooser dialog boxes at the same time // you cannot run two file chooser dialog boxes at the same time
jassertfalse; jassertfalse;
pimpl = nullptr;
pimpl.reset();
} }
// You've set the flags for both saveMode and openMode! // You've set the flags for both saveMode and openMode!
jassert (! (((flags & FileBrowserComponent::saveMode) != 0) jassert (! (((flags & FileBrowserComponent::saveMode) != 0)
&& ((flags & FileBrowserComponent::openMode) != 0))); && ((flags & FileBrowserComponent::openMode) != 0)));
@@ -256,7 +256,7 @@ void FileChooser::finished (const Array<URL>& asyncResults)
results = asyncResults; results = asyncResults;
pimpl = nullptr;
pimpl.reset();
if (callback) if (callback)
callback (*this); callback (*this);


+ 2
- 2
modules/juce_gui_basics/filebrowser/juce_FilenameComponent.cpp View File

@@ -87,8 +87,8 @@ void FilenameComponent::setBrowseButtonText (const String& newBrowseButtonText)
void FilenameComponent::lookAndFeelChanged() void FilenameComponent::lookAndFeelChanged()
{ {
browseButton.reset(); browseButton.reset();
addAndMakeVisible (browseButton = getLookAndFeel().createFilenameComponentBrowseButton (browseButtonText));
browseButton.reset (getLookAndFeel().createFilenameComponentBrowseButton (browseButtonText));
addAndMakeVisible (browseButton.get());
browseButton->setConnectedEdges (Button::ConnectedOnLeft); browseButton->setConnectedEdges (Button::ConnectedOnLeft);
browseButton->onClick = [this] { showChooser(); }; browseButton->onClick = [this] { showChooser(); };
resized(); resized();


+ 1
- 1
modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp View File

@@ -59,7 +59,7 @@ public:
endSpeed = jmax (0.0, endSpd * invTotalDistance); endSpeed = jmax (0.0, endSpd * invTotalDistance);
if (useProxyComponent) if (useProxyComponent)
proxy = new ProxyComponent (*component);
proxy.reset (new ProxyComponent (*component));
else else
proxy.reset(); proxy.reset();


+ 1
- 1
modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp View File

@@ -122,7 +122,7 @@ Component* ComponentBuilder::getManagedComponent()
{ {
if (component == nullptr) if (component == nullptr)
{ {
component = createComponent();
component.reset (createComponent());
#if JUCE_DEBUG #if JUCE_DEBUG
componentRef = component; componentRef = component;


+ 2
- 1
modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp View File

@@ -192,7 +192,8 @@ bool MultiDocumentPanel::addDocument (Component* const component,
{ {
if (tabComponent == nullptr && components.size() > numDocsBeforeTabsUsed) if (tabComponent == nullptr && components.size() > numDocsBeforeTabsUsed)
{ {
addAndMakeVisible (tabComponent = new TabbedComponentInternal());
tabComponent.reset (new TabbedComponentInternal());
addAndMakeVisible (tabComponent.get());
auto temp = components; auto temp = components;


+ 8
- 5
modules/juce_gui_basics/layout/juce_ScrollBar.cpp View File

@@ -245,7 +245,7 @@ void ScrollBar::paint (Graphics& g)
{ {
if (thumbAreaSize > 0) if (thumbAreaSize > 0)
{ {
LookAndFeel& lf = getLookAndFeel();
auto& lf = getLookAndFeel();
const int thumb = (thumbAreaSize > lf.getMinimumScrollbarThumbSize (*this)) const int thumb = (thumbAreaSize > lf.getMinimumScrollbarThumbSize (*this))
? thumbSize : 0; ? thumbSize : 0;
@@ -269,9 +269,9 @@ void ScrollBar::lookAndFeelChanged()
void ScrollBar::resized() void ScrollBar::resized()
{ {
const int length = vertical ? getHeight() : getWidth();
auto length = vertical ? getHeight() : getWidth();
LookAndFeel& lf = getLookAndFeel();
auto& lf = getLookAndFeel();
const bool buttonsVisible = lf.areScrollbarButtonsVisible(); const bool buttonsVisible = lf.areScrollbarButtonsVisible();
int buttonSize = 0; int buttonSize = 0;
@@ -279,8 +279,11 @@ void ScrollBar::resized()
{ {
if (upButton == nullptr) if (upButton == nullptr)
{ {
addAndMakeVisible (upButton = new ScrollbarButton (vertical ? 0 : 3, *this));
addAndMakeVisible (downButton = new ScrollbarButton (vertical ? 2 : 1, *this));
upButton .reset (new ScrollbarButton (vertical ? 0 : 3, *this));
downButton.reset (new ScrollbarButton (vertical ? 2 : 1, *this));
addAndMakeVisible (upButton.get());
addAndMakeVisible (downButton.get());
setButtonRepeatSpeed (initialDelayInMillisecs, repeatDelayInMillisecs, minimumDelayInMillisecs); setButtonRepeatSpeed (initialDelayInMillisecs, repeatDelayInMillisecs, minimumDelayInMillisecs);
} }


+ 5
- 3
modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp View File

@@ -145,7 +145,8 @@ void TabBarButton::setExtraComponent (Component* comp, ExtraComponentPlacement p
{ {
jassert (extraCompPlacement == beforeText || extraCompPlacement == afterText); jassert (extraCompPlacement == beforeText || extraCompPlacement == afterText);
extraCompPlacement = placement; extraCompPlacement = placement;
addAndMakeVisible (extraComponent = comp);
extraComponent.reset (comp);
addAndMakeVisible (extraComponent.get());
resized(); resized();
} }
@@ -200,7 +201,8 @@ TabbedButtonBar::TabbedButtonBar (Orientation orientationToUse)
: orientation (orientationToUse) : orientation (orientationToUse)
{ {
setInterceptsMouseClicks (false, true); setInterceptsMouseClicks (false, true);
addAndMakeVisible (behindFrontTab = new BehindFrontTabComp (*this));
behindFrontTab.reset (new BehindFrontTabComp (*this));
addAndMakeVisible (behindFrontTab.get());
setFocusContainer (true); setFocusContainer (true);
} }
@@ -256,7 +258,7 @@ void TabbedButtonBar::addTab (const String& tabName,
auto* newTab = new TabInfo(); auto* newTab = new TabInfo();
newTab->name = tabName; newTab->name = tabName;
newTab->colour = tabBackgroundColour; newTab->colour = tabBackgroundColour;
newTab->button = createTabButton (tabName, insertIndex);
newTab->button.reset (createTabButton (tabName, insertIndex));
jassert (newTab->button != nullptr); jassert (newTab->button != nullptr);
tabs.insert (insertIndex, newTab); tabs.insert (insertIndex, newTab);


+ 2
- 1
modules/juce_gui_basics/layout/juce_TabbedComponent.cpp View File

@@ -90,7 +90,8 @@ struct TabbedComponent::ButtonBar : public TabbedButtonBar
//============================================================================== //==============================================================================
TabbedComponent::TabbedComponent (const TabbedButtonBar::Orientation orientation) TabbedComponent::TabbedComponent (const TabbedButtonBar::Orientation orientation)
{ {
addAndMakeVisible (tabs = new ButtonBar (*this, orientation));
tabs.reset (new ButtonBar (*this, orientation));
addAndMakeVisible (tabs.get());
} }
TabbedComponent::~TabbedComponent() TabbedComponent::~TabbedComponent()


+ 5
- 3
modules/juce_gui_basics/layout/juce_Viewport.cpp View File

@@ -102,8 +102,11 @@ void Viewport::recreateScrollbars()
verticalScrollBar.reset(); verticalScrollBar.reset();
horizontalScrollBar.reset(); horizontalScrollBar.reset();
addChildComponent (verticalScrollBar = createScrollBarComponent (true));
addChildComponent (horizontalScrollBar = createScrollBarComponent (false));
verticalScrollBar .reset (createScrollBarComponent (true));
horizontalScrollBar.reset (createScrollBarComponent (false));
addChildComponent (verticalScrollBar.get());
addChildComponent (horizontalScrollBar.get());
getVerticalScrollBar().addListener (this); getVerticalScrollBar().addListener (this);
getHorizontalScrollBar().addListener (this); getHorizontalScrollBar().addListener (this);
@@ -126,7 +129,6 @@ Point<int> Viewport::viewportPosToCompPos (Point<int> pos) const
Point<int> p (jmax (jmin (0, contentHolder.getWidth() - contentBounds.getWidth()), jmin (0, -(pos.x))), Point<int> p (jmax (jmin (0, contentHolder.getWidth() - contentBounds.getWidth()), jmin (0, -(pos.x))),
jmax (jmin (0, contentHolder.getHeight() - contentBounds.getHeight()), jmin (0, -(pos.y)))); jmax (jmin (0, contentHolder.getHeight() - contentBounds.getHeight()), jmin (0, -(pos.y))));
return p.transformedBy (contentComp->getTransform().inverted()); return p.transformedBy (contentComp->getTransform().inverted());
} }


+ 15
- 15
modules/juce_gui_basics/menus/juce_PopupMenu.cpp View File

@@ -906,11 +906,11 @@ public:
if (childComp != nullptr if (childComp != nullptr
&& hasActiveSubMenu (childComp->item)) && hasActiveSubMenu (childComp->item))
{ {
activeSubMenu = new HelperClasses::MenuWindow (*(childComp->item.subMenu), this,
options.withTargetScreenArea (childComp->getScreenBounds())
.withMinimumWidth (0)
.withTargetComponent (nullptr),
false, dismissOnMouseUp, managerOfChosenCommand, scaleFactor);
activeSubMenu.reset (new HelperClasses::MenuWindow (*(childComp->item.subMenu), this,
options.withTargetScreenArea (childComp->getScreenBounds())
.withMinimumWidth (0)
.withTargetComponent (nullptr),
false, dismissOnMouseUp, managerOfChosenCommand, scaleFactor));
activeSubMenu->setVisible (true); // (must be called before enterModalState on Windows to avoid DropShadower confusion) activeSubMenu->setVisible (true); // (must be called before enterModalState on Windows to avoid DropShadower confusion)
activeSubMenu->enterModalState (false); activeSubMenu->enterModalState (false);
@@ -1342,8 +1342,8 @@ PopupMenu::Item& PopupMenu::Item::operator= (const Item& other)
{ {
text = other.text; text = other.text;
itemID = other.itemID; itemID = other.itemID;
subMenu = createCopyIfNotNull (other.subMenu.get());
image = (other.image != nullptr ? other.image->createCopy() : nullptr);
subMenu.reset (createCopyIfNotNull (other.subMenu.get()));
image.reset (other.image != nullptr ? other.image->createCopy() : nullptr);
customComponent = other.customComponent; customComponent = other.customComponent;
customCallback = other.customCallback; customCallback = other.customCallback;
commandManager = other.commandManager; commandManager = other.commandManager;
@@ -1401,7 +1401,7 @@ void PopupMenu::addItem (int itemResultID, const String& itemText, bool isActive
i.itemID = itemResultID; i.itemID = itemResultID;
i.isEnabled = isActive; i.isEnabled = isActive;
i.isTicked = isTicked; i.isTicked = isTicked;
i.image = iconToUse;
i.image.reset (iconToUse);
addItem (i); addItem (i);
} }
@@ -1423,7 +1423,7 @@ void PopupMenu::addCommandItem (ApplicationCommandManager* commandManager,
i.commandManager = commandManager; i.commandManager = commandManager;
i.isEnabled = target != nullptr && (info.flags & ApplicationCommandInfo::isDisabled) == 0; i.isEnabled = target != nullptr && (info.flags & ApplicationCommandInfo::isDisabled) == 0;
i.isTicked = (info.flags & ApplicationCommandInfo::isTicked) != 0; i.isTicked = (info.flags & ApplicationCommandInfo::isTicked) != 0;
i.image = iconToUse;
i.image.reset (iconToUse);
addItem (i); addItem (i);
} }
} }
@@ -1437,7 +1437,7 @@ void PopupMenu::addColouredItem (int itemResultID, const String& itemText, Colou
i.colour = itemTextColour; i.colour = itemTextColour;
i.isEnabled = isActive; i.isEnabled = isActive;
i.isTicked = isTicked; i.isTicked = isTicked;
i.image = iconToUse;
i.image.reset (iconToUse);
addItem (i); addItem (i);
} }
@@ -1450,7 +1450,7 @@ void PopupMenu::addColouredItem (int itemResultID, const String& itemText, Colou
i.colour = itemTextColour; i.colour = itemTextColour;
i.isEnabled = isActive; i.isEnabled = isActive;
i.isTicked = isTicked; i.isTicked = isTicked;
i.image = createDrawableFromImage (iconToUse);
i.image.reset (createDrawableFromImage (iconToUse));
addItem (i); addItem (i);
} }
@@ -1459,7 +1459,7 @@ void PopupMenu::addCustomItem (int itemResultID, CustomComponent* cc, const Popu
Item i; Item i;
i.itemID = itemResultID; i.itemID = itemResultID;
i.customComponent = cc; i.customComponent = cc;
i.subMenu = createCopyIfNotNull (subMenu);
i.subMenu.reset (createCopyIfNotNull (subMenu));
addItem (i); addItem (i);
} }
@@ -1489,10 +1489,10 @@ void PopupMenu::addSubMenu (const String& subMenuName, const PopupMenu& subMenu,
Item i; Item i;
i.text = subMenuName; i.text = subMenuName;
i.itemID = itemResultID; i.itemID = itemResultID;
i.subMenu = new PopupMenu (subMenu);
i.subMenu.reset (new PopupMenu (subMenu));
i.isEnabled = isActive && (itemResultID != 0 || subMenu.getNumItems() > 0); i.isEnabled = isActive && (itemResultID != 0 || subMenu.getNumItems() > 0);
i.isTicked = isTicked; i.isTicked = isTicked;
i.image = iconToUse;
i.image.reset (iconToUse);
addItem (i); addItem (i);
} }
@@ -1639,7 +1639,7 @@ int PopupMenu::showWithOptionalCallback (const Options& options, ModalComponentM
if (auto* window = createWindow (options, &(callback->managerOfChosenCommand))) if (auto* window = createWindow (options, &(callback->managerOfChosenCommand)))
{ {
callback->component = window;
callback->component.reset (window);
window->setVisible (true); // (must be called before enterModalState on Windows to avoid DropShadower confusion) window->setVisible (true); // (must be called before enterModalState on Windows to avoid DropShadower confusion)
window->enterModalState (false, userCallbackDeleter.release()); window->enterModalState (false, userCallbackDeleter.release());


+ 2
- 3
modules/juce_gui_basics/misc/juce_JUCESplashScreen.cpp View File

@@ -121,7 +121,7 @@ struct ReportingThread : public Thread,
void run() override void run() override
{ {
webStream = new WebInputStream (url, true);
webStream.reset (new WebInputStream (url, true));
webStream->withExtraHeaders (headers); webStream->withExtraHeaders (headers);
webStream->connect (nullptr); webStream->connect (nullptr);
@@ -138,8 +138,7 @@ private:
//============================================================================== //==============================================================================
void ReportingThreadContainer::sendReport (String address, String& userAgent, StringPairArray& parameters) void ReportingThreadContainer::sendReport (String address, String& userAgent, StringPairArray& parameters)
{ {
reportingThread = new ReportingThread (*this, address, userAgent, parameters);
reportingThread.reset (new ReportingThread (*this, address, userAgent, parameters));
reportingThread->startThread(); reportingThread->startThread();
} }


+ 3
- 3
modules/juce_gui_basics/native/juce_mac_FileChooser.mm View File

@@ -137,7 +137,7 @@ public:
if (panel != nil) if (panel != nil)
{ {
[panel setDelegate:nil];
[panel setDelegate: nil];
if (nsViewPreview != nil) if (nsViewPreview != nil)
{ {
@@ -152,7 +152,7 @@ public:
[panel close]; [panel close];
} }
panel = nullptr;
panel.reset();
if (delegate != nil) if (delegate != nil)
{ {
@@ -178,7 +178,7 @@ public:
ScopedPointer<TemporaryMainMenuWithStandardCommands> tempMenu; ScopedPointer<TemporaryMainMenuWithStandardCommands> tempMenu;
if (JUCEApplicationBase::isStandaloneApp()) if (JUCEApplicationBase::isStandaloneApp())
tempMenu = new TemporaryMainMenuWithStandardCommands();
tempMenu.reset (new TemporaryMainMenuWithStandardCommands());
jassert (panel != nil); jassert (panel != nil);
#if defined (MAC_OS_X_VERSION_10_6) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6) #if defined (MAC_OS_X_VERSION_10_6) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6)


+ 3
- 3
modules/juce_gui_basics/native/juce_mac_MainMenu.mm View File

@@ -102,7 +102,7 @@ public:
menuBarItemsChanged (nullptr); menuBarItemsChanged (nullptr);
} }
extraAppleMenuItems = createCopyIfNotNull (newExtraAppleMenuItems);
extraAppleMenuItems.reset (createCopyIfNotNull (newExtraAppleMenuItems));
} }
void addTopLevelMenu (NSMenu* parent, const PopupMenu& child, const String& name, int menuId, int topLevelIndex) void addTopLevelMenu (NSMenu* parent, const PopupMenu& child, const String& name, int menuId, int topLevelIndex)
@@ -249,7 +249,7 @@ public:
if (i.text == recentItemsMenuName) if (i.text == recentItemsMenuName)
{ {
if (recent == nullptr) if (recent == nullptr)
recent = new RecentFilesMenuItem();
recent.reset (new RecentFilesMenuItem());
if (recent->recentItem != nil) if (recent->recentItem != nil)
{ {
@@ -573,7 +573,7 @@ public:
: oldMenu (MenuBarModel::getMacMainMenu()) : oldMenu (MenuBarModel::getMacMainMenu())
{ {
if (auto* appleMenu = MenuBarModel::getMacExtraAppleItemsMenu()) if (auto* appleMenu = MenuBarModel::getMacExtraAppleItemsMenu())
oldAppleMenu = new PopupMenu (*appleMenu);
oldAppleMenu.reset (new PopupMenu (*appleMenu));
if (auto* handler = JuceMainMenuHandler::instance) if (auto* handler = JuceMainMenuHandler::instance)
oldRecentItems = handler->recentItemsMenuName; oldRecentItems = handler->recentItemsMenuName;


+ 2
- 2
modules/juce_gui_basics/native/juce_mac_Windowing.mm View File

@@ -364,7 +364,7 @@ public:
if (Process::isForegroundProcess()) if (Process::isForegroundProcess())
{ {
if (assertion == nullptr) if (assertion == nullptr)
assertion = new PMAssertion();
assertion.reset (new PMAssertion());
} }
else else
{ {
@@ -415,7 +415,7 @@ void Desktop::setScreenSaverEnabled (const bool isEnabled)
if (isEnabled) if (isEnabled)
screenSaverDefeater.reset(); screenSaverDefeater.reset();
else if (screenSaverDefeater == nullptr) else if (screenSaverDefeater == nullptr)
screenSaverDefeater = new ScreenSaverDefeater();
screenSaverDefeater.reset (new ScreenSaverDefeater());
} }
bool Desktop::isScreenSaverEnabled() bool Desktop::isScreenSaverEnabled()


+ 2
- 1
modules/juce_gui_basics/widgets/juce_Label.cpp View File

@@ -206,7 +206,8 @@ void Label::showEditor()
{ {
if (editor == nullptr) if (editor == nullptr)
{ {
addAndMakeVisible (editor = createEditorComponent());
editor.reset (createEditorComponent());
addAndMakeVisible (editor.get());
editor->setText (getText(), false); editor->setText (getText(), false);
editor->setKeyboardType (keyboardType); editor->setKeyboardType (keyboardType);
editor->addListener (this); editor->addListener (this);


+ 4
- 3
modules/juce_gui_basics/widgets/juce_ListBox.cpp View File

@@ -377,7 +377,8 @@ struct ListBoxMouseMoveSelector : public MouseListener
ListBox::ListBox (const String& name, ListBoxModel* const m) ListBox::ListBox (const String& name, ListBoxModel* const m)
: Component (name), model (m) : Component (name), model (m)
{ {
addAndMakeVisible (viewport = new ListViewport (*this));
viewport.reset (new ListViewport (*this));
addAndMakeVisible (viewport.get());
ListBox::setWantsKeyboardFocus (true); ListBox::setWantsKeyboardFocus (true);
ListBox::colourChanged(); ListBox::colourChanged();
@@ -408,7 +409,7 @@ void ListBox::setMouseMoveSelectsRows (bool b)
if (b) if (b)
{ {
if (mouseMoveSelector == nullptr) if (mouseMoveSelector == nullptr)
mouseMoveSelector = new ListBoxMouseMoveSelector (*this);
mouseMoveSelector.reset (new ListBoxMouseMoveSelector (*this));
} }
else else
{ {
@@ -859,7 +860,7 @@ void ListBox::setHeaderComponent (Component* const newHeaderComponent)
{ {
if (headerComponent != newHeaderComponent) if (headerComponent != newHeaderComponent)
{ {
headerComponent = newHeaderComponent;
headerComponent.reset (newHeaderComponent);
addAndMakeVisible (newHeaderComponent); addAndMakeVisible (newHeaderComponent);
ListBox::resized(); ListBox::resized();


+ 1
- 1
modules/juce_gui_basics/widgets/juce_Slider.cpp View File

@@ -1352,7 +1352,7 @@ void Slider::init (SliderStyle style, TextEntryBoxPosition textBoxPos)
setWantsKeyboardFocus (false); setWantsKeyboardFocus (false);
setRepaintsOnMouseActivity (true); setRepaintsOnMouseActivity (true);
pimpl = new Pimpl (*this, style, textBoxPos);
pimpl.reset (new Pimpl (*this, style, textBoxPos));
Slider::lookAndFeelChanged(); Slider::lookAndFeelChanged();
updateText(); updateText();


+ 3
- 2
modules/juce_gui_basics/widgets/juce_Toolbar.cpp View File

@@ -243,7 +243,8 @@ private:
//============================================================================== //==============================================================================
Toolbar::Toolbar() Toolbar::Toolbar()
{ {
addChildComponent (missingItemsButton = getLookAndFeel().createToolbarMissingItemsButton (*this));
missingItemsButton.reset (getLookAndFeel().createToolbarMissingItemsButton (*this));
addChildComponent (missingItemsButton.get());
missingItemsButton->setAlwaysOnTop (true); missingItemsButton->setAlwaysOnTop (true);
missingItemsButton->onClick = [this] { showMissingItems(); }; missingItemsButton->onClick = [this] { showMissingItems(); };
@@ -353,7 +354,7 @@ int Toolbar::getItemId (const int itemIndex) const noexcept
ToolbarItemComponent* Toolbar::getItemComponent (const int itemIndex) const noexcept ToolbarItemComponent* Toolbar::getItemComponent (const int itemIndex) const noexcept
{ {
return items [itemIndex];
return items[itemIndex];
} }
ToolbarItemComponent* Toolbar::getNextActiveComponent (int index, const int delta) const ToolbarItemComponent* Toolbar::getNextActiveComponent (int index, const int delta) const


+ 5
- 2
modules/juce_gui_basics/widgets/juce_TreeView.cpp View File

@@ -1008,8 +1008,11 @@ void TreeView::showDragHighlight (const InsertPoint& insertPos) noexcept
if (dragInsertPointHighlight == nullptr) if (dragInsertPointHighlight == nullptr)
{ {
addAndMakeVisible (dragInsertPointHighlight = new InsertPointHighlight());
addAndMakeVisible (dragTargetGroupHighlight = new TargetGroupHighlight());
dragInsertPointHighlight.reset (new InsertPointHighlight());
dragTargetGroupHighlight.reset (new TargetGroupHighlight());
addAndMakeVisible (dragInsertPointHighlight.get());
addAndMakeVisible (dragTargetGroupHighlight.get());
} }
dragInsertPointHighlight->setTargetPosition (insertPos, viewport->getViewWidth()); dragInsertPointHighlight->setTargetPosition (insertPos, viewport->getViewWidth());


+ 7
- 7
modules/juce_gui_basics/windows/juce_DocumentWindow.cpp View File

@@ -145,8 +145,8 @@ Component* DocumentWindow::getMenuBarComponent() const noexcept
void DocumentWindow::setMenuBarComponent (Component* newMenuBarComponent) void DocumentWindow::setMenuBarComponent (Component* newMenuBarComponent)
{ {
// (call the Component method directly to avoid the assertion in ResizableWindow)
Component::addAndMakeVisible (menuBar = newMenuBarComponent);
menuBar.reset (newMenuBarComponent);
Component::addAndMakeVisible (menuBar.get()); // (call the superclass method directly to avoid the assertion in ResizableWindow)
if (menuBar != nullptr) if (menuBar != nullptr)
menuBar->setEnabled (isActiveWindow()); menuBar->setEnabled (isActiveWindow());
@@ -292,18 +292,18 @@ void DocumentWindow::lookAndFeelChanged()
if (! isUsingNativeTitleBar()) if (! isUsingNativeTitleBar())
{ {
LookAndFeel& lf = getLookAndFeel();
auto& lf = getLookAndFeel();
if ((requiredButtons & minimiseButton) != 0) titleBarButtons[0] = lf.createDocumentWindowButton (minimiseButton);
if ((requiredButtons & maximiseButton) != 0) titleBarButtons[1] = lf.createDocumentWindowButton (maximiseButton);
if ((requiredButtons & closeButton) != 0) titleBarButtons[2] = lf.createDocumentWindowButton (closeButton);
if ((requiredButtons & minimiseButton) != 0) titleBarButtons[0].reset (lf.createDocumentWindowButton (minimiseButton));
if ((requiredButtons & maximiseButton) != 0) titleBarButtons[1].reset (lf.createDocumentWindowButton (maximiseButton));
if ((requiredButtons & closeButton) != 0) titleBarButtons[2].reset (lf.createDocumentWindowButton (closeButton));
for (auto& b : titleBarButtons) for (auto& b : titleBarButtons)
{ {
if (b != nullptr) if (b != nullptr)
{ {
if (buttonListener == nullptr) if (buttonListener == nullptr)
buttonListener = new ButtonListenerProxy (*this);
buttonListener.reset (new ButtonListenerProxy (*this));
b->addListener (buttonListener); b->addListener (buttonListener);
b->setWantsKeyboardFocus (false); b->setWantsKeyboardFocus (false);


+ 6
- 2
modules/juce_gui_basics/windows/juce_ResizableWindow.cpp View File

@@ -277,7 +277,8 @@ void ResizableWindow::setResizable (const bool shouldBeResizable,
if (resizableCorner == nullptr) if (resizableCorner == nullptr)
{ {
Component::addChildComponent (resizableCorner = new ResizableCornerComponent (this, constrainer));
resizableCorner.reset (new ResizableCornerComponent (this, constrainer));
Component::addChildComponent (resizableCorner.get());
resizableCorner->setAlwaysOnTop (true); resizableCorner->setAlwaysOnTop (true);
} }
} }
@@ -286,7 +287,10 @@ void ResizableWindow::setResizable (const bool shouldBeResizable,
resizableCorner.reset(); resizableCorner.reset();
if (resizableBorder == nullptr) if (resizableBorder == nullptr)
Component::addChildComponent (resizableBorder = new ResizableBorderComponent (this, constrainer));
{
resizableBorder.reset (new ResizableBorderComponent (this, constrainer));
Component::addChildComponent (resizableBorder.get());
}
} }
} }
else else


+ 6
- 7
modules/juce_gui_basics/windows/juce_ThreadWithProgressWindow.cpp View File

@@ -38,13 +38,12 @@ ThreadWithProgressWindow::ThreadWithProgressWindow (const String& title,
timeOutMsWhenCancelling (cancellingTimeOutMs), timeOutMsWhenCancelling (cancellingTimeOutMs),
wasCancelledByUser (false) wasCancelledByUser (false)
{ {
alertWindow = LookAndFeel::getDefaultLookAndFeel()
.createAlertWindow (title, String(),
cancelButtonText.isEmpty() ? TRANS("Cancel")
: cancelButtonText,
String(), String(),
AlertWindow::NoIcon, hasCancelButton ? 1 : 0,
componentToCentreAround);
alertWindow.reset (LookAndFeel::getDefaultLookAndFeel()
.createAlertWindow (title, {},
cancelButtonText.isEmpty() ? TRANS("Cancel")
: cancelButtonText,
{}, {}, AlertWindow::NoIcon, hasCancelButton ? 1 : 0,
componentToCentreAround));
// if there are no buttons, we won't allow the user to interrupt the thread. // if there are no buttons, we won't allow the user to interrupt the thread.
alertWindow->setEscapeKeyCancels (false); alertWindow->setEscapeKeyCancels (false);


+ 1
- 1
modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp View File

@@ -221,7 +221,7 @@ void TopLevelWindow::setDropShadowEnabled (const bool useShadow)
{ {
if (shadower == nullptr) if (shadower == nullptr)
{ {
shadower = getLookAndFeel().createDropShadowerForComponent (this);
shadower.reset (getLookAndFeel().createDropShadowerForComponent (this));
if (shadower != nullptr) if (shadower != nullptr)
shadower->setOwner (this); shadower->setOwner (this);


+ 15
- 12
modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp View File

@@ -289,7 +289,7 @@ public:
void paint (Graphics& g) override void paint (Graphics& g) override
{ {
jassert (dynamic_cast<CodeEditorComponent*> (getParentComponent()) != nullptr); jassert (dynamic_cast<CodeEditorComponent*> (getParentComponent()) != nullptr);
const CodeEditorComponent& editor = *static_cast<CodeEditorComponent*> (getParentComponent());
auto& editor = *static_cast<CodeEditorComponent*> (getParentComponent());
g.fillAll (editor.findColour (CodeEditorComponent::backgroundColourId) g.fillAll (editor.findColour (CodeEditorComponent::backgroundColourId)
.overlaidWith (editor.findColour (lineNumberBackgroundId))); .overlaidWith (editor.findColour (lineNumberBackgroundId)));
@@ -301,10 +301,10 @@ public:
const int lastLineToDraw = jmin (editor.lines.size(), clip.getBottom() / lineH + 1, const int lastLineToDraw = jmin (editor.lines.size(), clip.getBottom() / lineH + 1,
lastNumLines - editor.firstLineOnScreen); lastNumLines - editor.firstLineOnScreen);
const Font lineNumberFont (editor.getFont().withHeight (jmin (13.0f, lineHeightFloat * 0.8f)));
const float w = getWidth() - 2.0f;
auto lineNumberFont = editor.getFont().withHeight (jmin (13.0f, lineHeightFloat * 0.8f));
auto w = getWidth() - 2.0f;
GlyphArrangement ga; GlyphArrangement ga;
for (int i = firstLineToDraw; i < lastLineToDraw; ++i) for (int i = firstLineToDraw; i < lastLineToDraw; ++i)
ga.addFittedText (lineNumberFont, String (editor.firstLineOnScreen + i + 1), ga.addFittedText (lineNumberFont, String (editor.firstLineOnScreen + i + 1),
0, (float) (lineH * i), w, lineHeightFloat, 0, (float) (lineH * i), w, lineHeightFloat,
@@ -316,7 +316,7 @@ public:
void documentChanged (CodeDocument& doc, int newFirstLine) void documentChanged (CodeDocument& doc, int newFirstLine)
{ {
const int newNumLines = doc.getNumLines();
auto newNumLines = doc.getNumLines();
if (newNumLines != lastNumLines || firstLine != newFirstLine) if (newNumLines != lastNumLines || firstLine != newFirstLine)
{ {
@@ -339,7 +339,7 @@ CodeEditorComponent::CodeEditorComponent (CodeDocument& doc, CodeTokeniser* cons
selectionEnd (doc, 0, 0), selectionEnd (doc, 0, 0),
codeTokeniser (tokeniser) codeTokeniser (tokeniser)
{ {
pimpl = new Pimpl (*this);
pimpl.reset (new Pimpl (*this));
caretPos.setPositionMaintained (true); caretPos.setPositionMaintained (true);
selectionStart.setPositionMaintained (true); selectionStart.setPositionMaintained (true);
@@ -349,7 +349,8 @@ CodeEditorComponent::CodeEditorComponent (CodeDocument& doc, CodeTokeniser* cons
setMouseCursor (MouseCursor::IBeamCursor); setMouseCursor (MouseCursor::IBeamCursor);
setWantsKeyboardFocus (true); setWantsKeyboardFocus (true);
addAndMakeVisible (caret = getLookAndFeel().createCaretComponent (this));
caret.reset (getLookAndFeel().createCaretComponent (this));
addAndMakeVisible (caret.get());
addAndMakeVisible (verticalScrollBar); addAndMakeVisible (verticalScrollBar);
verticalScrollBar.setSingleStepSize (1.0); verticalScrollBar.setSingleStepSize (1.0);
@@ -416,7 +417,10 @@ void CodeEditorComponent::setLineNumbersShown (const bool shouldBeShown)
gutter.reset(); gutter.reset();
if (shouldBeShown) if (shouldBeShown)
addAndMakeVisible (gutter = new GutterComponent());
{
gutter.reset (new GutterComponent());
addAndMakeVisible (gutter.get());
}
resized(); resized();
} }
@@ -438,7 +442,7 @@ void CodeEditorComponent::setReadOnly (bool b) noexcept
//============================================================================== //==============================================================================
void CodeEditorComponent::resized() void CodeEditorComponent::resized()
{ {
const int visibleWidth = getWidth() - scrollbarThickness - getGutterSize();
auto visibleWidth = getWidth() - scrollbarThickness - getGutterSize();
linesOnScreen = jmax (1, (getHeight() - scrollbarThickness) / lineHeight); linesOnScreen = jmax (1, (getHeight() - scrollbarThickness) / lineHeight);
columnsOnScreen = jmax (1, (int) (visibleWidth / charWidth)); columnsOnScreen = jmax (1, (int) (visibleWidth / charWidth));
lines.clear(); lines.clear();
@@ -503,9 +507,8 @@ void CodeEditorComponent::rebuildLineTokens()
{ {
pimpl->cancelPendingUpdate(); pimpl->cancelPendingUpdate();
const int numNeeded = linesOnScreen + 1;
int minLineToRepaint = numNeeded;
auto numNeeded = linesOnScreen + 1;
auto minLineToRepaint = numNeeded;
int maxLineToRepaint = 0; int maxLineToRepaint = 0;
if (numNeeded != lines.size()) if (numNeeded != lines.size())


+ 30
- 22
modules/juce_gui_extra/misc/juce_ColourSelector.cpp View File

@@ -73,7 +73,7 @@ public:
class ColourSelector::ColourSpaceView : public Component class ColourSelector::ColourSpaceView : public Component
{ {
public: public:
ColourSpaceView (ColourSelector& cs, float& hue, float& sat, float& val, const int edgeSize)
ColourSpaceView (ColourSelector& cs, float& hue, float& sat, float& val, int edgeSize)
: owner (cs), h (hue), s (sat), v (val), lastHue (0.0f), edge (edgeSize) : owner (cs), h (hue), s (sat), v (val), lastHue (0.0f), edge (edgeSize)
{ {
addAndMakeVisible (marker); addAndMakeVisible (marker);
@@ -84,19 +84,19 @@ public:
{ {
if (colours.isNull()) if (colours.isNull())
{ {
const int width = getWidth() / 2;
const int height = getHeight() / 2;
auto width = getWidth() / 2;
auto height = getHeight() / 2;
colours = Image (Image::RGB, width, height, false); colours = Image (Image::RGB, width, height, false);
Image::BitmapData pixels (colours, Image::BitmapData::writeOnly); Image::BitmapData pixels (colours, Image::BitmapData::writeOnly);
for (int y = 0; y < height; ++y) for (int y = 0; y < height; ++y)
{ {
const float val = 1.0f - y / (float) height;
auto val = 1.0f - y / (float) height;
for (int x = 0; x < width; ++x) for (int x = 0; x < width; ++x)
{ {
const float sat = x / (float) width;
auto sat = x / (float) width;
pixels.setPixelColour (x, y, Colour (h, sat, val, 1.0f)); pixels.setPixelColour (x, y, Colour (h, sat, val, 1.0f));
} }
} }
@@ -117,8 +117,8 @@ public:
void mouseDrag (const MouseEvent& e) override void mouseDrag (const MouseEvent& e) override
{ {
const float sat = (e.x - edge) / (float) (getWidth() - edge * 2);
const float val = 1.0f - (e.y - edge) / (float) (getHeight() - edge * 2);
auto sat = (e.x - edge) / (float) (getWidth() - edge * 2);
auto val = 1.0f - (e.y - edge) / (float) (getHeight() - edge * 2);
owner.setSV (sat, val); owner.setSV (sat, val);
} }
@@ -172,8 +172,8 @@ public:
void paint (Graphics& g) override void paint (Graphics& g) override
{ {
const float cw = (float) getWidth();
const float ch = (float) getHeight();
auto cw = (float) getWidth();
auto ch = (float) getHeight();
Path p; Path p;
p.addTriangle (1.0f, 1.0f, p.addTriangle (1.0f, 1.0f,
@@ -199,7 +199,7 @@ private:
class ColourSelector::HueSelectorComp : public Component class ColourSelector::HueSelectorComp : public Component
{ {
public: public:
HueSelectorComp (ColourSelector& cs, float& hue, const int edgeSize)
HueSelectorComp (ColourSelector& cs, float& hue, int edgeSize)
: owner (cs), h (hue), edge (edgeSize) : owner (cs), h (hue), edge (edgeSize)
{ {
addAndMakeVisible (marker); addAndMakeVisible (marker);
@@ -259,11 +259,11 @@ public:
void paint (Graphics& g) override void paint (Graphics& g) override
{ {
const Colour c (owner.getSwatchColour (index));
auto col = owner.getSwatchColour (index);
g.fillCheckerBoard (getLocalBounds().toFloat(), 6.0f, 6.0f, g.fillCheckerBoard (getLocalBounds().toFloat(), 6.0f, 6.0f,
Colour (0xffdddddd).overlaidWith (c),
Colour (0xffffffff).overlaidWith (c));
Colour (0xffdddddd).overlaidWith (col),
Colour (0xffffffff).overlaidWith (col));
} }
void mouseDown (const MouseEvent&) override void mouseDown (const MouseEvent&) override
@@ -310,7 +310,7 @@ private:
}; };
//============================================================================== //==============================================================================
ColourSelector::ColourSelector (const int sectionsToShow, const int edge, const int gapAroundColourSpaceComponent)
ColourSelector::ColourSelector (int sectionsToShow, int edge, int gapAroundColourSpaceComponent)
: colour (Colours::white), : colour (Colours::white),
flags (sectionsToShow), flags (sectionsToShow),
edgeGap (edge) edgeGap (edge)
@@ -322,10 +322,15 @@ ColourSelector::ColourSelector (const int sectionsToShow, const int edge, const
if ((flags & showSliders) != 0) if ((flags & showSliders) != 0)
{ {
addAndMakeVisible (sliders[0] = new ColourComponentSlider (TRANS ("red")));
addAndMakeVisible (sliders[1] = new ColourComponentSlider (TRANS ("green")));
addAndMakeVisible (sliders[2] = new ColourComponentSlider (TRANS ("blue")));
addChildComponent (sliders[3] = new ColourComponentSlider (TRANS ("alpha")));
sliders[0].reset (new ColourComponentSlider (TRANS ("red")));
sliders[1].reset (new ColourComponentSlider (TRANS ("green")));
sliders[2].reset (new ColourComponentSlider (TRANS ("blue")));
sliders[3].reset (new ColourComponentSlider (TRANS ("alpha")));
addAndMakeVisible (sliders[0].get());
addAndMakeVisible (sliders[1].get());
addAndMakeVisible (sliders[2].get());
addChildComponent (sliders[3].get());
sliders[3]->setVisible ((flags & showAlphaChannel) != 0); sliders[3]->setVisible ((flags & showAlphaChannel) != 0);
@@ -335,8 +340,11 @@ ColourSelector::ColourSelector (const int sectionsToShow, const int edge, const
if ((flags & showColourspace) != 0) if ((flags & showColourspace) != 0)
{ {
addAndMakeVisible (colourSpace = new ColourSpaceView (*this, h, s, v, gapAroundColourSpaceComponent));
addAndMakeVisible (hueSelector = new HueSelectorComp (*this, h, gapAroundColourSpaceComponent));
colourSpace.reset (new ColourSpaceView (*this, h, s, v, gapAroundColourSpaceComponent));
hueSelector.reset (new HueSelectorComp (*this, h, gapAroundColourSpaceComponent));
addAndMakeVisible (colourSpace.get());
addAndMakeVisible (hueSelector.get());
} }
update (dontSendNotification); update (dontSendNotification);
@@ -491,7 +499,7 @@ void ColourSelector::resized()
if ((flags & showSliders) != 0) if ((flags & showSliders) != 0)
{ {
const int sliderHeight = jmax (4, sliderSpace / numSliders);
auto sliderHeight = jmax (4, sliderSpace / numSliders);
for (int i = 0; i < numSliders; ++i) for (int i = 0; i < numSliders; ++i)
{ {
@@ -561,7 +569,7 @@ int ColourSelector::getNumSwatches() const
return 0; return 0;
} }
Colour ColourSelector::getSwatchColour (const int) const
Colour ColourSelector::getSwatchColour (int) const
{ {
jassertfalse; // if you've overridden getNumSwatches(), you also need to implement this method jassertfalse; // if you've overridden getNumSwatches(), you also need to implement this method
return Colours::black; return Colours::black;


+ 2
- 2
modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.cpp View File

@@ -195,7 +195,7 @@ public:
void assignNewKey() void assignNewKey()
{ {
currentKeyEntryWindow = new KeyEntryWindow (owner);
currentKeyEntryWindow.reset (new KeyEntryWindow (owner));
currentKeyEntryWindow->enterModalState (true, ModalCallbackFunction::forComponent (keyChosen, this)); currentKeyEntryWindow->enterModalState (true, ModalCallbackFunction::forComponent (keyChosen, this));
} }
@@ -387,7 +387,7 @@ KeyMappingEditorComponent::KeyMappingEditorComponent (KeyPressMappingSet& mappin
: mappings (mappingManager), : mappings (mappingManager),
resetButton (TRANS ("reset to defaults")) resetButton (TRANS ("reset to defaults"))
{ {
treeItem = new TopLevelItem (*this);
treeItem.reset (new TopLevelItem (*this));
if (showResetToDefaultButton) if (showResetToDefaultButton)
{ {


+ 1
- 1
modules/juce_gui_extra/misc/juce_PreferencesPanel.cpp View File

@@ -122,7 +122,7 @@ void PreferencesPanel::setCurrentPage (const String& pageName)
currentPageName = pageName; currentPageName = pageName;
currentPage.reset(); currentPage.reset();
currentPage = createComponentForPage (pageName);
currentPage.reset (createComponentForPage (pageName));
if (currentPage != nullptr) if (currentPage != nullptr)
{ {


+ 1
- 1
modules/juce_gui_extra/misc/juce_WebBrowserComponent.h View File

@@ -137,7 +137,7 @@ private:
//============================================================================== //==============================================================================
class Pimpl; class Pimpl;
ScopedPointer<Pimpl> browser; ScopedPointer<Pimpl> browser;
bool blankPageShown, unloadPageWhenBrowserIsHidden;
bool blankPageShown = false, unloadPageWhenBrowserIsHidden;
String lastURL; String lastURL;
StringArray lastHeaders; StringArray lastHeaders;
MemoryBlock lastPostData; MemoryBlock lastPostData;


+ 3
- 3
modules/juce_gui_extra/native/juce_AndroidViewComponent.cpp View File

@@ -138,14 +138,14 @@ private:
AndroidViewComponent::AndroidViewComponent() {} AndroidViewComponent::AndroidViewComponent() {}
AndroidViewComponent::~AndroidViewComponent() {} AndroidViewComponent::~AndroidViewComponent() {}
void AndroidViewComponent::setView (void* const view)
void AndroidViewComponent::setView (void* view)
{ {
if (view != getView()) if (view != getView())
{ {
pimpl = nullptr;
pimpl.reset();
if (view != nullptr) if (view != nullptr)
pimpl = new Pimpl ((jobject) view, *this);
pimpl.reset (new Pimpl ((jobject) view, *this));
} }
} }


+ 3
- 3
modules/juce_gui_extra/native/juce_ios_UIViewComponent.mm View File

@@ -106,14 +106,14 @@ private:
UIViewComponent::UIViewComponent() {} UIViewComponent::UIViewComponent() {}
UIViewComponent::~UIViewComponent() {} UIViewComponent::~UIViewComponent() {}
void UIViewComponent::setView (void* const view)
void UIViewComponent::setView (void* view)
{ {
if (view != getView()) if (view != getView())
{ {
pimpl = nullptr;
pimpl.reset();
if (view != nullptr) if (view != nullptr)
pimpl = new Pimpl ((UIView*) view, *this);
pimpl.reset (new Pimpl ((UIView*) view, *this));
} }
} }


+ 2
- 2
modules/juce_gui_extra/native/juce_linux_X11_SystemTrayIcon.cpp View File

@@ -98,14 +98,14 @@ private:
//============================================================================== //==============================================================================
void SystemTrayIconComponent::setIconImage (const Image& newImage) void SystemTrayIconComponent::setIconImage (const Image& newImage)
{ {
pimpl = nullptr;
pimpl.reset();
if (newImage.isValid()) if (newImage.isValid())
{ {
if (! isOnDesktop()) if (! isOnDesktop())
addToDesktop (0); addToDesktop (0);
pimpl = new Pimpl (newImage, (Window) getWindowHandle());
pimpl.reset (new Pimpl (newImage, (Window) getWindowHandle()));
setVisible (true); setVisible (true);
toFront (false); toFront (false);


+ 1
- 1
modules/juce_gui_extra/native/juce_mac_SystemTrayIcon.cpp View File

@@ -236,7 +236,7 @@ void SystemTrayIconComponent::setIconImage (const Image& newImage)
if (newImage.isValid()) if (newImage.isValid())
{ {
if (pimpl == nullptr) if (pimpl == nullptr)
pimpl = new Pimpl (*this, newImage);
pimpl.reset (new Pimpl (*this, newImage));
else else
pimpl->updateIcon (newImage); pimpl->updateIcon (newImage);
} }


+ 4
- 5
modules/juce_gui_extra/native/juce_mac_WebBrowserComponent.mm View File

@@ -356,13 +356,12 @@ private:
}; };
//============================================================================== //==============================================================================
WebBrowserComponent::WebBrowserComponent (const bool unloadWhenHidden)
: blankPageShown (false),
unloadPageWhenBrowserIsHidden (unloadWhenHidden)
WebBrowserComponent::WebBrowserComponent (bool unloadWhenHidden)
: unloadPageWhenBrowserIsHidden (unloadWhenHidden)
{ {
setOpaque (true); setOpaque (true);
addAndMakeVisible (browser = new Pimpl (this));
browser.reset (new Pimpl (this));
addAndMakeVisible (browser.get());
} }
WebBrowserComponent::~WebBrowserComponent() WebBrowserComponent::~WebBrowserComponent()


+ 2
- 2
modules/juce_gui_extra/native/juce_win32_SystemTrayIcon.cpp View File

@@ -203,13 +203,13 @@ void SystemTrayIconComponent::setIconImage (const Image& newImage)
HICON hicon = IconConverters::createHICONFromImage (newImage, TRUE, 0, 0); HICON hicon = IconConverters::createHICONFromImage (newImage, TRUE, 0, 0);
if (pimpl == nullptr) if (pimpl == nullptr)
pimpl = new Pimpl (*this, hicon, (HWND) getWindowHandle());
pimpl.reset (new Pimpl (*this, hicon, (HWND) getWindowHandle()));
else else
pimpl->updateIcon (hicon); pimpl->updateIcon (hicon);
} }
else else
{ {
pimpl = nullptr;
pimpl.reset();
} }
} }


+ 1
- 1
modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp View File

@@ -181,7 +181,7 @@ bool OpenGLFrameBuffer::initialise (OpenGLContext& context, int width, int heigh
jassert (context.isActive()); // The context must be active when creating a framebuffer! jassert (context.isActive()); // The context must be active when creating a framebuffer!
pimpl.reset(); pimpl.reset();
pimpl = new Pimpl (context, width, height, false, false);
pimpl.reset (new Pimpl (context, width, height, false, false));
if (! pimpl->createdOk()) if (! pimpl->createdOk())
pimpl.reset(); pimpl.reset();


+ 1
- 1
modules/juce_osc/osc/juce_OSCReceiver.cpp View File

@@ -593,7 +593,7 @@ OSCReceiver::OSCReceiver() : pimpl (new Pimpl())
OSCReceiver::~OSCReceiver() OSCReceiver::~OSCReceiver()
{ {
pimpl = nullptr;
pimpl.reset();
} }
bool OSCReceiver::connect (int portNumber) bool OSCReceiver::connect (int portNumber)


+ 1
- 1
modules/juce_osc/osc/juce_OSCSender.cpp View File

@@ -300,7 +300,7 @@ OSCSender::OSCSender() : pimpl (new Pimpl())
OSCSender::~OSCSender() OSCSender::~OSCSender()
{ {
pimpl->disconnect(); pimpl->disconnect();
pimpl = nullptr;
pimpl.reset();
} }
//============================================================================== //==============================================================================


+ 1
- 1
modules/juce_video/capture/juce_CameraDevice.cpp View File

@@ -44,7 +44,7 @@ CameraDevice::CameraDevice (const String& nm, int index, int minWidth, int minHe
CameraDevice::~CameraDevice() CameraDevice::~CameraDevice()
{ {
stopRecording(); stopRecording();
pimpl = nullptr;
pimpl.reset();
} }
Component* CameraDevice::createViewerComponent() Component* CameraDevice::createViewerComponent()


Loading…
Cancel
Save