Cancelling quit - onApplicationQuit

Ask for help and post bugs.

Cancelling quit - onApplicationQuit

Postby kokosnoot » Mon Sep 25, 2017 12:46 pm


In my application I am cancelling Unity's quit (eg. after Alt-F4) in order to display a quit confirmation. This will generate a lot of errors in the build exe version:

Code: Select all
NullReferenceException: Object reference not set to an instance of an object
  at TouchScript.Layers.StandardLayer.performSSUISearch (IPointer pointer, TouchScript.Hit.HitData& hit) [0x00000] in <filename unknown>:0
  at TouchScript.Layers.StandardLayer.Hit (IPointer pointer, TouchScript.Hit.HitData& hit) [0x00000] in <filename unknown>:0
  at TouchScript.Core.LayerManagerInstance.GetHitTarget (IPointer pointer, TouchScript.Hit.HitData& hit) [0x00000] in <filename unknown>:0
  at TouchScript.Pointers.Pointer.GetOverData (Boolean forceRecalculate) [0x00000] in <filename unknown>:0
  at TouchScript.Layers.UI.TouchScriptInputModule+UIStandardInputModule.ProcessUpdated (System.Object sender, TouchScript.PointerEventArgs pointerEventArgs) [0x00000] in <filename unknown>:0
  at (wrapper delegate-invoke) System.EventHandler`1<TouchScript.PointerEventArgs>:invoke_void__this___object_PointerEventArgs (object,TouchScript.PointerEventArgs)
  at TouchScript.Utils.EventHandlerExtensions.InvokeHandleExceptions[PointerEventArgs] (System.EventHandler`1 handler, System.Object sender, TouchScript.PointerEventArgs args) [0x00000] in <filename unknown>:0
UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
UnityEngine.DebugLogHandler:LogException(Exception, Object)
UnityEngine.Logger:LogException(Exception, Object)
TouchScript.Utils.EventHandlerExtensions:InvokeHandleExceptions(EventHandler`1, Object, PointerEventArgs)

I have already found out the reason: It is because there are a couple of OnApplicationQuits() in the TouchManager code which set "shuttingDown = true", while the application still has the opportunity to cancel (Application.CancelQuit()).

As a test I have removed these (there are four of them) and rebuild the project. Now the "cancel quit" button seems to work when Alt-F4 is pressed. I do not have any crashes without the shuttingDown = true removed. shuttingDown is a private variable, so it can also not be set from outside.

So I am not sure what the best solution is :). But I thought I would be good to let you know about this issue.


Posts: 3
Joined: Thu Aug 03, 2017 11:47 am

Re: Cancelling quit - onApplicationQuit

Postby valyard » Mon Sep 25, 2017 3:36 pm

Indeed, I haven't thought about this.
shuttingDown variable was needed not to recreate all the state when the app is destroying but some code is trying to do something with TouchManager.Instance.
I'll check if this is still needed.
Site Admin
Posts: 439
Joined: Mon Sep 08, 2014 11:57 pm

Re: Cancelling quit - onApplicationQuit

Postby valyard » Fri Sep 29, 2017 5:18 pm

Fixed in develop branch.
Site Admin
Posts: 439
Joined: Mon Sep 08, 2014 11:57 pm

Return to Help and Bugs

Who is online

Users browsing this forum: Majestic-12 [Bot] and 1 guest