From 479ed0300add743b8a6ee25bf2c47265bce4c78a Mon Sep 17 00:00:00 2001 From: SpoinkyNL Date: Mon, 14 Nov 2016 12:36:55 +0100 Subject: [PATCH] Fixed a crash on Bubbles and Overlay views --- Artemis/Artemis/Resources/lua-placeholder.lua | 9 ++++++--- Artemis/Artemis/ViewModels/ShellViewModel.cs | 6 ++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Artemis/Artemis/Resources/lua-placeholder.lua b/Artemis/Artemis/Resources/lua-placeholder.lua index 697a08bdc..87b7a962a 100644 --- a/Artemis/Artemis/Resources/lua-placeholder.lua +++ b/Artemis/Artemis/Resources/lua-placeholder.lua @@ -5,7 +5,7 @@ -- This is a default script to be executed by Artemis. -- You do not need to use this if you don't want to script. The default profiles -- should provide you with a lot of functionality out of the box. --- However, if you wan't to change the way profiles work, this is the ideal way +-- However, if you want to change the way profiles work, this is the ideal way -- go about it. -- For docs and examples, see wiki: https://github.com/SpoinkyNL/Artemis/wiki/LUA @@ -15,7 +15,9 @@ -- This event is raised after every profile update, before drawing. function updateHandler(profile, eventArgs) - -- In this example we only want to update once per frame when the keyboard is updated + -- In this example we only want to update once per frame when the keyboard is + -- updated. If you don't do this the updateHandler will trigger on every + -- device's update. if eventArgs.DeviceType != "keyboard" then return end @@ -25,7 +27,8 @@ end -- This event is raised after every profile draw, after updating. function drawHandler(profile, eventArgs) - -- In this example we only want to draw to the keyboard + -- In this example we only want to draw to the keyboard. Each device has it's + -- own drawing event if eventArgs.DeviceType != "keyboard" then return end diff --git a/Artemis/Artemis/ViewModels/ShellViewModel.cs b/Artemis/Artemis/ViewModels/ShellViewModel.cs index de8d7c5de..163fdb432 100644 --- a/Artemis/Artemis/ViewModels/ShellViewModel.cs +++ b/Artemis/Artemis/ViewModels/ShellViewModel.cs @@ -141,6 +141,12 @@ namespace Artemis.ViewModels CheckDuplicateInstances(); Updater.CheckChangelog(MetroDialogService); + // Run this on the UI thread to avoid having to use dispatchers in VMs + Execute.OnUIThread(ActivateViews); + } + + private void ActivateViews() + { var vms = _kernel.GetAll().ToList(); Items.Clear(); Items.AddRange(vms);