Skip to content

Commit 486a606

Browse files
committed
Fix ability to open same patch twice
1 parent 043199a commit 486a606

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

Source/TabComponent.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,18 @@ Canvas* TabComponent::newPatch()
310310

311311
void TabComponent::openHelpPatch(const URL& path)
312312
{
313+
for (auto* editor : pd->getEditors()) {
314+
for (auto* cnv : editor->getCanvases()) {
315+
if (cnv->patch.getCurrentFile() == path.getLocalFile()) {
316+
pd->logError("Patch is already open");
317+
editor->getTopLevelComponent()->toFront(true);
318+
editor->getTabComponent().showTab(cnv, cnv->patch.splitViewIndex);
319+
editor->getTabComponent().setActiveSplit(cnv);
320+
return;
321+
}
322+
}
323+
}
324+
313325
auto const patch = pd->loadPatch(path);
314326

315327
if (auto p = patch->getPointer()) {
@@ -343,6 +355,7 @@ void TabComponent::openPatch(const URL& path)
343355
editor->getTopLevelComponent()->toFront(true);
344356
editor->getTabComponent().showTab(cnv, cnv->patch.splitViewIndex);
345357
editor->getTabComponent().setActiveSplit(cnv);
358+
return;
346359
}
347360
}
348361
}

0 commit comments

Comments
 (0)