언어 설정

Menu
Sites
Language
App stop working after adding a second view to it

Hi all, 

i'm facing a very strange and cryptic problem. I started my application to be a single view application, but now i need to add a new view that function as a main menu window. 

So using UI builder, i created a new view, added a grid, a button, and then created the transiction to the game view.

And i dind't get any error or problem during that. But after i've done it, the apps even if ti apparently compile fine, it doesn't start nor on the device neither on the emulator. 

There are no errors, problems or warning. It simply doesn't start. Apparently it stop working as soon as i set the new view as startup view. Even the console window says "Tizen application is succesfully launched"

Besides, after upgrading to Tizen 2.0 the log window doesn't log anything when testing on the device. 

 

Any idea?

Thanks

Edited by: Ivan Gualandri on 28 11월, 2017

Responses

13 댓글
Shaswati Saha

Hi Ivan,

Please try running the app with Debug As mode. After that try launching, it'll work now. Though it seems a little bit strange but it works. It worked in my case in this way.

Ivan Gualandri

In my case the problem is different  I found there is a segmentation fault that happens only when i add the new view. 

This is the code involved: 

static bool _on_create_cb(void *user_data)
{
    /*
	 * This area will be auto-generated when you add or delete user_view
	 * Please do not hand edit this area. The code may be lost.
	 */
	uib_app_manager_st* app_manager = uib_app_manager_get_instance();;
	app_manager->initialize();
	/*
	 * End of area
	 */
	char *res_path = app_get_resource_path();
	uib_app_manager_st* uib_app_manager = uib_app_manager_get_instance();
	uib_game_view_view_context* vc = (uib_game_view_view_context*)uib_app_manager->find_view_context("game_view");
	set_object_image(vc->player2_add_btn, res_path, "ic_add_circle_outline_white_48dp.png");
	set_object_image(vc->player2_subtract_btn, res_path, "ic_remove_circle_outline_white_48dp.png");
	...
}

Basically the problem is that when i add a second view the call to: 

uib_app_manager->find_view_context("game_view")

Returns null (0x0), and this is i suppose the cause of my problems.

the question is why? Is the view unavailable when it starts from a different view? Is there a different way to get the reference to the view when the application is starting? (i need it ti configure several ui components).

Is there another callback that is called when switching view? 

Ivan Gualandri

I noticed that when calling the function find_view_context the view arraay contains only one element, instead of two (at least this is what i was expecting). 

Shaswati Saha

Please try following below steps.

  1. Take a sample project (i.e. UIBuilderSingleView) after that do changes into layout.xml file not in C code(as you know it'll be generated by UIBuilder).  
  2. Take a new view. You may take two buttons into both of the views (i.e. next and previous button to navigate through the pages).
  3. Make transaction between those views based on button click.

Now try to launch the app according to my previous post.

Ivan Gualandri

Hi Shaswati, 

I tried the steps above, and it works (anyway i was kind of expecting that). 

In fact i did some investigation, and what i noticed, is that when the on create_cb is called, apparently all the veiws are not available, and this mean that i can't rely on the find_view_context, i.e. the following code_snippet: 

uib_view2_view_context* vc = (uib_view2_view_context*)app_manager->find_view_context("view2");

Is returning NULL to vc. 

And if i try to debug, these are the values of the views array:

So as you can see all the values in the array are set to NULL except for the first one (you cant see all 100 element from the picture, but i can assure you that they are all 0x0). 

And this behaviour is the same in both projects, my project and the new one (i tried to get the view called "view2". 

My actual code in the on_create_cb is the following: 

static bool _on_create_cb(void *user_data)
{
    /*
	 * This area will be auto-generated when you add or delete user_view
	 * Please do not hand edit this area. The code may be lost.
	 */
	uib_app_manager_st* app_manager = uib_app_manager_get_instance();;
	app_manager->initialize();
	/*
	 * End of area
	 */
	char *res_path = app_get_resource_path();

	uib_game_view_view_context* vc = (uib_game_view_view_context*)app_manager->find_view_context("game_view");
	set_object_image(vc->player2_add_btn, res_path, "ic_add_circle_outline_white_48dp.png");
	set_object_image(vc->player2_subtract_btn, res_path, "ic_remove_circle_outline_white_48dp.png");
	set_object_image(vc->player1_add_btn, res_path, "ic_add_circle_outline_white_48dp.png");
	set_object_image(vc->player1_subtract_btn, res_path, "ic_remove_circle_outline_white_48dp.png");
	char edj_path[PATH_MAX] = {0, };
    ...
}

Maybe i'm doing something wrong? I need to access the content of the view called "game_view" before it is displayed, since i need to configure some objects in the layout (p.s. set_object_image is a custom function that i wrote). 

Shaswati Saha

Would you please try doing the same thing in _on_resume_cb before displaying to user instead of _on_create_cb ?

Ivan Gualandri

Tried it, same problem. find_view_context return 0x0 (NULL).

Ivan Gualandri

It looks like that even when i try to use find_view_context in a click event_handler, i'm getting the same error. 

Anyway what i need is do some settings to the object in the view i'm going to launch (adding styles, icons to buttons, etc.), if there is an alternative way that works for me it's ok.

Shaswati Saha

Your issue was about the problem of adding second view to a singleview project of UIBuilder and I think you've got a solution from this post. I would like to suggest you to close the discussion by selecting a best answer in this post and open a new thread with the current problem so that other developers can find results easily without any ambiguity. 

Ivan Gualandri

Ehm, where is the solution? 

I'm still having that problem that is the problem for which i have opened this forum post. I don't think i should open a new task, because the problem isn't solved.

What we have found is only the cause of the problem, but at the moment i can't see any solution. And it means also that i can't proceed

Shaswati Saha

Your post was about the problem of app stops working after adding a new view and  I've meant about your reply after trying the steps I told you to follow, as in that reply you mentioned that "I tried the steps above, and it works". So, I thought you've found a solution of the problem, this post describes about. 
Neverthless, I've tried to find out a way to apply custom styles, icons to buttons and could manage a simple workaround. You may try using genlist item(it supports style with icon at start and end) as button. I couldn't find any way to modify predefined styles using UIBuilder, don't forget to share here if you can find any.

Ivan Gualandri

So finally i got it working.

After updating to Tizen Studio 2.1, i have two new event buttons on the view properties, the created one, that is passing the view context that i needed. 

So event if i don't know if find_view_context is not working, the created event is what i needed. 

So using that everything is working fine. 

Shaswati Saha

That's really great. Please provide screenshots if possible, it'll help other developers.