OK, very simple tutorial (code below). When attempting to build/run on Mac OSX Mojave, I first receive the warnings that “~ScopedPointer is deprecated” - but the tutorial runs.
Following the warnings around, I read in the JUCE source that:
// ScopedPointer is deprecated! You should use std::unique_ptr instead.
JUCE_DEPRECATED_ATTRIBUTE inline ScopedPointer() = default;
So I change the variable in the tutorial to:
//ScopedPointer<MainWindow> mainWindow;
std::unique_ptr<MainWindow> mainWindow;
However, now when I try to build it, I receive the error “no viable overloaded ‘=’” on this line:
mainWindow = new MainWindow (getApplicationName());
What would be the correct way nowadays for this?
//==============================================================================
class MainWindowTutorialApplication : public JUCEApplication
{
public:
//==============================================================================
MainWindowTutorialApplication() {}
const String getApplicationName() override { return ProjectInfo::projectName; }
const String getApplicationVersion() override { return ProjectInfo::versionString; }
bool moreThanOneInstanceAllowed() override { return true; }
//==============================================================================
void initialise (const String& commandLine) override
{
// Add your application's initialisation code here..
mainWindow = new MainWindow (getApplicationName());
}
void shutdown() override
{
// Add your application's shutdown code here..
mainWindow = nullptr;
}
//==============================================================================
void systemRequestedQuit() override
{
// This is called when the app is being asked to quit: you can ignore this
// request and let the app carry on running, or call quit() to allow the app to close.
quit();
}
void anotherInstanceStarted (const String& commandLine) override
{
// When another instance of the app is launched while this one is running,
// this method is invoked, and the commandLine parameter tells you what
// the other instance's command-line arguments were.
}
//==============================================================================
class MainWindow : public DocumentWindow
{
public:
MainWindow (String name) : DocumentWindow (name,
Colours::lightgrey,
DocumentWindow::allButtons)
{
centreWithSize (300, 200);
setVisible (true);
}
void closeButtonPressed() override
{
JUCEApplication::getInstance()->systemRequestedQuit();
}
private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainWindow)
};
private:
std::unique_ptr<MainWindow> mainWindow;
//ScopedPointer<MainWindow> mainWindow;
};
//==============================================================================
// This macro generates the main() routine that launches the app.
START_JUCE_APPLICATION (MainWindowTutorialApplication)
