Opened 13 years ago

Closed 13 years ago

#495 closed defect (fixed)

JavaScript error, when closing dialogs in Explorer

Reported by: anonymous Owned by: gogo
Priority: normal Milestone:
Component: Xinha Core Version:
Severity: normal Keywords:
Cc:

Description

When a Xinha dialog window is closed using the Windows close button (the little x in the right upper corner) I get an JavaScript? error.

This error seems to occures only, if you use the Explorer (not Internet Explorer) to view the page. You have to open a normal Explorer window (for example for C:) and then enter the URL in the address bar. (I assume, this is somehow related to the fact, that the opened dialog is in a different process than the main page. The main window has a little folder symbol in the taskbar, the dialog an Internet Explorer symbol...)

When I added this line:

        window.onunload = __dlg_onclose;

behind window.moveTo(x, y) in the second else clause in __dlg_init in popup.js it seemed to solve the problem. Without this line opener.Dialog._return is not called when the window is closed and so it never gets released.

Change History (3)

comment:1 Changed 13 years ago by xinha.20.artus83@…

I found another related error. If you use, as explained above, Explorer and open a dialog window, you get JavaScript? errors when unloading the page, since there are references to the closed window left in the free list.

To avoid the problems I added two catch blocks.

In HTMLArea.free:

HTMLArea.free = function(obj, prop)
{
  try
  {
    if(obj && !prop)
    {
      for(var p in obj)
      {
        HTMLArea.free(obj, p);
      }
    }
    else if (obj)
    {
      obj[prop] = null;
    }
  }
  catch (e) { };
}

and in HTMLArea.flushEvents:

HTMLArea.flushEvents = function()
{
  var x = 0;
  var e = null;
  while(e = HTMLArea._eventFlushers.pop())
  {
    try
    {
      if(e.length == 3)
      {
        HTMLArea._removeEvent(e[0], e[1], e[2]);
        x++;
      }
      else if (e.length == 2)
      {
        e[0]['on' + e[1]] = null;
        e[0]._xinha_dom0Events[e[1]] = null;
        x++;
      }
    }
    catch (e) { };
  }

The "right" thing to do, would probably be removing the event handlers from the lists and freeing the events, when the window is closed. But this seems to be quite complicated. And since these procedures are only used for clean up, I consider inserting these try blocks to ignore the errors as no serious problem. But if someone knows a more elegant solution...

comment:2 Changed 13 years ago by anonymous

  • Component changed from Documentation to Xinha Core
  • Owner changed from akaEdge to gogo

comment:3 Changed 13 years ago by gogo

  • Resolution set to fixed
  • Status changed from new to closed

I think your solution of simply catching and ignoring is fine in this case, it's only in this case and I don't know what else we could do really, if MS is taking stuff away before we're done with it.

Applied in changeset:395

Note: See TracTickets for help on using tickets.