Author Topic: Loading and unloading macro files and Slick Stack  (Read 5428 times)

jporkkahtc

  • Senior Community Member
  • Posts: 2620
  • Hero Points: 210
  • Text
Loading and unloading macro files and Slick Stack
« on: January 16, 2017, 05:34:13 AM »
I've got a project with several *.E files.

To try to a avoid getting into a weird state, I've written 2 commands and placed them into a separate FOO.e file._command void SymTagUnload() name_info(',')
{
    unload("m1.ex");
    unload("m2.ex");
    unload("m3.ex");
}

_command void SymTagload() name_info(',')
{
    load("C:\\Users\\joe\\Documents\\Slickedit\\macros\\m3.e");
    load("C:\\Users\\joe\\Documents\\Slickedit\\macros\\m2.e");
    load("C:\\Users\\joe\\Documents\\Slickedit\\macros\\m1.e");
}


Now, sometimes after unloading Slick gets into a state where it gets a slick-stack everytime slick gets focus - so then I have to kill Slick with the taskman. The stack
stack[2017-01-15T21:25:18Z] Slick-C STACK TRACE ******************************
stack[2017-01-15T21:25:18Z] Created on 1/15/2017 at 21:25:18 (776 ms)
stack[2017-01-15T21:25:18Z] SlickEdit Pro Version 21.0.1.0 Copyright 1988-2016 SlickEdit Inc.
stack[2017-01-15T21:25:18Z] Edit module and type "st -f <offset>" to get the
stack[2017-01-15T21:25:18Z] run-time error position
stack[2017-01-15T21:25:18Z]
stack[2017-01-15T21:25:18Z] error code=-3015
stack[2017-01-15T21:25:18Z] Invalid argument
stack[2017-01-15T21:25:18Z]
stack[2017-01-15T21:25:18Z]files.ex 12164 call_list(_switchbuf_,,W,<empty>,-1)   p_window_id: 246   p_object: OI_EDITOR   p_name: edit1
stack[2017-01-15T21:25:18Z]stdprocs.ex 13633 switch_buffer(,W,<empty>,-1)   p_window_id: 246   p_object: OI_EDITOR   p_name: edit1
stack[2017-01-15T21:25:18Z]stdprocs.ex 13381 _on_got_focus()   p_window_id: 246   p_object: OI_EDITOR   p_name: edit1


In m1,m2 and m3, there are a couple of call_list() event handlers, like:
void _switchbuf_m2(_str oldbuffname, _str flag)
{
}


An apparently, call_list doesn't seem to get the memo that this macro file was unloaded.


What is the best way to got about loading and unloading *.E files during development?
Slick seems to be pretty flaky about it - I imagine there is some trick to it?

Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
Re: Loading and unloading macro files and Slick Stack
« Reply #1 on: January 17, 2017, 10:41:01 AM »
I almost never use unload, for no particular reason.  I just tried the call_list _switchbuf problem you mention and I get a slick c stack the same as you.  I wonder why I get two (and sometimes 4) calls to _switchbuf every time I switch buffers.  If I comment out the _switchbuf function and reload the module, there's no slick stack  - so maybe instead of unloading a module you could load an empty module of the same name from another folder.

jporkkahtc

  • Senior Community Member
  • Posts: 2620
  • Hero Points: 210
  • Text
Re: Loading and unloading macro files and Slick Stack
« Reply #2 on: January 17, 2017, 06:23:47 PM »
Nice that its easy to repro :-)

Good idea about the empty file, though I think I got things more under control now.
My _switchbuf code wasn't needed so I just removed it - solving that problem.

With timers at least, you can kill the timers before unloading a module, but I don't know how you could avoid the wrath of call_list.

I've also had more luck now using SymTagLoad() to reload everything, in the right order, rather than just reloading each file as I make changes. It helps also that unloading works with the _switchbuf function removed.

I'm a little surprised to find that global variables in a module survive and keep their values even with unload / load: I would have expected them to vanish with unloading - I'd imagine this can cause vslick.sta to get bloated.


jporkkahtc

  • Senior Community Member
  • Posts: 2620
  • Hero Points: 210
  • Text
Re: Loading and unloading macro files and Slick Stack
« Reply #3 on: January 17, 2017, 06:57:01 PM »
In Files.e,  call_list keeps a global cache of function indexes - gcall_list_indexes.
This isn't updates on module unload, and it should be.

It is updated on module load.

files.e implements
    void _on_load_module_call_list()
But it also needs to implement
    void _on_unload_module_call_list()

and clear this cache.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6826
  • Hero Points: 526
Re: Loading and unloading macro files and Slick Stack
« Reply #4 on: January 26, 2017, 03:52:31 PM »
I've checked in a fix for v21.0.2 so that call_list() handles the case where you unload a module. Need to pre-check the cached listed to make sure the indexes are all callable with index_callable(index).