Jump to content

WidgetEditText::setText after using a dialog file


photo

Recommended Posts

I have found a really weird problem: when I use a dialog widget to select a file and after that I try to call setText() for a widget (tested with WidgetEditText and WidgetButton) I get an error:

 

ExternClass::run_function(): object is NULL
Stack dump:
0x0000: string: "Switch"

 

"Switch" is the string I passed to setText(). Any idea about whats happening here?

Link to comment
ExternClass::run_function(): object is NULL

 

I would guess that some object variable in your code is not initialized. You should post at least your function code including an indication where the exception is raised..

Link to comment

I would guess that some object variable in your code is not initialized. You should post at least your function code including an indication where the exception is raised..

 

Here is a simple code:

DialogFile::init();
DialogFile::show("Choose dialog file", fileName,"*.xml");
btNew.setText("Switch");

 

The file selection dialog works fine, and the button exists, fo course, Im just changing its text.

Link to comment

How is btNew object variable initialized ? Fisrt of all include following test code to verify btNew initialization.

 

DialogFile::init();
DialogFile::show("Choose dialog file", fileName,"*.xml");

if( btNew != 0 )
{
   btNew.setText("Switch");
}
else
{
   log.error("btNew is null");
}

Link to comment

I used the widget demo as base:

 

class Window {

Gui gui;				// gui
UserInterface ui;

WidgetButton btNew;	    // New dialog

       ***

Window() {

gui = engine.getGui();
btNew = new WidgetButton(gui,"New");
       gui.addChild(btNew,GUI_ALIGN_OVERLAP);
       ***
}

 

Also added your code and made a test, it reports that btNew is null.

Link to comment

Also added your code and made a test, it reports that btNew is null.

 

check if Window() constructor gets called by adding some log messages. In the sample this is done via

 

/*
*/
void create_scene() {

Window window = new Window();
window = window;

return "Toggle button";
}

Link to comment

Everything works fine, as long as I dont display a DialogFile before. I remove it and the widgets are accessed normally (as I said, I tested with several widgets, which are already created and are perfectly visible).

Link to comment

Everything works fine, as long as I dont display a DialogFile before. I remove it and the widgets are accessed normally (as I said, I tested with several widgets, which are already created and are perfectly visible).

 

Post a small test-case .cpp/.world for problem reproduction

Link to comment

A little detail:

 

npcLine.setText("Loading"); <-- This works
	DialogFile::init();
	DialogFile::show("Choose dialog file", fileName,"*.xml");
	npcLine.setText("testtt"); <-- This no works

 

Seems that DialogFile is invalidating all my previously created widgets. Also tried calling dialogFile::shutdown after show(), but didnt solved the problem.

Link to comment
×
×
  • Create New...