Skip to content

Commit

Permalink
Fix instance being created before workspace (angr#1296)
Browse files Browse the repository at this point in the history
  • Loading branch information
twizmwazin authored Jul 23, 2024
1 parent cb003a8 commit 39b4a11
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
3 changes: 1 addition & 2 deletions angrmanagement/ui/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
from angrmanagement.config import IMG_LOCATION, Conf, save_config
from angrmanagement.daemon import daemon_conn, daemon_exists, run_daemon_process
from angrmanagement.daemon.client import ClientService
from angrmanagement.data.instance import Instance
from angrmanagement.data.jobs import DependencyAnalysisJob
from angrmanagement.data.jobs.loading import LoadAngrDBJob, LoadBinaryJob, LoadTargetJob
from angrmanagement.data.library_docs import LibraryDocs
Expand Down Expand Up @@ -372,7 +371,7 @@ def _init_workspace(self) -> None:
self.dock_manager.setAutoHideConfigFlags(QtAds.CDockManager.DefaultAutoHideConfig)
self.dock_manager.createSideTabBarWidgets()
self.setCentralWidget(self.dock_manager)
wk = Workspace(self, Instance())
wk = Workspace(self)
self.workspace = wk

def set_caption(**kwargs) -> None: # pylint: disable=unused-argument
Expand Down
20 changes: 9 additions & 11 deletions angrmanagement/ui/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
VariableRecoveryConfiguration,
)
from angrmanagement.data.breakpoint import Breakpoint, BreakpointType
from angrmanagement.data.instance import ObjectContainer
from angrmanagement.data.instance import Instance, ObjectContainer
from angrmanagement.data.jobs import (
CFGGenerationJob,
CodeTaggingJob,
Expand Down Expand Up @@ -78,7 +78,6 @@
from collections.abc import Callable
from typing import Any

from angrmanagement.data.instance import Instance
from angrmanagement.ui.main_window import MainWindow


Expand All @@ -93,11 +92,8 @@ class Workspace:

job_manager: JobManager

def __init__(self, main_window: MainWindow, instance: Instance) -> None:
def __init__(self, main_window: MainWindow) -> None:
self.main_window: MainWindow = main_window
self._main_instance = instance
instance.workspace = self

self.job_manager = JobManager(self)

self.command_manager: CommandManager = CommandManager()
Expand All @@ -106,11 +102,13 @@ def __init__(self, main_window: MainWindow, instance: Instance) -> None:
self.variable_recovery_job: VariableRecoveryJob | None = None
self._first_cfg_generation_callback_completed: bool = False

self._main_instance = Instance()

# Configure callbacks on main_instance
instance.project.am_subscribe(self._instance_project_initalization)
instance.simgrs.am_subscribe(self._update_simgr_debuggers)
instance.handle_comment_changed_callback = self.plugins.handle_comment_changed
instance.job_worker_exception_callback = self._handle_job_exception
self.main_instance.project.am_subscribe(self._instance_project_initalization)
self.main_instance.simgrs.am_subscribe(self._update_simgr_debuggers)
self.main_instance.handle_comment_changed_callback = self.plugins.handle_comment_changed
self.main_instance.job_worker_exception_callback = self._handle_job_exception

self.current_screen = ObjectContainer(None, name="current_screen")

Expand Down Expand Up @@ -143,7 +141,7 @@ def __init__(self, main_window: MainWindow, instance: Instance) -> None:

DisassemblyView.register_commands(self)

instance.patches.am_subscribe(self._on_patch_event)
self.main_instance.patches.am_subscribe(self._on_patch_event)

#
# Properties
Expand Down

0 comments on commit 39b4a11

Please sign in to comment.