mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-22 01:34:21 +00:00
Use NullCheckedInvocation in more places
This commit is contained in:
parent
84750f2f2a
commit
ff0cb4ad5b
46 changed files with 145 additions and 258 deletions
|
|
@ -235,8 +235,7 @@ void MainWindow::closeCurrentProject (OpenDocumentManager::SaveIfNeeded askUserT
|
|||
{
|
||||
if (currentProject == nullptr)
|
||||
{
|
||||
if (callback != nullptr)
|
||||
callback (true);
|
||||
NullCheckedInvocation::invoke (callback, true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
@ -259,8 +258,7 @@ void MainWindow::closeCurrentProject (OpenDocumentManager::SaveIfNeeded askUserT
|
|||
|
||||
if (! closedSuccessfully)
|
||||
{
|
||||
if (callback != nullptr)
|
||||
callback (false);
|
||||
NullCheckedInvocation::invoke (callback, false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
@ -269,8 +267,7 @@ void MainWindow::closeCurrentProject (OpenDocumentManager::SaveIfNeeded askUserT
|
|||
{
|
||||
parent->setProject (nullptr);
|
||||
|
||||
if (callback != nullptr)
|
||||
callback (true);
|
||||
NullCheckedInvocation::invoke (callback, true);
|
||||
};
|
||||
|
||||
if (askUserToSave == OpenDocumentManager::SaveIfNeeded::no)
|
||||
|
|
@ -286,8 +283,8 @@ void MainWindow::closeCurrentProject (OpenDocumentManager::SaveIfNeeded askUserT
|
|||
|
||||
if (saveResult == FileBasedDocument::savedOk)
|
||||
setProjectAndCallback();
|
||||
else if (callback != nullptr)
|
||||
callback (false);
|
||||
else
|
||||
NullCheckedInvocation::invoke (callback, false);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
@ -392,15 +389,13 @@ void MainWindow::openFile (const File& file, std::function<void (bool)> callback
|
|||
parent->currentProject->updateDeprecatedProjectSettingsInteractively();
|
||||
}
|
||||
|
||||
if (callback != nullptr)
|
||||
callback (saveResult);
|
||||
NullCheckedInvocation::invoke (callback, saveResult);
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (callback != nullptr)
|
||||
callback (false);
|
||||
NullCheckedInvocation::invoke (callback, false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
@ -413,9 +408,7 @@ void MainWindow::openFile (const File& file, std::function<void (bool)> callback
|
|||
if (parent != nullptr)
|
||||
{
|
||||
parent->createProjectContentCompIfNeeded();
|
||||
|
||||
if (callback != nullptr)
|
||||
callback (parent->getProjectContentComponent()->showEditorForFile (file, true));
|
||||
NullCheckedInvocation::invoke (callback, parent->getProjectContentComponent()->showEditorForFile (file, true));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -428,9 +421,7 @@ void MainWindow::openFile (const File& file, std::function<void (bool)> callback
|
|||
|
||||
if (openedSuccessfully)
|
||||
{
|
||||
if (callback != nullptr)
|
||||
callback (true);
|
||||
|
||||
NullCheckedInvocation::invoke (callback, true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -444,8 +435,7 @@ void MainWindow::openFile (const File& file, std::function<void (bool)> callback
|
|||
return;
|
||||
}
|
||||
|
||||
if (callback != nullptr)
|
||||
callback (false);
|
||||
NullCheckedInvocation::invoke (callback, false);
|
||||
}
|
||||
|
||||
void MainWindow::openPIP (const File& pipFile, std::function<void (bool)> callback)
|
||||
|
|
@ -454,9 +444,7 @@ void MainWindow::openPIP (const File& pipFile, std::function<void (bool)> callba
|
|||
|
||||
if (! generator->hasValidPIP())
|
||||
{
|
||||
if (callback != nullptr)
|
||||
callback (false);
|
||||
|
||||
NullCheckedInvocation::invoke (callback, false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -469,9 +457,7 @@ void MainWindow::openPIP (const File& pipFile, std::function<void (bool)> callba
|
|||
generatorResult.getErrorMessage());
|
||||
messageBox = AlertWindow::showScopedAsync (options, nullptr);
|
||||
|
||||
if (callback != nullptr)
|
||||
callback (false);
|
||||
|
||||
NullCheckedInvocation::invoke (callback, false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -482,9 +468,7 @@ void MainWindow::openPIP (const File& pipFile, std::function<void (bool)> callba
|
|||
"Failed to create Main.cpp.");
|
||||
messageBox = AlertWindow::showScopedAsync (options, nullptr);
|
||||
|
||||
if (callback != nullptr)
|
||||
callback (false);
|
||||
|
||||
NullCheckedInvocation::invoke (callback, false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -500,16 +484,13 @@ void MainWindow::openPIP (const File& pipFile, std::function<void (bool)> callba
|
|||
"Failed to open .jucer file.");
|
||||
parent->messageBox = AlertWindow::showScopedAsync (options, nullptr);
|
||||
|
||||
if (callback != nullptr)
|
||||
callback (false);
|
||||
|
||||
NullCheckedInvocation::invoke (callback, false);
|
||||
return;
|
||||
}
|
||||
|
||||
parent->setupTemporaryPIPProject (*generator);
|
||||
|
||||
if (callback != nullptr)
|
||||
callback (true);
|
||||
NullCheckedInvocation::invoke (callback, true);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -746,9 +727,7 @@ static void askAllWindowsToCloseRecursive (WeakReference<MainWindowList> parent,
|
|||
{
|
||||
if (parent->windows.size() == 0)
|
||||
{
|
||||
if (callback != nullptr)
|
||||
callback (true);
|
||||
|
||||
NullCheckedInvocation::invoke (callback, true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -759,9 +738,7 @@ static void askAllWindowsToCloseRecursive (WeakReference<MainWindowList> parent,
|
|||
|
||||
if (! closedSuccessfully)
|
||||
{
|
||||
if (callback != nullptr)
|
||||
callback (false);
|
||||
|
||||
NullCheckedInvocation::invoke (callback, false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -845,9 +822,7 @@ void MainWindowList::openFile (const File& file, std::function<void (bool)> call
|
|||
{
|
||||
if (! file.exists())
|
||||
{
|
||||
if (callback != nullptr)
|
||||
callback (false);
|
||||
|
||||
NullCheckedInvocation::invoke (callback, false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -857,9 +832,7 @@ void MainWindowList::openFile (const File& file, std::function<void (bool)> call
|
|||
{
|
||||
w->toFront (true);
|
||||
|
||||
if (callback != nullptr)
|
||||
callback (true);
|
||||
|
||||
NullCheckedInvocation::invoke (callback, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -893,8 +866,7 @@ void MainWindowList::openFile (const File& file, std::function<void (bool)> call
|
|||
parent->closeWindow (w);
|
||||
}
|
||||
|
||||
if (callback != nullptr)
|
||||
callback (openedSuccessfully);
|
||||
NullCheckedInvocation::invoke (callback, openedSuccessfully);
|
||||
});
|
||||
|
||||
return;
|
||||
|
|
@ -902,8 +874,8 @@ void MainWindowList::openFile (const File& file, std::function<void (bool)> call
|
|||
|
||||
getFrontmostWindow()->openFile (file, [parent, callback] (bool openedSuccessfully)
|
||||
{
|
||||
if (parent != nullptr && callback != nullptr)
|
||||
callback (openedSuccessfully);
|
||||
if (parent != nullptr)
|
||||
NullCheckedInvocation::invoke (callback, openedSuccessfully);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue