fix: Export shared inst for IWindowManager/Interop

Bugs (fixed):
   * 2 WindowManager instances are created on startup!  This causes many
   problems (for ex, 'IShellWindow.thread_init' is called twice for each
   shell window)
This commit is contained in:
John Colvin committed 2022-04-19 11:42:42 -04:00
1 parent ee1d02991c
commit fbaf15ad34
5 files changed
+9 -10

No files matched your search

@@ -33,7 +33,7 @@ namespace mbts.spark {
[ImportingConstructor]
public AnalyticsShellModule(
IBus bus, IWindowManager wm, UserSettingsHub settings_hub, OrdersModel orders_model) {
IBus bus, WindowManager wm, UserSettingsHub settings_hub, OrdersModel orders_model) {
_wm = wm;
_bus = bus;
var reports_demuxer = new TableUpdateDemuxer<ReportImmutable?, int>(default, false);
@@ -8,6 +8,7 @@
using mbts.persist;
using mbts.spark;
using mbts.ui;
using mbts.ui.shell;
using System;
using System.Collections.Generic;
@@ -27,7 +28,7 @@
[ImportingConstructor]
public TradingShellModule(
IBus bus,
IWindowManager wm,
WindowManager wm,
INotificationService notification_service,
INotificationServiceDataCache notification_service_data_cache,
UserSettingsHub settings_hub,
@@ -20,20 +20,20 @@ namespace mbts.ui.settings {
[Export(typeof(ISettingsCollector))]
class SettingsCollector : ISettingsCollector {
IWindowsInterop _interop;
IWindowManager _wm;
WindowManager _wm;
ILauncher _launcher;
[ImportingConstructor]
public SettingsCollector(IWindowManager wm, IWindowsInterop interop, ILauncher launcher) {
public SettingsCollector(WindowManager wm, ILauncher launcher) {
_wm = wm;
_interop = interop;
_launcher = launcher;
}
[Import]
public ObservableCollection<IShellModule> modules { get; set; }
IWindowsInterop _interop => _wm;
public IEnumerable<WindowState> get_window_state() {
foreach (var window in _wm.list_windows()) {
// Check that the window is still open since we might be iterating asyncronously
@@ -23,8 +23,6 @@ namespace mbts.ui.shell {
// When a new tab is created the WindowManager checks to see if it is requesting an existing FloatingWindow
// If so it adds it to that window otherwise it creates a new window.
[Export(typeof(IWindowManager))]
[Export(typeof(IWindowsInterop))]
[Export]
public class WindowManager : IWindowManager, IWindowsInterop, IDisposable {
readonly IShellThreadFactory _threads;
@@ -27,7 +27,7 @@ namespace mbts.ui.shell {
ISettingsCollector _settings_collector;
private ISavedWindowFactory _window_restore;
IWindowManager _wm;
WindowManager _wm;
private IPersist _public;
private IPersist _private;
private ObservableCollection<IShellModule> _modules;
@@ -69,7 +69,7 @@ namespace mbts.ui.shell {
}
[Import]
public IWindowManager window_manager {
public WindowManager window_manager {
get => _wm;
set {
_wm = value;