UpdateData(FALSE) causes assertion failure 
Author Message
 UpdateData(FALSE) causes assertion failure

Hi:

I have a vc++5.0 application that has a dialog box that has buttons that
send text strings out the serial port and, by decoding the data that is
sent back to the serial port in response, displays what the response
was.

Depending on what came back from the remote device I display different
messages in an edit box on the dialog box with code similar to:

void CMyDlg::OnCharIn(LPCTSTR pchData, int nBy)
{    ...

     m_EditBox1="My Message";
    UpdateData(FALSE);

Quote:
}

Where OnCharIn() is called from a method in MyDoc.cpp which, in turn, is
called from my serial port routines whenever data comes into the serial
port.

Whenever I run my application in release mode everything works fine and
the data is displayed properly.

The problem is that when I run in Debug mode I get an assertion error
whenever the program gets to "UpdateData(FALSE)".  I get the messages:

Debug Assertion Failed; then
Unhandled exception in MyProg.exe(MFC42D.DLL; 0xC0000005; Access
violation.

(Whenever I run code with "UpdateData(FALSE)" in it directly from a
button on my dialog box everything works fine.)

Can anyone tell me what I'm doing wrong here?

Or, just as well, is there another way to display data in my edit box
that won't cause any problems?

TIA,
Brad McMillan



Thu, 09 Jan 2003 03:00:00 GMT  
 UpdateData(FALSE) causes assertion failure

Quote:

> Hi:

> I have a vc++5.0 application that has a dialog box that has buttons that
> send text strings out the serial port and, by decoding the data that is
> sent back to the serial port in response, displays what the response
> was.

> Depending on what came back from the remote device I display different
> messages in an edit box on the dialog box with code similar to:

> void CMyDlg::OnCharIn(LPCTSTR pchData, int nBy)
> {    ...

>      m_EditBox1="My Message";
>     UpdateData(FALSE);
> }

> Where OnCharIn() is called from a method in MyDoc.cpp which, in turn, is
> called from my serial port routines whenever data comes into the serial
> port.

> Whenever I run my application in release mode everything works fine and
> the data is displayed properly.

> The problem is that when I run in Debug mode I get an assertion error
> whenever the program gets to "UpdateData(FALSE)".  I get the messages:

> Debug Assertion Failed; then
> Unhandled exception in MyProg.exe(MFC42D.DLL; 0xC0000005; Access
> violation.

> (Whenever I run code with "UpdateData(FALSE)" in it directly from a
> button on my dialog box everything works fine.)

> Can anyone tell me what I'm doing wrong here?

> Or, just as well, is there another way to display data in my edit box
> that won't cause any problems?

> TIA,
> Brad McMillan

When you hit the access violation the de{*filter*} stack window should give you some
clues what's wrong.  Examine all the passed variables in the stack.

If your serial input routines are in another thread that is the problem.  MFC
CWnd functions don't work from threads that did not create the window.  A
solution is described in http://www.*-*-*.com/

--
Scott McPhillips [VC++ MVP]



Thu, 09 Jan 2003 03:00:00 GMT  
 UpdateData(FALSE) causes assertion failure
Brad,

I've been using MFC for only a few months now and quickly
learned that using UpdateData() is not the best method to
get/post data to/from controls. It addresses every control
while you only want the m_editBox. Try adding a control
variable (let's call it m_editbox1Ctrl) for your edit box
using the Class Wizard. Then just add this code in your
OnCharIn routine:

   m_editbox1Ctrl.SetWindowText(_T("My message"));

If you are using a multiline edit box you can access individual
lines using CEdit's GetLine(). Other type of controls may have
differing methods to access data.

hope this helps, Robb



Quote:
> Hi:

> I have a vc++5.0 application that has a dialog box that has buttons
that
> send text strings out the serial port and, by decoding the data that
is
> sent back to the serial port in response, displays what the response
> was.

> Depending on what came back from the remote device I display different
> messages in an edit box on the dialog box with code similar to:

> void CMyDlg::OnCharIn(LPCTSTR pchData, int nBy)
> {    ...

>      m_EditBox1="My Message";
>     UpdateData(FALSE);
> }

> Where OnCharIn() is called from a method in MyDoc.cpp which, in turn,
is
> called from my serial port routines whenever data comes into the
serial
> port.

> Whenever I run my application in release mode everything works fine
and
> the data is displayed properly.

> The problem is that when I run in Debug mode I get an assertion error
> whenever the program gets to "UpdateData(FALSE)".  I get the messages:

> Debug Assertion Failed; then
> Unhandled exception in MyProg.exe(MFC42D.DLL; 0xC0000005; Access
> violation.

> (Whenever I run code with "UpdateData(FALSE)" in it directly from a
> button on my dialog box everything works fine.)

> Can anyone tell me what I'm doing wrong here?

> Or, just as well, is there another way to display data in my edit box
> that won't cause any problems?

> TIA,
> Brad McMillan

Sent via Deja.com http://www.deja.com/
Before you buy.


Sat, 11 Jan 2003 03:00:00 GMT  
 UpdateData(FALSE) causes assertion failure

Assuming m_EditBox1 is of Type CString and NOT char or a control pointer,
your DoDataExchange(CDataExchange* pDX) should contain a line similar to the
one shown below:
     DDX_Text(pDX, ID_MY_EDIT_CONTROL, vm_m_EditBox1);

If m_EditBox1 isn;t a CString object then your code m_EditBox1="My Message";
is probably setting m_EditBox1 with a pointer to your string which may cause
the error you are getting.

DArryl

="My Message";

Quote:
> Brad,

> I've been using MFC for only a few months now and quickly
> learned that using UpdateData() is not the best method to
> get/post data to/from controls. It addresses every control
> while you only want the m_editBox. Try adding a control
> variable (let's call it m_editbox1Ctrl) for your edit box
> using the Class Wizard. Then just add this code in your
> OnCharIn routine:

>    m_editbox1Ctrl.SetWindowText(_T("My message"));

> If you are using a multiline edit box you can access individual
> lines using CEdit's GetLine(). Other type of controls may have
> differing methods to access data.

> hope this helps, Robb



> > Hi:

> > I have a vc++5.0 application that has a dialog box that has buttons
> that
> > send text strings out the serial port and, by decoding the data that
> is
> > sent back to the serial port in response, displays what the response
> > was.

> > Depending on what came back from the remote device I display different
> > messages in an edit box on the dialog box with code similar to:

> > void CMyDlg::OnCharIn(LPCTSTR pchData, int nBy)
> > {    ...

> >      m_EditBox1="My Message";
> >     UpdateData(FALSE);
> > }

> > Where OnCharIn() is called from a method in MyDoc.cpp which, in turn,
> is
> > called from my serial port routines whenever data comes into the
> serial
> > port.

> > Whenever I run my application in release mode everything works fine
> and
> > the data is displayed properly.

> > The problem is that when I run in Debug mode I get an assertion error
> > whenever the program gets to "UpdateData(FALSE)".  I get the messages:

> > Debug Assertion Failed; then
> > Unhandled exception in MyProg.exe(MFC42D.DLL; 0xC0000005; Access
> > violation.

> > (Whenever I run code with "UpdateData(FALSE)" in it directly from a
> > button on my dialog box everything works fine.)

> > Can anyone tell me what I'm doing wrong here?

> > Or, just as well, is there another way to display data in my edit box
> > that won't cause any problems?

> > TIA,
> > Brad McMillan

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Sun, 12 Jan 2003 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Debug Assertion failure on UpdateData();

2. Assertion Failure when calling UpdateData

3. the difference between updatedata(FALSE) and updatedata(TRUE)

4. Why does this function cause an assertion failure?

5. delete operator causing assertion failure

6. Accessing ComboBox in dialog box causes an Assertion failure

7. These codes cause a assertion failure..

8. CAsyncSocket::Create() in thread causes assertion failure

9. CRecortset::Delete causes assertion failure!

10. MFC Callback Causes Assertion Failure

11. Tooltips cause a assertion failure in regular dll

12. Tooltips used in dll cause assertion failure

 

 
Powered by phpBB® Forum Software