Skip to content

Commit 2e51c60

Browse files
committed
Fix iOS file opening issue
1 parent 0eb8d5e commit 2e51c60

5 files changed

Lines changed: 22 additions & 21 deletions

File tree

Source/Components/WelcomePanel.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -877,13 +877,13 @@ class WelcomePanel final : public Component
877877

878878
tile->onClick = [this, patchFile]() mutable {
879879
if (patchFile.existsAsFile()) {
880-
editor->pd->autosave->checkForMoreRecentAutosave(patchFile, editor, [this](File patchFile, File patchPath) {
881-
auto* cnv = editor->getTabComponent().openPatch(URL(patchFile));
880+
editor->pd->autosave->checkForMoreRecentAutosave(URL(patchFile), editor, [this](URL const& patchFile, URL const& patchPath) {
881+
auto* cnv = editor->getTabComponent().openPatch(patchFile);
882882
if(cnv)
883883
{
884-
cnv->patch.setCurrentFile(URL(patchPath));
884+
cnv->patch.setCurrentFile(patchPath);
885885
}
886-
SettingsFile::getInstance()->addToRecentlyOpened(patchPath);
886+
SettingsFile::getInstance()->addToRecentlyOpened(patchPath.getLocalFile());
887887
});
888888
} else {
889889
editor->pd->logError("Patch not found");

Source/Dialogs/MainMenu.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ class MainMenu : public PopupMenu {
3131
auto path = File(recentlyOpenedTree.getChild(i).getProperty("Path").toString());
3232
recentlyOpened->addItem(path.getFileName(), [path, editor]() mutable {
3333
if (path.existsAsFile()) {
34-
editor->pd->autosave->checkForMoreRecentAutosave(path, editor, [editor](File patchFile, File patchPath) {
35-
auto* cnv = editor->getTabComponent().openPatch(URL(patchFile));
34+
editor->pd->autosave->checkForMoreRecentAutosave(URL(path), editor, [editor](URL const& patchFile, URL const& patchPath) {
35+
auto* cnv = editor->getTabComponent().openPatch(patchFile);
3636
if(cnv)
3737
{
38-
cnv->patch.setCurrentFile(URL(patchPath));
38+
cnv->patch.setCurrentFile(patchPath);
3939
}
40-
SettingsFile::getInstance()->addToRecentlyOpened(patchPath);
40+
SettingsFile::getInstance()->addToRecentlyOpened(patchPath.getLocalFile());
4141
});
4242
} else {
4343
editor->pd->logError("Patch not found");

Source/PluginEditor.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -903,13 +903,13 @@ void PluginEditor::filesDropped(StringArray const& files, int const x, int const
903903
auto file = File(path);
904904
if (file.exists() && file.hasFileExtension("pd")) {
905905
openedPdFiles = true;
906-
pd->autosave->checkForMoreRecentAutosave(file, this, [this](File patchFile, File patchPath) {
907-
auto* cnv = tabComponent.openPatch(URL(patchFile));
906+
pd->autosave->checkForMoreRecentAutosave(URL(file), this, [this](URL const& patchFile, URL const& patchPath) {
907+
auto* cnv = tabComponent.openPatch(patchFile);
908908
if(cnv)
909909
{
910-
cnv->patch.setCurrentFile(URL(patchPath));
910+
cnv->patch.setCurrentFile(patchPath);
911911
}
912-
SettingsFile::getInstance()->addToRecentlyOpened(patchPath);
912+
SettingsFile::getInstance()->addToRecentlyOpened(patchPath.getLocalFile());
913913
});
914914
}
915915
if (file.exists() && file.hasFileExtension("plugdata")) {

Source/TabComponent.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,13 +377,13 @@ void TabComponent::openPatch()
377377
Dialogs::showOpenDialog([this](URL resultURL) {
378378
auto result = resultURL.getLocalFile();
379379
if (result.exists() && result.getFileExtension().equalsIgnoreCase(".pd")) {
380-
editor->pd->autosave->checkForMoreRecentAutosave(result, editor, [this, result, resultURL](File patchFile, File patchPath) {
381-
auto* cnv = openPatch(URL(patchFile));
380+
editor->pd->autosave->checkForMoreRecentAutosave(resultURL, editor, [this](URL const& patchFile, URL const& patchPath) {
381+
auto* cnv = openPatch(patchFile);
382382
if(cnv)
383383
{
384-
cnv->patch.setCurrentFile(URL(patchPath));
384+
cnv->patch.setCurrentFile(patchPath);
385385
}
386-
SettingsFile::getInstance()->addToRecentlyOpened(patchPath);
386+
SettingsFile::getInstance()->addToRecentlyOpened(patchPath.getLocalFile());
387387
});
388388
}
389389
},

Source/Utility/Autosave.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,17 @@ class Autosave final : public Timer
3838
}
3939

4040
// Call this whenever we load a file
41-
static void checkForMoreRecentAutosave(File& patchPath, PluginEditor* editor, std::function<void(File, File)> callback)
41+
static void checkForMoreRecentAutosave(URL const& patchUrl, PluginEditor* editor, std::function<void(URL const&, URL const&)> callback)
4242
{
43+
auto patchPath = patchUrl.getLocalFile();
4344
auto lastAutoSavedPatch = autoSaveTree.getChildWithProperty("Path", patchPath.getFullPathName());
4445
auto const autoSavedTime = static_cast<int64>(lastAutoSavedPatch.getProperty("LastModified"));
4546
auto const fileChangedTime = patchPath.getLastModificationTime().toMilliseconds();
4647
if (lastAutoSavedPatch.isValid() && autoSavedTime > fileChangedTime) {
4748
auto const timeDescription = RelativeTime((autoSavedTime - fileChangedTime) / 1000.0f).getApproximateDescription();
4849

4950
Dialogs::showMultiChoiceDialog(
50-
&editor->openedDialog, editor, "Restore autosave?\n (last autosave is " + timeDescription + " newer)", [lastAutoSavedPatch, patchPath, callback, editor](int const dontUseAutosaved) {
51+
&editor->openedDialog, editor, "Restore autosave?\n (last autosave is " + timeDescription + " newer)", [lastAutoSavedPatch, patchUrl, patchPath, callback, editor](int const dontUseAutosaved) {
5152
if (!dontUseAutosaved) {
5253
MemoryOutputStream ostream;
5354
Base64::convertFromBase64(ostream, lastAutoSavedPatch.getProperty("Patch").toString());
@@ -56,16 +57,16 @@ class Autosave final : public Timer
5657
glob_forcefilename(editor->pd->generateSymbol(patchPath.getFileName().toRawUTF8()), editor->pd->generateSymbol(patchPath.getParentDirectory().getFullPathName().replaceCharacter('\\', '/').toRawUTF8()));
5758
auto patchFile = File::createTempFile(".pd");
5859
patchFile.replaceWithText(autosavedPatch);
59-
callback(patchFile, patchPath);
60+
callback(URL(patchFile), patchUrl);
6061
}
6162
else {
62-
callback(patchPath, patchPath);
63+
callback(URL(patchPath), patchUrl);
6364
}
6465

6566
},
6667
{ "Yes", "No" });
6768
} else {
68-
callback(patchPath, patchPath);
69+
callback(patchUrl, patchUrl);
6970
}
7071
}
7172

0 commit comments

Comments
 (0)