Skip to content

Commit

Permalink
Merge pull request #623 from SkyTemple/migrate-to-views
Browse files Browse the repository at this point in the history
Migrate Views
  • Loading branch information
theCapypara authored Mar 30, 2024
2 parents d64ffd1 + e131a27 commit ef07d93
Show file tree
Hide file tree
Showing 191 changed files with 11,126 additions and 10,140 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/build-test-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ jobs:
$env:INCLUDE = "C:\gtk-build\gtk\x64\release\include;C:\gtk-build\gtk\x64\release\include\cairo;C:\gtk-build\gtk\x64\release\include\glib-2.0;C:\gtk-build\gtk\x64\release\include\gobject-introspection-1.0;C:\gtk-build\gtk\x64\release\lib\glib-2.0\include;" + $env:INCLUDE
cd installer
pip debug --verbose # print compatible tags etc. for debugging purposes
# Package
.\build-windows.ps1 $PACKAGE_VERSION
Expand Down Expand Up @@ -246,11 +248,11 @@ jobs:
# git is already installed.
brew install enchant pygobject3 gtk+3 [email protected] gtksourceview4 adwaita-icon-theme sdl12-compat sdl2 cmake
python3 -m venv .venv
python3.11 -m venv .venv
. .venv/bin/activate
pip3 debug --verbose # print compatible tags etc. for debugging purposes
pip3 install -U certifi
PATH=/usr/local/opt/[email protected]/bin:/usr/local/bin:$PATH
# Install other dependencies and SkyTemple itself
Expand Down Expand Up @@ -332,8 +334,9 @@ jobs:
# git is already installed.
brew install enchant pygobject3 gtk+3 [email protected] gtksourceview4 adwaita-icon-theme sdl12-compat sdl2 meson cmake
python3 -m venv .venv
python3.11 -m venv .venv
. .venv/bin/activate
pip3 debug --verbose # print compatible tags etc. for debugging purposes
pip3 install -U certifi
export PATH=/usr/local/opt/[email protected]/bin:/usr/local/bin:/opt/homebrew/bin:$PATH
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,4 @@ venv.bak/
*.glade~

.vscode/
massif.out.*
36 changes: 36 additions & 0 deletions mem_profile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
export SKYTEMPLE_MEMPROFILE=1
export G_SLICE=always-malloc
export PYTHONMALLOC=malloc
exec valgrind \
--tool=massif \
--num-callers=50 \
--trace-children=no \
--threshold=0.1 \
--alloc-fn=g_malloc \
--alloc-fn=g_object_new \
--alloc-fn=g_malloc0 \
--alloc-fn=g_malloc0_n \
--alloc-fn=g_malloc_n \
--alloc-fn=g_realloc \
--alloc-fn=g_realloc_n \
--alloc-fn=g_slice_alloc \
--alloc-fn=g_slice_alloc0 \
--alloc-fn=g_type_create_instance \
--alloc-fn=g_object_new_internal \
--alloc-fn=g_object_new_with_properties \
--alloc-fn=g_object_newv \
--alloc-fn=g_object_new_valist \
--alloc-fn=g_try_malloc \
--alloc-fn=g_try_malloc_n \
--alloc-fn=g_hash_table_realloc_key_or_value_array \
--alloc-fn=realloc_arrays \
--alloc-fn=g_hash_table_resize \
--alloc-fn=g_hash_table_maybe_resize \
--alloc-fn=g_hash_table_insert_node \
--alloc-fn=g_hash_table_insert_internal \
--alloc-fn=g_hash_table_setup_storage \
--alloc-fn=tracemalloc_realloc \
--alloc-fn=realloc \
--alloc-fn=calloc \
python -m skytemple.main
8 changes: 5 additions & 3 deletions skytemple/controller/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ def reload_view(cls):
view_cls.__class__,
assert_not_none(cls._instance._current_view_item_id),
assert_not_none(cls._instance),
)
),
threadsafe=False,
)

@classmethod
Expand Down Expand Up @@ -486,7 +487,8 @@ def load_view(
self._current_view_controller_class,
self._current_view_item_id,
self,
)
),
threadsafe=False,
)
# Expand the node
tree.expand_to_path(path)
Expand Down Expand Up @@ -555,7 +557,7 @@ def on_view_loaded(
EventManager.instance().trigger(
EVT_VIEW_SWITCH,
module=module,
controller=in_view,
view=in_view,
breadcrumbs=self._current_breadcrumbs,
)

Expand Down
9 changes: 7 additions & 2 deletions skytemple/core/async_tasks/delegator.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,17 @@ def run_main(cls, app: Gio.Application):
sys.exit(exit_code)

@classmethod
def run_task(cls, coro: Coroutine):
def run_task(cls, coro: Coroutine, threadsafe=True):
"""
This runs the coroutine, depending on the current configuration for async tasks.
If the task is marked as not threadsafe (=it is expected to run on the calling thread) the task
may be run immediately instead of the configured async strategy.
"""
if cls.config_type().async_task_runner_type == AsyncTaskRunnerType.THREAD_BASED:
AsyncTaskRunner.instance().run_task(coro)
if not threadsafe:
Now.instance().run_task(coro)
else:
AsyncTaskRunner.instance().run_task(coro)
elif (
cls.config_type().async_task_runner_type
== AsyncTaskRunnerType.EVENT_LOOP_BLOCKING
Expand Down
6 changes: 4 additions & 2 deletions skytemple/core/events/abstract_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# You should have received a copy of the GNU General Public License
# along with SkyTemple. If not, see <https://www.gnu.org/licenses/>.
from abc import ABC
from typing import Union
from gi.repository import Gtk

from skytemple.core.abstract_module import AbstractModule
from skytemple.core.module_controller import AbstractController
Expand Down Expand Up @@ -50,13 +52,13 @@ def on_project_open(self, project: RomProject):
def on_view_switch(
self,
module: AbstractModule,
controller: AbstractController,
view: Union[AbstractController, Gtk.Widget],
breadcrumbs: list[str],
):
"""
Triggered, when a view in the main UI was fully and successfully loaded.
:param module: Instance of the module, that the view belongs to.
:param controller: Instance of the controller that handles the loaded view
:param view: Instance of the view that handles the loaded view
:param breadcrumbs: List of strings of the path in the main UI tree that lead up to this view (as displayed
in the titlebar). The most inner level is the first entry.
"""
Expand Down
Loading

0 comments on commit ef07d93

Please sign in to comment.