﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
8771	getDialogValue in docprops plugin failing to release event handlers	NicHolt		"Steps to recreate: a page in the docprops dialog with two elements that invoke a child dialog - e.g. colorpicker (in my case a treeview dialog.

1. Click to open the child dialog for one element. 

2. Cancel.

3. Click to open the child dialog for the other element. 

4. Make a selection in the child dialog.

5. Click OK.

Expected results:

The first element should be unchanged, and the second should be updated with the value from the child dialog.

Actual result:

BOTH elements are updated with the value from the second invocation of the child dialog.

Explanation: releaseHandlers is not being called in the correct context, so when OK is clicked, there are TWO OK event handlers bound to the dialog, one for the field for which OK was clicked, one ofr the field which was canceled.

The following code explicitly establishes the context both for the event handlers and for releaseHandlers, rather than relying on ""this"".


{{{
		var onOk = function()
		{
			var dlg = editor._.storedDialogs[dialogName];  // Changed by Nic to fix failure to releaseHandlers correctly
			releaseHandlers();
			callback( dlg, dlg._.parentDialog );
		};

		var releaseHandlers = function()
		{
			var dlg = editor._.storedDialogs[dialogName];  // Changed by Nic to fix failure to releaseHandlers correctly
			dlg.removeListener( 'ok', onOk );
			dlg.removeListener( 'cancel', releaseHandlers );
		};



}}}
"	Bug	closed	Normal		General	3.6.1	expired		
