Raised This Month: $32 Target: $400
 8% 

Native "CloseHandle" reported


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
axiom123
Member
Join Date: May 2013
Location: Ukraine, Kiev
Old 01-17-2014 , 12:04   Native "CloseHandle" reported
Reply With Quote #1

I do not understand what triggered this error
Quote:
L 01/17/2014 - 20:56:10: [SM] Native "CloseHandle" reported: Handle 2400098 is invalid (error 3)
L 01/17/2014 - 20:56:10: [SM] Displaying call stack trace for plugin "elotf2.smx":
L 01/17/2014 - 20:56:10: [SM] [0] Line 219, D:\Сервер\ent\addons\sourcemod\scripting\elot f2.sp::TopMenuHandler1()
Code:
public SQLQueryTop10(Handle:owner, Handle:hndl, const String:error[], any:data) {
	new client;
	if((client = GetClientOfUserId(data))==0) {
		return;
	}
	if(hndl==INVALID_HANDLE) {
		LogError("Query failed: %s", error);
	} 
	else {
		decl String:qname[64], String:qrating[8], String:buffer[68];
		new i = 1;
		new Handle:menu = CreateMenu(TopMenuHandler1);
		SetMenuTitle(menu, "Top players:");
		while(SQL_FetchRow(hndl)) {
			SQL_FetchString(hndl, 0, qname, sizeof(qname));
			SQL_FetchString(hndl, 1, qrating, sizeof(qrating));
			Format(buffer, sizeof(buffer), "%s (%s)", qname, qrating);
			AddMenuItem(menu, "0", buffer);
			i++;
		}
		SetMenuExitButton(menu, true);
		DisplayMenu(menu, client, 60);
	}
}
public TopMenuHandler1(Handle:menu, MenuAction:action, client, args)
{
	if (action == MenuAction_End)
	{
		CloseHandle(menu);// erorr
	}
	else if (action == MenuAction_Select){
		if(args == 0)
			CloseHandle(menu);
	}
}

Last edited by axiom123; 01-17-2014 at 12:06.
axiom123 is offline
Send a message via ICQ to axiom123 Send a message via Skype™ to axiom123
rswallen
SourceMod Donor
Join Date: Jun 2013
Location: 127.0.0.1
Old 01-17-2014 , 12:37   Re: Native "CloseHandle" reported
Reply With Quote #2

You close the menu via CloseHandle() when a client selects option 0.
Thus, when the MenuHandler is called again (with action MenuAction_End), menu is an invalid handle (ie does not exist) and CloseHandle() throws an error
rswallen is offline
axiom123
Member
Join Date: May 2013
Location: Ukraine, Kiev
Old 01-17-2014 , 13:43   Re: Native "CloseHandle" reported
Reply With Quote #3

Thank
added return;
axiom123 is offline
Send a message via ICQ to axiom123 Send a message via Skype™ to axiom123
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 01-17-2014 , 14:21   Re: Native "CloseHandle" reported
Reply With Quote #4

When dealing with menus, only call CloseHandle on the menu in the MenuAction_End action. And only if you're not going to be reusing the menu.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
TheDiamant953
Member
Join Date: Jan 2013
Old 06-16-2015 , 14:44   Re: Native "CloseHandle" reported
Reply With Quote #5

Quote:
Originally Posted by axiom123 View Post
Thank
added return;
I don't understand what you have done.

I have this error to on my plugins, it's menus who is used and closed a lot. So the errors logs spam the "same" error.

What can i do in my script for fix it ?
TheDiamant953 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:43.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode