Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with hide() in box class #7

Open
chiru9670 opened this issue Dec 28, 2017 · 8 comments
Open

Problem with hide() in box class #7

chiru9670 opened this issue Dec 28, 2017 · 8 comments

Comments

@chiru9670
Copy link
Contributor

This is the declaration of my box object:

box menu2(c, window.getwidth() * 0.6, window.getheight() - 6 );
//some code in between(unimportant)//
menu2.clear();
menu2.setheight(menu.getheight());
menu2.settcolor(GREEN);
menu2 << ui::centeralign << "Employee Management" << ui::endl << ui::endl;
menu2.settcolor(WHITE);
menu2 << "Employee Details: " << ui::endl;
menu2.settcolor(ui::tcolor);

At this point, the output is:
1
as expected.
Now when I hide this box, this is the output:
2
as expected.
After this, the following code is run:

menu2.display();
menu2 << "ID: " << e->get_id() << ui::endl;

The output here is:
3
as expected.
Now when I hide this box, this is the output:
4
which is highly unexpected.
Is there something wrong with my code, or is it something else?

@chiru9670
Copy link
Contributor Author

Ok, I was trying to debug this a little, and I can't figure out anything from this point:
I commented out the main function of hosp.cpp, and made another main function in ui/test.cpp, which is as follows:

void main()
{
	ui::clrscr();
	box menu2(coord(2, 4), 40, 10 );
	menu2.settcolor(GREEN);
	menu2 << ui::centeralign << "Employee Management" << ui::endl << ui::endl;
	menu2.settcolor(WHITE);
	int menu2_height;
	menu2_height = 10;
//	menu2.setheight(menu2_height);
	menu2 << "View employee data" << ui::endl;
	menu2.settcolor(ui::tcolor);
//	menu2 << "Enter employee's id: ";
	unsigned long id;
	menu2 >> id;
	menu2 << ui::endl;
	menu2.setexit_button("Submit");
	menu2.loop();
	
	menu2.clear();
	menu2.setheight(15);
	menu2.settcolor(GREEN);
	menu2 << ui::centeralign << "Employee Management" << ui::endl << ui::endl;
	menu2.settcolor(WHITE);
	menu2 << "Employee Details: " << ui::endl;
	menu2.settcolor(ui::tcolor);
		getch();
		menu2.hide();
		getch();
		menu2.display();
		getch();
	menu2 << "ID: " << id << ui::endl;
		getch();
		menu2.hide();
		getch();
		menu2.display();
		getch();
}

The same problem as mentioned in the issue came up here.
Now I commented out the line menu2 << "View employee data" << ui::endl;. Here, another problem came up; menu2 << "ID: " << id << ui::endl; doesn't print the line ID: (whatever id is) at all...

@arpit-saxena
Copy link
Member

This is quite weird. I'll have to look into it. Your code is alright

@arpit-saxena
Copy link
Member

Something very, very weird is going on. It seems like Turbo is running out of memory here. I narrowed it down to a place where I figured the problem has to lie. The problem was in a statement that just used new to allocate heap memory, and that statement resulted in another memory space being modified, which I guess is turbo running out of memory and reallocating stuff.

@arpit-saxena
Copy link
Member

SOMEONE NEEDS TO FIX THIS!!
ANY CLUE REGARDING WHAT'S GOING ON WOULD BE HELPFUL

@chiru9670
Copy link
Contributor Author

You guys wanna ask some prof at IITD/IITB about this??!!

@arpit-saxena
Copy link
Member

arpit-saxena commented Sep 1, 2018

Asking a prof would be overkill. Let's ask some of the genius coders here. Do you know any?

I asked some people in some groups. Let's see what happens.

And... do you know where can we run turbo c++ here?

@chiru9670
Copy link
Contributor Author

Well, I can run it on my roommate's laptop here...

@sankalpgambhir
Copy link
Member

Oioioioioioi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants