[Fwd: Re: [Lcdproc] lcdproc-0.5.0 segfaults]

Andrew Foss a.foss@f5.com
Thu May 4 17:47:01 2006


This is a multi-part message in MIME format.
--------------010804060205080005050801
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

lcdproc folks,

attached is a fix for clients that set a custom_main_menu. With this the 
menu_destroy routine sets custom_main_menu = NULL, if the menu being 
destroyed is the same as custom_main_menu and appears to fix the crash 
that Laurent was seeing.

If someone had the time/interest to review and commit?

thanks,
andrew

-------- Original Message --------
Subject: 	Re: [Lcdproc] lcdproc-0.5.0 segfaults
Date: 	Thu, 04 May 2006 19:32:33 +0200
From: 	Laurent B. <lorijho@yes.lu>
To: 	Andrew Foss <a.foss@f5.com>
References: 
<B8ECF7C8B6783140ABC787DC9794BAFD0A3B32@exchfour.olympus.f5net.com> 
<445A2B55.9070908@yes.lu> <445A2E81.1090805@f5.com> 
<445A3478.5000801@yes.lu> <445A3844.7020403@f5.com>



You solved it! Now it works.
Great job fixing that so quickly.

Laurent Baum



Andrew Foss wrote:
> Sorry, typo'd put an "=" where I need "==", c++ I wouldn't make these 
> mistakes:-)
>
> Also, upon looking forther I've moved it to the menu_destroy, instead 
> of the menuitem_destroy...
>
> here it is corrected.
>
> andrew
>
> Laurent B. wrote:
>> Andrew, I'm afraid the patch brakes the functionality of LCDd. Now 
>> upon calling menu_set_main nothing changes.
>> menu_set_main "", menu_set_main "<a_client_menu_id>" or  
>> menu_set_main "_main_" do nothing.
>> I'll give you a concrete example...
>> client sends: menu_set_main "", which should set the client menu as 
>> the default one (as advertised in the dev doc of lcdproc), results in 
>> having 2 menu entries upon pressing menu key.
>> ### LCDproc Menu ####
>> >Options >
>>  client_menu >
>>
>> So menu_set_main has no use with this patch, but at least LCDd 
>> doesn't crash...
>>
>> Laurent
>>
>>
>> Andrew Foss wrote:
>>> Laurent,
>>>
>>> here's a patch file that might work, if you can test it, I cannot 
>>> right now.
>>>
>>> from the server directory do the following command, assuming this 
>>> file is in your ~ directory
>>>
>>> patch -p1 < ~/lcdproccustommainmenu.patch
>>>
>>> if it works, we can submit it to the project.
>>>
>>> thanks,
>>> andrew
>>>
>>> Laurent B. wrote:
>>>> Hey as long as you're happy with what you do...
>>>> Diversity is a good thing!
>>>>
>>>> L
>>>>
>>>> Andrew Foss wrote:
>>>>>
>>>>> I'm just the opposite. I can't get my mind around the c++ logic in 
>>>>> header files:-)
>>>>>
>>> ------------------------------------------------------------------------ 
>>>
>>>
>>> --- server/menu.c.orig    2006-05-04 09:24:56.000000000 -0700
>>> +++ server/menu.c    2006-05-04 09:28:09.000000000 -0700
>>> @@ -39,6 +39,9 @@
>>>  #include "screen.h"
>>>  #include "widget.h"
>>>  
>>> +
>>> +extern Menu * custom_main_menu;
>>> +
>>>  /** Basicly a patched version of LL_GetByIndex() that ignores hidden
>>>   * entries completely. (But it takes a menu as an argument.) */
>>>  static void *
>>> @@ -172,6 +175,9 @@
>>>      if ((menu == NULL) || (item == NULL))
>>>          return;
>>>  
>>> +    if (custom_main_menu = menu)
>>> +        custom_main_menu = NULL;
>>> +
>>>      /* Find the item */
>>>      for (item2 = LL_GetFirst(menu->data.menu.contents), i = 0;
>>>           item2 != NULL;
>>>   
>>
> ------------------------------------------------------------------------
>
> --- server/menu.c.orig	2006-05-04 10:09:37.000000000 -0700
> +++ server/menu.c	2006-05-04 10:11:15.000000000 -0700
> @@ -39,6 +39,9 @@
>  #include "screen.h"
>  #include "widget.h"
>  
> +
> +extern Menu * custom_main_menu;
> +
>  /** Basicly a patched version of LL_GetByIndex() that ignores hidden
>   * entries completely. (But it takes a menu as an argument.) */
>  static void *
> @@ -137,6 +140,9 @@
>  	if (menu == NULL)
>  		return;
>  
> +	if (custom_main_menu == menu)
> +		custom_main_menu = NULL;
> +
>  	menu_destroy_all_items (menu);
>  	LL_Destroy (menu->data.menu.contents);
>  	menu->data.menu.contents = NULL;
>   



--------------010804060205080005050801
Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0";
 name="lcdproccustommainmenu.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="lcdproccustommainmenu.patch"

--- server/menu.c.orig	2006-05-04 10:09:37.000000000 -0700
+++ server/menu.c	2006-05-04 10:11:15.000000000 -0700
@@ -39,6 +39,9 @@
 #include "screen.h"
 #include "widget.h"
 
+
+extern Menu * custom_main_menu;
+
 /** Basicly a patched version of LL_GetByIndex() that ignores hidden
  * entries completely. (But it takes a menu as an argument.) */
 static void *
@@ -137,6 +140,9 @@
 	if (menu == NULL)
 		return;
 
+	if (custom_main_menu == menu)
+		custom_main_menu = NULL;
+
 	menu_destroy_all_items (menu);
 	LL_Destroy (menu->data.menu.contents);
 	menu->data.menu.contents = NULL;

--------------010804060205080005050801--