|
Hi,
I've tried to exit the thread on the "close" event. Unfortunately, the worker
thread seems to crash somewhere in between the following 2 instants.
a) when the user clicks on the close button 'x' of the
application window AND
b) when the "close" event handler is called.
Thus the "Debug Assert failure "problem persists.
Should i try the suggestion posted by Stuart Dootson ?
Any help will be greatly appreciated.
|
|
|
|
|
A) Is the CDialog::OnClose() method called before or after you try to shut down the thread? This could have been a quick hack to fix the problem, though not a solid solution.
B) Seriously, Stuart is right. Threads should post messages to the main application, and not to dialogs directly, that way pointers and objects that are not valid are thrown away easily by the operating system, and you don't have to worry about this sort of thing consistently. I would rework the code as suggested by Stuart. But it shouldn't be that difficult.
|
|
|
|
|
You don't want to manipulate UI from a worker thread. You can post windows messages safely enough, but calling control methods will, at best, send a message rather than posting it, which isn't a good idea, believe me.
Try posting an app-specific message to the UI threads queue using PostThreadMessage. Respond to that message in the UI by redrawing the UI.
Also, you probably want to tell the worker to stop before terminating and wait for it to do so.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hello,
I am trying to run my Win32 application in Release mode. The application breaks and it pops up a message box with title "Microsoft Visual C++ Debug Library" and the first line in message box is "Debug Error!"
Below that, there is some "Buffer overrun ........." message.
And it has 3 buttons, ABORT, RETRY, CANCEL.
Just confused why in Release mode it popos up a message box with Debug Error.
Is it a problem with Release Configuration setting?
Any help is welcome.
Thanks in advance!
|
|
|
|
|
No, it sounds more like a problem with your code - the "Buffer overrun" gives it away.
Although...why does it say "Microsoft Visual C++ Debug Library" - are you linking with a release variant of the run-time (in project properties, check C/C++->Code Generation->Runtime Library)?
Anyway - if you've got the correct runtime variant, turn on debug information (you can, even in a Release mode app) and run your app under the debugger. See where in your code the exception is raised.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Check to see if you're not initializing any pointers to 0. Debug mode will do this for you, but in release mode, a pointer may start off with a garbage value, and consequently, if you try to use it, any one of a number of weird things can happen.
|
|
|
|
|
Hello,
I am working on a Win32 application in C/C++ using Visual Studio 2003.
There is a feature to write application data to a CD. This feature works fine. The issue is with, when the User enters a CD to the drive the application should be able to auto detect that and prompt the User.
Is there a Windows function to do that?
Is there a function which will retrieve whether a CD has been inserted to the CD Drive?
Thanks in advance!
|
|
|
|
|
Handle the WM_DEVICECHANGE message. The event will be DBT_DEVICEARRIVAL .
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
if I define a function like
int MakeBigger(int nVal1, int nVal2, int nMultiplier )
{
int nRetValue;
nRetValue = (nVal1+nVal2) * nMultiplier;
return (nRetValue);
}
is it necessary that the default parameter (nMultiplier) be the last parameter in the list?
For example, could the following be valid:
int MakeBigger(int nVal1, int nMultiplier, int nVal2)
{
}
or also
int MakeBigger(int nMultiplier, int nVal1, int nVal2)
{
}
ALSO
Is it valid to have more than one default parameter? AND what is the correct syntax:
int MyFn(int nDefaultParam)
OR
int MyFn(int nDefaultParam=2)
Thanks,
Johnny
|
|
|
|
|
Default parameters must be last in your function definitions.
You can have more than one default parameter:
int MyFn(int nParam1, bool bRequired = true, float fMultiplier = 2.26);
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
Thanks!
I have seen two types of syntax regarding the definition of the default values:
void MyFn(int nDefault)
and
void MyFn(int nDefault=2)
Which is "proper"?
|
|
|
|
|
john john mackey wrote: Which is "proper"?
Only the latter since the former is just a comment.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
void MyFn(int nDefault=2) is necessary somewhere in the code. If you declare this function in a class, then put this code in the class. If you are declaring it before the function call and definition, you can declare it like this as well. Then, you can use void MyFn(int nDefault/*=2*/) when you define the function.
Otherwise, when you define the function, you must write void MyFn(int nDefault=2) as the function header.
|
|
|
|
|
The second one would be the prototype and the first one would be the actual function.
void MyFn(int nDefault=2);
void MyFn(int nDefault)
{ ... }
The only reason for applying the second one to the functions is so that it reflects the prototype (a.k.a. documents prototype parameter).
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Which is a bad practice. Since modification of default value would need to change two places in code...
|
|
|
|
|
Does anybody know how the NTVDM.EXE, launched CREATE_SEPARATE_WOW_VDM via CreateProcess, shuts itself down.
I have a 16bit app and a 16bit DLL. Lets assume that the 16 bit DLL allocates some resources and then frees them in the WEP function.
The 16 bit app is created via 32bit call CreateProcess with CREATE_SEPARATE_WOW_VDM. However, upon 16 bit app termination, the 16 bit DLL WEP function is not automatically called.
The 16bit DLL WEP code IS called when CREATE_SHARED_WOW_VDM flags settings is used. Does anyone know why or have they seen this behavior before?
I am starting to get alot of insufficient resources error messages and was wondering is it related. Now, it is completely feasible that there are other memory/resource leaks in the 16bit app/dll. I'm just trying to rule this out first.
Error message =
The Win 16 Subsystem has insufficent resources to continue running. Click on OK, close your applications, and restart your machine.
|
|
|
|
|
Hello,
After I have added some new controls to dialog and add variables related with these new controls
,application crashes.( no crash after controls are added but related variable are not defined) When I break application and try to debug it , I saw that it is crashing
within void Reallocate( _In_ int nLength ) function of CSimpleStringT class.Any comments ...
|
|
|
|
|
Can you remove all of the related variables and then add them back in one at a time until the problem appears?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I have already remove all latest added control, and try to put one bye one and change their IDs also. I got the some result.As soon as first variable defined after first control is put onto dialog , it crashes.
|
|
|
|
|
Bilge Kaan wrote: ...it crashes.
Exception, assertion, or some other anomaly?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hi,
I am working on one C++ DLL. That dll is internally using some statically build common.lib. When I am building the DLL, I am getting following linking errors:
Creating library Release Standard Heap/paecustomactions.lib and object Release Standard Heap/paecustomactions.exp
common.lib(properocommon.obj) : error LNK2019: unresolved external symbol __imp__mymalloc referenced in function _MIDL_user_allocate@4
common.lib(properocommon.obj) : error LNK2019: unresolved external symbol __imp__myrealloc referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl PROPERO::FormatStringA(char const *,...)" (?FormatStringA@PROPERO@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PBDZZ)
common.lib(hcheapfix.obj) : error LNK2019: unresolved external symbol __imp__myfree_cond referenced in function _myfree
common.lib(sysconfig.obj) : error LNK2019: unresolved external symbol __imp__mycalloc referenced in function "public: __thiscall PROPERO::Runnable::Runnable(int,int,unsigned short const *)" (??0Runnable@PROPERO@@QAE@HHPBG@Z)
common.lib(stackTrace32.obj) : error LNK2001: unresolved external symbol __imp__mycalloc
../bin/i386/release/paecustomactions.dll : fatal error LNK1120: 4 unresolved externals
Can you please guide me to solve this issue?
Thanks in advance
|
|
|
|
|
Reason :-
1. Did u included the include file of systemconfig.h, propercommon.h etc in your project along with the library?
2. Common.lib is again referencing some other libs, you need to find those libs which common.lib is referencing.
and check
http://msdn.microsoft.com/en-us/library/799kze2z(VS.71).aspx[^]
modified on Friday, July 10, 2009 8:57 AM
|
|
|
|
|
1) Find the library that implements those functions and link to it.
or
2) Write implementations for those functions.
It looks to me like your DLL wants to link against another DLL - that's what the __imp__ prefix on the undefined external names implies to me...
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I am doing custom drawing of my header control in listview, that time i would like to know the image number associated with the column. The column doesn't have any image associated to it,has the image number as -1, this is the default value.
I am using Header_GetItem macro to identify the column details. I am getting all the detials like Name of the column, Width of the column correctly, but the image number is wrong. The image number always comes as 0 for the column not associated with any image. But it should come as -1.
HDITEM pColItem;
pColItem.mask = HDI_TEXT |HDI_FORMAT |HDI_IMAGE ;
pColItem.pszText = wcBuf;
pColItem.cchTextMax = 255;
pColItem.iImage = I_IMAGECALLBACK;
Header_GetItem(HederHandle,nColIndex,&pColItem);
Can anyone please help me how to rectify this problem?
|
|
|
|
|
I am using Microlsoft Visual Studio 6.00.
I am creating a new frame using CreateNewFrame(). At the time of creation of class I derive the class from CScrollView. I want to paint the background of the view with some color. So I am using SetBkColor as
pDC->SetBkColor(RGB(255,0,0))
Here 'pDC' is of OnDraw() method.
But it can't work.
Plz tell me how can I paint the background window.
Regards
Nikesh
|
|
|
|