|
Since you mentioned garbage collection, I gather you are using .NET. Rather than setting the objects to null or letting them go out of scope, try explicitly callin the Dispose() method as soon as you are done using them.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
It was actually a suggestion by Ryan Binns in the above reply, but only if I was using managed code.
I really am unsure if I am using managed code or not. I read on a website that managed code is code that uses the .NET framework. Well, I don't know if I am, but I know I'm using vs.net 2005, so doesn't that mean I am? How annoying it all is... heh
I read tutorials on sites about garbage collection which state that I am required to include certain dlls and set my Common Language Runtime (CLR). Well, I wasn't using any CLR support so now I am questoning if I really am using managed code. When I set CLR support on, I get numerous errors.
Here is essentially how I've been removing my class objects (the code doesn't sit next to each other, but I've placed them in the order they run...(and they do run)). No memory leaks were detected with my software either (see original post).
class gameplayscene
{
public:
gameplayscene() {miniScene = 0; }
~gameplayscene();
...
private:
...
int miniScene;
menu * mainMenu;
};
class menu
{
public:
menu();
~menu(); //deletes the textures I dynamically loaded.
...
private:
...
};
//User clicks menu button
if (miniScene != 1)
{
mainMenu = new menu;
miniScene = 1;
}
//User Interact with menu and we also draw it to screen
...(do menu stuff here)...
//User clicks return on menu
delete mainMenu;
mainMenu = NULL;
miniScene = 0;
(keep in mind the code was retyped, not a direct copy, and the menu can be called anytime miniScene = 0)
-- modified at 2:17 Tuesday 14th March, 2006
|
|
|
|
|
I'm thinking resource leak.
You might also want to delete mainMenu in the gameplayscene destructor, but if your tools aren't saying there's a leak...
I'm out of ideas. Once you fix it, it will probably either be something blatantly obvious in hindsight or something that will keep you scratching your head every time you think about it (been there too many times.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
what dll or lib coresponding to the sdk? for example mfc lib is supplied in mfc42.lib or mfc42.dll.
|
|
|
|
|
When i run my project on debug mode, i get a message saying that profuis225md.dll is not a valid windows image. If I run it on release mode, the project is ok. I can't debug the project because of this. What can I do to solve this problem. Thanks in advance.
|
|
|
|
|
Hi all.
I want close my form (CFormView dialog) when i press the Esc key.
Please give some code.
Thanks
|
|
|
|
|
pjmvn wrote: I want close my form (CFormView dialog)...
What is a "CFormView dialog?"
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
See this code:
try<br />
{<br />
conn = new CDaoDatabase(); <br />
conn->Open(fileName);<br />
}<br />
catch(CDaoException* error){}
This code will open the Database for me but i can not catch the CDaoException when error. Ex: when the fileName is wrong.
Please help me for this problem.
Thanks
|
|
|
|
|
Hi pjmvn,
try
{
CDaoDatabase *conn;
LPCTSTR fileName="c:\1";
conn = new CDaoDatabase();
conn->Open(fileName);
}
catch(CDaoException* error)
{
switch( )
{
case 1://Here is error code 1 is example
break;
}
}
-- modified at 23:32 Monday 13th March, 2006
|
|
|
|
|
Sorry, my question is not abvious.
This is my code:
try<br />
{<br />
conn = new CDaoDatabase(); <br />
conn->Open(fileName);<br />
}<br />
catch(CDaoException* error)<br />
{<br />
delete conn;<br />
conn = NULL;<br />
LPTSTR errors = L"";<br />
error->GetErrorMessage(errors,100,NULL);<br />
AfxMessageBox(errors);<br />
}
When fileName is wrong. The program does not show Message.
It debug only
|
|
|
|
|
I put a breakpoint at a location and was trying to debug the program. When i hit "run" it should stop at the breakpoint. But, it is giving me a message that "the code has exited" without stopping at the breakpoint. I tried changing the location. Wherever in the program i put a breakpoint and try to debug, the same thing is happening. What might be the problem?
|
|
|
|
|
Sound like the breakpoint isn't being hit. Put a call the MessageBox in the code to verify this suspicion.
Steve
|
|
|
|
|
cuteee wrote: When i hit "run"...
Is this via F5 or Ctrl+F5?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
|
So even though the breakpoint is not being hit, does the code in that routine execute?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Hi,
I am wondering what the correct way is to properly end a modeless dialog during the OnInitDialog. I currently have 2 (lets call them A and B) dialogs, B is called during the OnInitDialog handling of A. If the return from B is false, then I don't want to display A. When the dialog was modal, I just used an EndDialog(IDABORT) call without any problems. Now that I moved to modeless, I'm wondering if this is still correct. I can't seem to find anywhere that this topic is discussed. Thanks for the help.
Doug
|
|
|
|
|
|
Mike,
This doesn't seem correct since the dialog hasn't been created yet. I agree that typically you use the DestroyWindow() function to close the dialog, but I have created the dialog yet through the OnInitDialog().
Thanks,
Doug
|
|
|
|
|
Inside OnInitDialog the dialog has been created - It's just not visible yet.
Steve
|
|
|
|
|
Ok - I get some assertion errors if I use the destroywindow() call (line 207 of winocc.cpp and line 105 of afxwin2.inl). If I use the EndDialog(IDABORT), even though this is a modeless dialog, I don't get these assertion errors. Are you sure that the above statements are true?
|
|
|
|
|
Verify it for yourself (I would). Put a breakpoint in OnInitDialog and when hit look at the this->m_hWnd class member. You can use Spy (or code is a call to ::IsWindow ) to verify the HWND exists. But yes, I'm sure.
Steve
|
|
|
|
|
Ok, that seems to be true that the handle is there. However, when you call destroy window, the handle gets removed (which I believe is what is causing the assertion errors). It would seem that we don't want to Destroy the window yet. Does this make sense?
Thanks,
Doug
|
|
|
|
|
Sounds possible - But I don't know off hand. The lines numbers in my MFC don't line up with yours (I use MSVC6) so I can't have a look and see what the problem is. Can you post some details of the ASSERTS?
Steve
|
|
|
|
|
Steve,
Both assertion errors are related to the handle being null (line 207 of winocc.cpp - ASSERT(::IsWindow(m_hWnd) || (m_pCtrlSite != NULL)); and line 105 of afxwin2.inl - { ASSERT(::IsWindow(m_hWnd)); ::GetWindowRect(m_hWnd, lpRect); }). This means the handle shouldn't be null - caused by the destroywindow(). So, what is the correct call for the closing modeless during OnInitDIalog()?
Thanks,
Doug
|
|
|
|
|
Try this:
PostMessage(WM_CLOSE);
Steve
|
|
|
|