|
Has anyone else noticed some output from TRACE seems to occasionally be dropped before it appears in the debug window?
Am I paranoid? Am I covering my own programming inadequacies by blaming M$?
TIA,
Pete
|
|
|
|
|
donno about that, but i've been bitten already by the size limit of presearved text in the output window; it just won't hold generated C source for a 4MB transparency LUT
Black rooms are calling; To men in leather coats. White labs are cooking up the silver ghost. Smashing Pumpkins, Glass and the Ghost Children
|
|
|
|
|
The input buffer size for the TRACE output window is a limited size (after all its a pipe between the processes). If your debug output TRACE volume is high and the thread reading the buffer in the VC editor does not run often enough, you can lose TRACE information from the window.
So your not paranoid, if this is what is happening to you.
Roger Allen
Sonork 100.10016
If I'm not breathing, I'm either dead or holding my breath.
A fool jabbers, while a wise man listens. But is he so wise to listen to the fool?
|
|
|
|
|
That sounds like what is happening. I'm writing LOADS of memory allocation info to the debug output to try and track down mem leaks. I guess the only solution would be to put a little pause in my AllocHook() after every TRACE().
Thanks Roger.
|
|
|
|
|
No, you are probably getting bitten by a Visual Studio bug. Visual Studio filters the output of the OutPutDebugString() function, which the TRACE macro ultimately calls, before showing it in the output window in order to remove the application name (which otherwise gets added). However, the filtering is not too smart (at least with version 6.0), and it messes up the display of TRACE messages that includes both an open parenthesis "(" and a colon ":" in that order.
When I add the following lines to my code
TRACE (_T("Text before colon: Text after colon\n"));
TRACE (_T("Text with parenthesis() before colon: Text after colon\n"));
TRACE (_T("Text with open parenthesis( before colon: Text after colon\n"));
TRACE (_T("Text with close parenthesis) before colon: Text after colon\n"));
TRACE (_T("Text with (text inside parenthesis) before colon: Text after colon\n"));
the Visual Studio output window displays
Text before colon: Text after colon
Text with parenthesis() before colon
Text with open parenthesis( before colon
Text with close parenthesis) before colon: Text after colon
Text with (text inside parenthesis) before colon
Intrestingly, if I select this text text in the output window and paste it into notepad, I get
Text before colon: Text after colon
Text with parenthesis() before colonText with open parenthesis( before colonText with close parenthesis) before colon: Text after colon
Text with (text inside parenthesis) before colon
Stephen C. Steel
Kerr Vayne Systems Ltd.
|
|
|
|
|
No, you aren't being paranoid - there is a bug in Visual Studio version 6.0. The TRACE macro ultimately uses OutputDebugString(), and along the way the application name gets prepended to the output. Visual studio has a filter that attempts to strip the application name before showing the text in the output window, but it is buggy.
If I add the following code to my application
TRACE (_T("Text before colon: Text after colon\n"));
TRACE (_T("Text with parenthesis() before colon: Text after colon\n"));
TRACE (_T("Text with open parenthesis( before colon: Text after colon\n"));
TRACE (_T("Text with close parenthesis) before colon: Text after colon\n"));
TRACE (_T("Text with (text inside parenthesis) before colon: Text after colon\n"));
then the Visual Studio output window displays
Text before colon: Text after colon
Text with parenthesis() before colon
Text with open parenthesis( before colon
Text with close parenthesis) before colon: Text after colon
Text with (text inside parenthesis) before colon
Interestingly, if I select the text in the output window and paste it to notepad, I get
Text before colon: Text after colon
Text with parenthesis() before colonText with open parenthesis( before colonText with close parenthesis) before colon: Text after colon
Text with (text inside parenthesis) before colon
Stephen C. Steel
Kerr Vayne Systems Ltd.
|
|
|
|
|
I don't think this is the issue in my case, as I'm not using paretheses.
But thanks anyway, it's always useful to know stuff like that!
Pete
|
|
|
|
|
Can sombody tell me why this won't Beep? Cw is derived from CWinThread and Run() is supposed to be executed so what gives?
//////////////////////////////////
class Cw : public CWinThread
{
public:
int Run();
Cw();
virtual ~Cw();
};
Cw::Cw(){}
Cw::~Cw(){}
int Cw::Run()
{
Beep(1000,500);
return 0;
}
///////////////////////
elsewhere in the program:
Cw* w = new Cw();
w->CreateThread();
|
|
|
|
|
You must override CWinThread::InitInstance . This method by default returns FALSE thus preventing the call to CWinThread::Run .
As a sidenote, I assume you're doing this as a simple test and do not plan to base any actual code on this way of overriding CWinThread::Run : this method has to provide some sort of message pump (which is what does by default). To run separate tasks, it is better to use worker threads.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thank Joaquin, I'll give it a try. Actually, I need a thread with a message pump because i need to send it commands to do things. I can't figure out how to get message queue on a workerthread so I'm using a UI thread. I plan to put my own GetMessage() call into Run(). I will not be using this thread to service an UI elemets though. The only other thing that I know Run() does is call OnIdle(). Can I safly not call OnIdle() - I don't plan to overide it?
|
|
|
|
|
what?
I think you answered the wrong guy.
Bye
|
|
|
|
|
Joaquín,
I tried what you said and overriding CWinThread::InitInstance works. Thanks! Now I have another question. If I declare several instances of this class they all seem to share the same variables. Maybe I am not saying that right so I will show you the code:
class Cw : public CWinThread
{
public:
DWORD delay;
DWORD freq;
BOOL InitInstance();
int Run();
Cw();
virtual ~Cw();
};
Cw::Cw()
{ delay = 0;
freq=1000;
}
Cw::~Cw(){}
int Cw::Run()
{ Sleep(delay);
Beep(freq,500);
return 0;
}
BOOL Cw::InitInstance(){Return TRUE;}
////////////////////////
Then i have four of the instances and i think i should hear 4 tones one after the other but i don't. Are they all sharing the same delay and freq?
w = new Cw();
w->freq=5000;
w->CreateThread();
x = new Cw();
x->delay=500;
x->freq=2000;
x->CreateThread();
y = new Cw();
y->delay=1000;
y->freq=1000;
y->CreateThread();
z = new Cw();
z->delay=1500;
z->freq=500;
z->CreateThread();
///////////////////////////////////////////////
The above code should sound like this:
w = new Cw();
w->freq=5000;
w->CreateThread();
Sleep(500);
x = new Cw();
x->freq=2000;
x->CreateThread();
Sleep(500);
y = new Cw();
y->freq=1000;
y->CreateThread();
Sleep(500);
z = new Cw();
z->freq=500;
z->CreateThread();
|
|
|
|
|
Joaquín,
Please ignore my message above. It was a bad test. If I change the values it will work better. Thanks again for your help.
(But I still wonder about my OnIdle question: The only other thing that I know Run() does is call OnIdle(). Can I safly not call OnIdle() - I don't plan to overide it? )
Here is how I getting my test to work (I increased the delay):
//Sleep(500);
x = new Cw();
x->delay=3000;
x->freq=2000;
x->CreateThread();
//Sleep(500);
y = new Cw();
y->delay=6000;
y->freq=1000;
y->CreateThread();
//Sleep(500);
z = new Cw();
z->delay=9000;
z->freq=500;
z->CreateThread();
|
|
|
|
|
I'm not the guy you want to chat with.
please pay attention to my question ...about ocx, I had nothing to do with your subject.
Bye.
|
|
|
|
|
I've been trying to return data from an ODBC database and display it in a tabbed dialog (property page). The code compiles just fine, but I get a runtime error during execution. Specifically,
ERROR MESSAGE:
<br />
TRACE0("ASSERT_VALID fails with NULL pointer.\n");<br />
if (AfxAssertFailedLine(lpszFileName, nLine))<br />
AfxDebugBreak();<br />
return;
I know the CRecordset class I created works fine (I've used it before in a single dialog page). The problem seems to occur during data exchange in the CPropertypage class. Here's the code that is suspect:
CPROPERTYPAGE SOURCE:
<br />
CPersonalData::CPersonalData() : CPropertyPage(CPersonalData::IDD)<br />
{<br />
m_pSet = NULL;<br />
}<br />
<br />
void CPersonalData::DoDataExchange(CDataExchange* pDX)<br />
{<br />
CPropertyPage::DoDataExchange(pDX);<br />
DDX_FieldText(pDX, IDC_TITLE, m_pSet->m_TITLE, m_pSet);<br />
}<br />
<br />
CRecordset* CPersonalData::OnGetRecordset()<br />
{<br />
return m_pSet;<br />
}<br />
In addition, m_pSet is defined in the header file for the CPropertypage as follows:
CPROPERTYPAGE HEADER:
<br />
class CPhysiciansListSet;<br />
<br />
class CPersonalData : public CPropertyPage<br />
{<br />
DECLARE_DYNCREATE(CPersonalData)<br />
<br />
public:<br />
CPersonalData();<br />
~CPersonalData();<br />
<br />
virtual BOOL PreTranslateMessage (MSG* pMsg);<br />
<br />
enum { IDD = IDD_PERSONALDATA };<br />
CPhysiciansListSet* m_pSet;<br />
};<br />
Any suggestions would be GREATLY appreciated. I've been screwing around with this app for a week now on this one problem and I'm about to go crazy.
Thanks in advance.
|
|
|
|
|
I have a CHtmlView loaded with some HTML that i generate on the fly (loaded with IPersistStreamInit). it works fine - everything displays properly - yay.
the problem is when i try to do links within the document: links like <a href="#somelink">..</a> to <a name="somelink"> .
if i hit one of these, the browser takes me to a page that says "blank#somelink", not to the "somelink" on the original page.
since i'm loading this HTML stream dynamically, i can't use the res:// "protocol" and, "file://" doesn't work...
any ideas?
-c
Smaller Animals Software, Inc.
You're the icing - on the cake - on the table - at my wake. Modest Mouse
|
|
|
|
|
I nned to be able to get the main frame window from a worker thread with no GUI component. AfxGetMainWnd() get the main window for the current thread - the worker thread and so returns null.
Any ideas on how to get the MainFrame from the primary thread?
Thanks,
Giles
|
|
|
|
|
Pass HWND of MainFrame through thread parameters and then create CWnd object by CWnd::FromHandle(HWND) function in workeer thread
|
|
|
|
|
I thought of passing the handle, but was not sure if it would be okay from another thread. Despite that, I am updainting another window, but need to be able to get at the promary thread so I can attach to the Frane Window, and them the Status Bar.
Thanks,
Giles
|
|
|
|
|
Try AfxGetApp( )->m_pMainWnd
Nish
Bow wow wow,
Yippee yo yippee yay,
My miniputt high,
Is now 30 yay.
|
|
|
|
|
Thanks Nish, will check it out.
Giles
|
|
|
|
|
Hio again.. I have a class (CCompanyHandler) which loads and saves a CObArray which is full of CObjects. The load file function calls the CObject constructors, and I'm trying to figure out how to destruct all of these objects created when loaded. I figure if I can overload the CCompanyHandler destructor then I should be able to have it destruct all of the CObjects, but I still have some sort of memory leak. Here is a trace:
CCompanyHandler:Constructor
CCompanyHandler:LoadFile
CCompany:Contructor <+ 1
CCompanyHandler:Constructor
CCompanyHandler:LoadFile
CCompany:Contructor <+ 2
CCompanyHandler:Constructor
CCompanyHandler:LoadFile
CCompany:Contructor <+ 3
CCompanyHandler:LoadFile
CCompany:Contructor <+ 4
CCompanyHandler:Destructor
CCompany:Destructor <- 3
CCompanyHandler:Destructor
CCompany:Destructor <- 2
CCompanyHandler:Destructor
CCompany:Destructor <- 1
As you can see the LoadFile() function of CCompanyHandler is what calls the constructors for the objects as it reads them.
TRACE("CCompanyHandler:LoadFile\n");
try
{
CFile fileMyFile(m_strFileName,CFile::modeRead + CFile::modeNoTruncate); //open file for reading
CArchive arRead(&fileMyFile, CArchive::load); //open archive for loading
m_oaCompanies.Serialize(arRead); //call serialize function to populate m_oaCompanies
arRead.Close(); // close archive
fileMyFile.Close(); // close file
return 1;
}
My problem is that if I call the loadfile() function multiple times it will keep creating instances of CCompany, and then my destructor doesn't get rid of it.. here is what my destructor does:
TRACE("CCompanyHandler:Destructor\n");
if (GetSize() > 0)
for (int i = 0; i < GetSize(); i++)
((CCompany*)m_oaCompanies[i])->~CCompany();
As you can see this only calls the destructor for each of the objects in the CObArray, not all of the objects which were actually made by the loadfile() function..
basicly i am clueless on proper destruction right now, and I'm getting tons of memory leaks when I debug, any suggestions on proper destruction of pointers and such will be MOST appreciated.
-dz
|
|
|
|
|
hi i connected an access database thru classwizard by creating a recordset class and connecting the database thru the following dialog. how do i run executesql command to acess related tables since i cannot find an automatically generated CDatabase class
|
|
|
|
|
Do you want to run a Query or execute a SQL Statement?;)
Regards
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|