This is inconsistently but fairly regularly reproduceable on my W10 system with DO 12.21.2. I have a test detached dialog using the WatchTab method to monitor tab activate/deactivate events. In the following example the current lister initially contains two tabs - C: and C:\Program Files. I use an inline >go /temp newtab command to create a new tab. The new tab is always created but the dialog sometimes recognises the new tab and sometimes crashes.
Trace output is either (success):
Current lister has changed
Watching 264854 (C:) Program Files
currLister.tabs.count (0) = 2
currLister.tabs.count (1) = 2
Prev = 264854 (C:) Program Files | Curr = 1051344 (C:) Temp
Watching 1051344 (C:) Temp
or (crash):
Current lister has changed
Watching 264854 (C:) Program Files
currLister.tabs.count (0) = 2
currLister.tabs.count (1) = 2
Prev = 264854 (C:) Program Files | Curr = 0 undefined
01/08/20 09:52 Error at line 57, position 2
01/08/20 09:52 Invalid procedure call or argument (0x800a0005)
I can't detect any particular pattern that causes it to work or fail. However, there is a currLister.Update() statement between the two tab count traces and I would expect the second trace to report 3 tabs, at least when it doesn't crash. Maybe a timing issue?
WTTest.dcf (5.1 KB)
var cmd = DOpus.create.command, dlg = DOpus.dlg, msg_obj;
var opus_ver = "12.21";
var me = "WTTest";
var me_ver = me+" - 1st August, 2020 - © AussieBoykie";
var watched = DOpus.Create.Map();
var prevTab, currTab, prevLister, currLister = DOpus.listers.lastactive;
function OnClick(clickData)
{
if (!DOpus.version.AtLeast(opus_ver)){
dlg.request("DOpus version "+opus_ver+" or later is required.","OK","Version Check");
return false;
}
dlg.template = me;
dlg.window = DOpus.listers.lastactive;
dlg.detach = true;
dlg.title = me_ver;
dlg.create;
checkListerChange();
dlg.show;
do{
msg_obj = dlg.getmsg();
if (msg_obj==false) break;
if (msg_obj.event=="click"){
DOpus.output(msg_obj.control+" : "+dlg.control(msg_obj.control).label);
if (msg_obj.control=="button2") break;
}
else if ((msg_obj.event=="tab") && (msg_obj.value=="activate")){
if (!checkListerChange()) checkTabChange();
}
}
while (msg_obj);
}
function checkListerChange()
{
if (currLister==prevLister) return false; // Lister hasn't changed
DOpus.output("Current lister has changed");
watched = DOpus.Create.Map(); // Reset the map of watched tabs
prevTab = currTab = currLister.activetab; // Reset previous and current tabs
watchit(currTab); // Watch current tab
prevLister = currLister // Reset previous lister
return true;
}
function checkTabChange()
{
DOpus.output("currLister.tabs.count (0) = "+currLister.tabs.count);
currLister.Update();
DOpus.output("currLister.tabs.count (1) = "+currLister.tabs.count);
prevTab = currTab;
currTab = DOpus.listers.lastactive.activetab;
if (String(currTab)!=String(prevTab)){ // Deactivate event triggered by prevTab
DOpus.output("Prev = "+String(prevTab)+" "+prevTab.displayed_label+" | Curr = "+String(currTab)+" "+currTab.displayed_label);
if (!watched.exists(currTab)) watchit(currTab);
}
}
function watchit(someTab)
{
dlg.watchtab(someTab,"activate");
DOpus.output("Watching "+someTab+" "+someTab.displayed_label);
watched(someTab) = someTab.displayed_label;
}