Sign up

Compilation error in src/gio/DesktopAppInfo.d

On line 402 of src/gio/DesktopAppInfo.d :

	public string[] listActions()
	{
		// const gchar * const * g_desktop_app_info_list_actions (GDesktopAppInfo *info);
		auto p = g_desktop_app_info_list_actions(gDesktopAppInfo);
		
		string[] strArray = null;
		foreach ( cstr; p[0 .. ] )
		{
			strArray ~= Str.toString(cstr);
		}
		
		return strArray;
	}

The foreach part with p[0..] doesn't compile. Could we use Str.toStringArray instead? Though it looks like that function limits you to ten strings from a gchar**.

Re: Compilation error in src/gio/DesktopAppInfo.d

On 09/27/2013 06:17 PM, ollie wrote:

On line 402 of src/gio/DesktopAppInfo.d :

code

The foreach part with p[0..] doesn't compile. Could we use Str.toStringArray instead? Though it looks like that function limits you to ten strings from a gchar**.

Fixed:
https://github.com/gtkd-developers/GtkD/commit/842a484115a800dfc8fd042092e83eef7094016d.

How is toStringArray limited to 10 strings?

Re: Compilation error in src/gio/DesktopAppInfo.d

On Fri, 27 Sep 2013 22:23:43 +0200, Mike Wey wrote:

How is toStringArray limited to 10 strings?

In src/glib/Str.d at line 190:

	public static string[] toStringArray(char** args)
	{
		if ( args is null )
		{
			return null;
		}
		string[] argv;
		
		char* arg = args[0];
		int i=0;
		while( (arg) != null && i<10)
		{
			argv ~= toString(arg);
			++i;
			arg = args[i];
		}
		
		return argv;
	}

Because of the i in the while loop. As long as arg points to a valid string and i<10 concat to argv. If i==10 stop looping even if arg points to a valid string.

I don't know if this is an arbitrary limit or some underlying need for that limit.

Re: Compilation error in src/gio/DesktopAppInfo.d

On 09/28/2013 06:29 AM, ollie wrote:

On Fri, 27 Sep 2013 22:23:43 +0200, Mike Wey wrote:

How is toStringArray limited to 10 strings?

In src/glib/Str.d at line 190:

	public static string[] toStringArray(char** args)
	{
		if ( args is null )
		{
			return null;
		}
		string[] argv;
		
		char* arg = args[0];
		int i=0;
		while( (arg) != null && i<10)
		{
			argv ~= toString(arg);
			++i;
			arg = args[i];
		}
		
		return argv;
	}

Because of the i in the while loop. As long as arg points to a valid string and i<10 concat to argv. If i==10 stop looping even if arg points to a valid string.

I don't know if this is an arbitrary limit or some underlying need for that limit.

The 10 does seem arbitrary, the original commit mentions it's a bugfix
but not for what and why 10.