Merge remote-tracking branch 'origin/patch'

This commit is contained in:
Ryan Kurtz 2024-06-24 13:59:30 -04:00
commit e9e4ee48ce
6 changed files with 21 additions and 42 deletions

View file

@ -93,34 +93,28 @@ public class ProgramOpener {
*/ */
public Program openProgram(ProgramLocator locator, TaskMonitor monitor) { public Program openProgram(ProgramLocator locator, TaskMonitor monitor) {
if (locator.isURL()) { if (locator.isURL()) {
try { return openURL(locator, monitor);
return openURL(locator, monitor);
}
catch (CancelledException e) {
return null;
}
catch (IOException e) {
Msg.showError(this, null, "Program Open Failed",
"Failed to open Ghidra URL: " + locator.getURL());
}
return null;
} }
return openProgram(locator, locator.getDomainFile(), monitor); return openProgram(locator, locator.getDomainFile(), monitor);
} }
private Program openURL(ProgramLocator locator, TaskMonitor monitor) private Program openURL(ProgramLocator locator, TaskMonitor monitor) {
throws CancelledException, IOException {
URL ghidraUrl = locator.getURL(); URL ghidraUrl = locator.getURL();
AtomicReference<Program> openedProgram = new AtomicReference<>(); AtomicReference<Program> openedProgram = new AtomicReference<>();
GhidraURLQuery.queryUrl(ghidraUrl, new GhidraURLResultHandlerAdapter() { try {
@Override GhidraURLQuery.queryUrl(ghidraUrl, new GhidraURLResultHandlerAdapter() {
public void processResult(DomainFile domainFile, URL url, TaskMonitor m) { @Override
Program p = openProgram(locator, domainFile, m); // may return null public void processResult(DomainFile domainFile, URL url, TaskMonitor m) {
openedProgram.set(p); Program p = openProgram(locator, domainFile, m); // may return null
} openedProgram.set(p);
}, monitor); }
}, monitor);
}
catch (IOException | CancelledException e) {
// IOException reported to user by GhidraURLResultHandlerAdapter
return null;
}
return openedProgram.get(); return openedProgram.get();
} }

View file

@ -465,12 +465,6 @@ public class FakeSharedProject {
void refresh() { void refresh() {
DefaultProjectData projectData = getProjectData(); DefaultProjectData projectData = getProjectData();
try { projectData.refresh(true);
projectData.refresh(true);
}
catch (IOException e) {
// shouldn't happen
throw new AssertionFailedError("Unable to refresh project " + this);
}
} }
} }

View file

@ -742,7 +742,7 @@ public class DefaultProjectData implements ProjectData {
} }
@Override @Override
public void refresh(boolean force) throws IOException { public void refresh(boolean force) {
try { try {
rootFolderData.refresh(true, true, projectDisposalMonitor); rootFolderData.refresh(true, true, projectDisposalMonitor);
} }

View file

@ -17,14 +17,12 @@ package ghidra.framework.main.projectdata.actions;
import java.awt.Component; import java.awt.Component;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.io.IOException;
import javax.swing.Icon; import javax.swing.Icon;
import docking.action.*; import docking.action.*;
import ghidra.framework.client.ClientUtil;
import ghidra.framework.main.datatable.ProjectDataContext;
import ghidra.framework.main.datatable.FrontendProjectTreeAction; import ghidra.framework.main.datatable.FrontendProjectTreeAction;
import ghidra.framework.main.datatable.ProjectDataContext;
import ghidra.framework.model.ProjectData; import ghidra.framework.model.ProjectData;
import ghidra.util.HelpLocation; import ghidra.util.HelpLocation;
import ghidra.util.task.*; import ghidra.util.task.*;
@ -53,13 +51,7 @@ public class ProjectDataRefreshAction extends FrontendProjectTreeAction {
TaskLauncher.launch(new Task("Refresh folders and files", false, false, true) { TaskLauncher.launch(new Task("Refresh folders and files", false, false, true) {
@Override @Override
public void run(TaskMonitor monitor) { public void run(TaskMonitor monitor) {
try { projectData.refresh(false);
projectData.refresh(false);
}
catch (IOException e) {
ClientUtil.handleException(projectData.getRepository(), e,
"Refresh Project Data", false, comp);
}
} }
}); });
} }

View file

@ -143,9 +143,8 @@ public interface ProjectData {
* Sync the Domain folder/file structure with the underlying file structure. * Sync the Domain folder/file structure with the underlying file structure.
* @param force if true all folders will be be visited and refreshed, if false * @param force if true all folders will be be visited and refreshed, if false
* only those folders previously visited will be refreshed. * only those folders previously visited will be refreshed.
* @throws IOException if an IO error occurs
*/ */
public void refresh(boolean force) throws IOException; public void refresh(boolean force);
/** /**
* Returns User object associated with remote repository or null if a remote repository * Returns User object associated with remote repository or null if a remote repository

View file

@ -119,7 +119,7 @@ public class TestDummyProjectData implements ProjectData {
} }
@Override @Override
public void refresh(boolean force) throws IOException { public void refresh(boolean force) {
// stub // stub
} }