Jump to content

Incorrect namespace in ui file crash Unigine


photo

Recommended Posts

Posted

I use ui file:

 

<?xml version="1.0" encoding="utf-8"?>
<ui version="1.0">

<vbox name="Source::ToolBar::vBox" export="1">
	<icon name="Source::ToolBar::reloadWidgetIcon" export="1" toggleable="1" texture="action_reset.png">
		<callback type="clicked">Source::ToolBar::worldReloadClickHandler</callback>
	</icon>
   <icon name="Source::ToolBar::changeCameraIcon" export="1" toggleable="1" texture="player_dummy.png">
     <callback type="clicked">Source::ToolBar::changeCameraClickHandler</callback>
   </icon>
</vbox>

</ui>

 

and script for it:

namespace Source
{
class ToolBar
{
	//private:
	//	Game game;
	public:
		UserInterface ui;

		//ToolBar toolBar;

		WidgetVBox vBox;
		WidgetIcon reloadWidgetIcon;
		WidgetIcon changeCameraIcon;

		ToolBar()
		{
			//this.game = game;

			//log.message("game: " + typeinfo(this.game) + "\n");

			ui = engine.gui.addUserInterface(engine.getGui(), "source/scripts/editor/ToolBar.ui");

			Gui gui = engine.getGui();
			gui.addChild(vBox, GUI_ALIGN_OVERLAP);
			vBox.setPosition(2, 42);
		}

		~ToolBar() 
		{
			engine.gui.removeUserInterface(ui);
		}
};
};

 

So, if I remove namespace Source from <vbox name="ToolBar::vBox" export="1"> I get crash of Unigine:

post-151-0-01819600-1291285789_thumb.jpg

Posted

You are trying to call a non-static member function of a class, is that possible in c++?

Posted
You are trying to call a non-static member function of a class, is that possible in c++?

I use class ToolBar in namespace Source, given above in my first post. When I add namespace to my project - I forget update .ui-files. So handlers in ui refer to wrong function definition.

 

This is expected behavior.

 

So crashing of unigine is that you expected? :)

Expected behavior - show me my mistake and all.

Posted

its simple answer, try these code in a c++ compiler:

#include <stdio.h>
namespace a{
 class b
 {
 public:
    int val;
    b() {}
    ~b() {}
 };
};

void main()
{
 a::b::val = 1;
 return 0;
}

 

these simple code has exactly same concept with your code.

 

so, if you want to use Source::ToolBar::vBox, then the ToolBar must be a namespace not a class.

Posted

I talk not about code rightness I talk about program is crash/hang/close.

Posted

So crashing of unigine is that you expected? :)

Expected behavior - show me my mistake and all.

 

We can predict all, even crashes :blink:

So, the crash occurred when the assertion widget!=NULL failed.

Posted

Sorry. I don't understand.

I get bug - I write Feedback. Must you fixing it or not - it's you choice.

Posted

Sorry. I don't understand.

I get bug - I write Feedback. Must you fixing it or not - it's you choice.

 

Thank you for your feedback, it's really important for us.

 

Unfortunately this is the case of referencing wrong object pointer, such errors frequently produce crashes (if you code in C++, you know that it's a real pain in the ass), so we see no way to handle it.

Posted

Oh, I see.

No, I not "native" C++ programmer so I don't know about this :)

×
×
  • Create New...