Binding issue: uninitialized local variable

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
bandali99
Knows some wx things
Knows some wx things
Posts: 40
Joined: Fri Jul 05, 2019 3:58 pm

Binding issue: uninitialized local variable

Post by bandali99 »

Hi, I created a separate window and I want to connect it to a widget on another window. I used the bind function and included the header files but when I run the file "uninitialized local variable" error appeared. What did I do wrong?

Code: Select all

slidercontrol* checkslider;
	selectedslider = checkslider->getselect();
This may not be enough code to look at so here is the git link too, the cpp files I am referring to are selectslidercontrol and mysingleslider (line 143).

https://github.com/fahadbandali/multi-slider

thanks
alys666
Super wx Problem Solver
Super wx Problem Solver
Posts: 329
Joined: Tue Oct 18, 2016 2:31 pm

Re: Binding issue: uninitialized local variable

Post by alys666 »

you just declared "checkslider", but not assigned any value to it. and later use it as something assigned.
for example if you declared:

int my_burth_date;

how your real birth date was assigned to it?
ubuntu 20.04, wxWidgets 3.2.1
bandali99
Knows some wx things
Knows some wx things
Posts: 40
Joined: Fri Jul 05, 2019 3:58 pm

Re: Binding issue: uninitialized local variable

Post by bandali99 »

alys666 wrote: Tue Aug 13, 2019 4:09 pm you just declared "checkslider", but not assigned any value to it. and later use it as something assigned.
for example if you declared:

int my_burth_date;

how your real birth date was assigned to it?
The checkslider object has dynamically changing values based on what the user check marks on that window. If the user checks slide 1 then the value of checkslider would be one. Did I call or bind it incorrectly?
alys666
Super wx Problem Solver
Super wx Problem Solver
Posts: 329
Joined: Tue Oct 18, 2016 2:31 pm

Re: Binding issue: uninitialized local variable

Post by alys666 »

where you created this object? you just declared pointer to this object, not created object itself.
whre is something like -

Code: Select all

slidercontrol* checkslider = new slidercontrol(...);
ubuntu 20.04, wxWidgets 3.2.1
bandali99
Knows some wx things
Knows some wx things
Posts: 40
Joined: Fri Jul 05, 2019 3:58 pm

Re: Binding issue: uninitialized local variable

Post by bandali99 »

alys666 wrote: Tue Aug 13, 2019 4:38 pm where you created this object? you just declared pointer to this object, not created object itself.
whre is something like -

Code: Select all

slidercontrol* checkslider = new slidercontrol(...);
Just tried that and there are no errors in the code now however when I run it the widget and the checkbox are not linked at all..

Code: Select all

Bind(wxEVT_COMMAND_MENU_SELECTED, &slidercontrol::select1, main, ID_SLIDE1);
	Bind(wxEVT_COMMAND_MENU_SELECTED, &slidercontrol::select2, main, ID_SLIDE2);
	Bind(wxEVT_COMMAND_MENU_SELECTED, &slidercontrol::select3, main, ID_SLIDE3);
	Bind(wxEVT_COMMAND_MENU_SELECTED, &slidercontrol::select4, main, ID_SLIDE4);
Here is how I binded the function to the code in selectslidercontrol and in mysingle slider I used #include "selectslidercontrol" did I do enough to link the two cpp files together?
alys666
Super wx Problem Solver
Super wx Problem Solver
Posts: 329
Joined: Tue Oct 18, 2016 2:31 pm

Re: Binding issue: uninitialized local variable

Post by alys666 »

if your programm was successfully linked and you have it runing - all your needed files were linked in executable file. So calm down.

I do not understand an idea of your Bind(....), i just see that your attached 4 handlers to one event. and it looks odd. :)

ps.
also "main" in this lines looks strange... check which methods of which objects, you're attaching to some event source.

Code: Select all

Bind(wxEVT_COMMAND_MENU_SELECTED, &slidercontrol::select2, main, ID_SLIDE2);
ubuntu 20.04, wxWidgets 3.2.1
Post Reply