#1838: Context-menu doesn't aways dissapear after selecting an option
--------------------------------+-------------------------------------------
Reporter: dustball | Owner: martinkou
Type: Bug | Status: assigned
Priority: Normal | Milestone: FCKeditor 2.6
Component: UI : Context Menu | Version: SVN
Resolution: | Keywords: Confirmed Firefox
--------------------------------+-------------------------------------------
Comment (by martinkou):
I think I've finally found out why the menus aren't closing and derived a
fix for that. Although with this kind of bug it can never be 100% sure
since I don't know whether it will appear again at the 1000th trial to
reproduce it despite having the fix. Anyway, here's my theory on why it is
happening, based on what I've seen in today's code traces:
If you look into FCKPanel::Show() you'll see there's a little closure
called "resizeFunc()", which sets the flag FCKPanel::_IsOpened to true. It
is not executed directly by FCKPanel::Show(), however. It is only executed
with a setTimeout() with a 1ms delay. So there's a 1ms delay (probably
much longer, as you know the JavaScript timer isn't very accurate) during
which the _IsOpened state is desynced from the rest of the FCKDialog
object's states.
Now what can be checking that _IsOpened flag during the 1ms window? My
code trace today showed that FCKMenuBlockPanel::Show(), which is called
when opening the Row, Cell, Column submenus, would check it by calling
FCKPanel::CheckIsOpened(). What happened, at least during the code traces
I've seen, was that FCKMenuBlockPanel::Show() may get called multiple
times even for the same submenu while your mouse hovered above the
submenu's parent item quickly. The first time it is called, the submenu's
FCKPanel::Show() is called, a timer is set to run resizeFunc() and the
parent menu's _LockCounter is incremented. The second time it is called,
it finds that the submenu is still not opened (since the timer has not run
resizeFunc() yet), and thus called FCKPanel::Show() for the submenu again.
Which, subsequently, causes the _LockCounter of the parent menu to be
incorrectly incremented by 1 again.
So the fix to this, would be to move the _IsOpened = true assignment out
of the resizeFunc() closure and make it executed with the rest of the code
in FCKPanel::Show(). This creates a potential problem, however, that it
makes it possible for a submenu to appear after it's FCKPanel::Hide() had
been executed during the 1ms window. So we need to take care of that case
in FCKPanel::Hide() by clearing the timer used to execute resizeFunc().
--
Ticket URL: <https://dev.fckeditor.net/ticket/1838#comment:9>
FCKeditor <http://www.fckeditor.net>
The text editor for Internet
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
FCKeditor-Trac mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fckeditor-trac