Results 1 to 8 of 8

Thread: exited with code -1073741819

  1. #1
    Join Date
    Jan 2011
    Posts
    33
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default exited with code -1073741819

    i made a new class inheriting QTcpsocket,with the following content :

    mytcpsocket.h
    Qt Code:
    1. #ifndef MYTCPSOCKET_H
    2. #define MYTCPSOCKET_H
    3.  
    4. #include <QTcpSocket>
    5. #include <QString>
    6. #include <qvariant.h>
    7.  
    8. class MyTcpSocket : public QTcpSocket
    9. {
    10. public:
    11. MyTcpSocket(QObject* parent = 0);
    12. void setClientUser(const QString &strClientUser);
    13. void setGroup(const int &iGroup);
    14. QString getClientUser();
    15. int getGroup();
    16. private:
    17. QString strClientUser;
    18. int iGroup;
    19. };
    20.  
    21. #endif // MYTCPSOCKET_H
    To copy to clipboard, switch view to plain text mode 
    mytcpsocket.cpp
    Qt Code:
    1. #include "mytcpsocket.h"
    2.  
    3. MyTcpSocket::MyTcpSocket(QObject* parent) : QTcpSocket(parent)
    4. {
    5. //strClientUser = tr("Student");
    6. iGroup = 0;
    7. }
    8. void MyTcpSocket::setClientUser(const QString &strClientUser){
    9. this->strClientUser = strClientUser;
    10. }
    11. void MyTcpSocket::setGroup(const int &iGroup){
    12. this->iGroup = iGroup;
    13. }
    14. QString MyTcpSocket::getClientUser(){
    15. return strClientUser;
    16. }
    17. int MyTcpSocket::getGroup(){
    18. return iGroup;
    19. }
    To copy to clipboard, switch view to plain text mode 

    whenever i used the method of setClientUser or getClientUser
    the program got exited with code -1073741819

    but the methods of setGroup and getGroup run properly.

    help me get to know and solve this problem.thank you so much

  2. #2
    Join Date
    Jan 2011
    Location
    Netherlands
    Posts
    17
    Thanks
    4
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: exited with code -1073741819

    These methods + implementation are correct so they should work. Perhaps you are not properly creating a new MyTcpSocket object before calling the methods of this object? Such as:

    Qt Code:
    1. MyTcpSocket* socket = new MyTcpSocket
    To copy to clipboard, switch view to plain text mode 

    Can you show us the code on which it fails?

  3. #3
    Join Date
    Jan 2011
    Posts
    33
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: exited with code -1073741819

    this is my code :

    client side,when connected() occurs :

    Qt Code:
    1. if(socket == NULL) return;
    2. if(socket->state() != QAbstractSocket::ConnectedState ) return;
    3. QString msg = "NICK";
    4. QVariant data = QVariant(ui->nick->text().toLatin1());
    5. QByteArray block;
    6. QDataStream out(&block, QIODevice::WriteOnly);
    7. out.setVersion(QDataStream::Qt_4_2);
    8. out << (quint32) 0;
    9. out << msg;
    10. out << data;
    11. out.device()->seek(0);
    12. out << (quint32)(block.size() - sizeof(quint32));
    13.  
    14. socket->write(block);
    15. socket->flush();
    To copy to clipboard, switch view to plain text mode 

    site sever when receive a message from cilent :

    Qt Code:
    1. MyTcpSocket* socket = static_cast<MyTcpSocket*>(sender());
    2.  
    3. if (socket == NULL) return;
    4. if ( socket->state() != QAbstractSocket::ConnectedState ) return;
    5.  
    6. QDataStream in(socket);
    7. in.setVersion(QDataStream::Qt_4_2);
    8.  
    9. if (blockSize == 0) {
    10. if (socket->bytesAvailable() < (int)sizeof(quint32)) return;
    11. in >> blockSize;
    12. }
    13.  
    14. if (socket->bytesAvailable() < blockSize) return;
    15.  
    16. QString msgString;
    17. QVariant msgData;
    18. in >> msgString;
    19. in >> msgData;
    20.  
    21. if(msgString != "NICK"){
    22. onMessage( msgString, msgData );
    23. }else{
    24. socket->setGroup(1);
    25. qDebug() << "value of group is : " << socket->getGroup();
    26. socket->setClientUser(msgData.toString());
    27. qDebug() << "ok";
    28. }
    29. blockSize = 0;
    30. if (socket->bytesAvailable() > 0) receiveMessage();
    To copy to clipboard, switch view to plain text mode 

    Application sever output :
    value of group is : 1
    D:\ProGram\QT\SimpleChat-build-desktop\SimpleChatServer\debug\SimpleChatServer.ex e exited with code -1073741819

  4. #4
    Join Date
    Jan 2011
    Posts
    33
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: exited with code -1073741819

    someone help me

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: exited with code -1073741819

    What is in msgData at line 25 (last listing)? Can it be converted to a string?

    Edit, more:
    -1073741819 is 0xC0000003, which in Windows land means Access violation. This would normally be caused by access through an invalid pointer, or using a reference to an object that no longer exists.
    Last edited by ChrisW67; 26th January 2011 at 06:54. Reason: updated contents

  6. #6
    Join Date
    Jan 2011
    Posts
    33
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: exited with code -1073741819

    I try to use qDebug() << "value of data is : " << msgData.toString(); and it prints out the exact name the user input from client side
    instead of using socket->setClientUser(msgData.toString()); i try socket-> setclientuser("Cuong"); or socket-> setclientuser(tr("Cuong"));<<< but the same error occurs

  7. #7
    Join Date
    Jan 2011
    Posts
    33
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: exited with code -1073741819

    Somebody help me, I need it

  8. #8
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: exited with code -1073741819

    Is "socket" still pointing at a valid object?
    Have you determined the exact line that the error is triggered by?

Similar Threads

  1. Replies: 3
    Last Post: 2nd November 2010, 22:36
  2. program crashing randomly code -1073741819
    By feraudyh in forum General Programming
    Replies: 6
    Last Post: 21st September 2010, 17:07
  3. name.exe exited with code 1.
    By Fallen_ in forum Qt Programming
    Replies: 2
    Last Post: 2nd September 2010, 01:17
  4. Qt Creator exited with code -1073741515
    By OverTheOCean in forum Qt Tools
    Replies: 4
    Last Post: 6th April 2010, 13:54
  5. exited with code -1073741819 error
    By arpspatel in forum Qt Programming
    Replies: 8
    Last Post: 2nd March 2010, 09:47

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.