Hello,

EDIT: See 1st reply for likely solution.

I've seen this question get asked a lot but haven't found much of an answer beyond 'something is wrong with your sockets'. I've found this--thanks caduel--which says that 26 is likely an invalid file descriptor. How would an invalid descriptor come to be sent to a QSocketNotifier method? The socket in question is a QLocalSocket (one of two write sockets), and here is the code I use to send a message:

Qt Code:
  1. void MyClass::WriteToLog(const string& msg, MY_MSG_TYPE type)
  2. {
  3. QDataStream out(&qb,QIODevice::WriteOnly);
  4. out << quint16(0) << quint8(type) << QString(msg.c_str());
  5. int num_bytes = qb.size() - sizeof(quint16); //Subtract four because in reading the
  6. //size information, the two bytes containing it are removed from the stream
  7. // Also sizeof(MY_MSG_TYPE) == 8
  8. out.device()->seek(0);
  9. out << quint16(num_bytes);
  10.  
  11. my_socket->write(qb);
  12. my_socket->flush();
  13. }
To copy to clipboard, switch view to plain text mode 

This seems to happen more frequently the more data I send through this socket, but I don't really send that much, maybe several hundred bytes every vertical refresh (60Hz), or ~50KB/sec tops to get this.

I looked at the QSocketNotifier code and what I saw there confused me a little bit--

Qt Code:
  1. QSocketNotifier::QSocketNotifier(int socket, Type type, QObject *parent,
  2. const char *name)
  3. : QObject(parent)
  4. {
  5. setObjectName(QString::fromAscii(name));
  6. if (socket < 0)
  7. qWarning("QSocketNotifier: Invalid socket specified");
  8. sockfd = socket;
  9. sntype = type;
  10. snenabled = true;
  11.  
  12. ...
  13. }
To copy to clipboard, switch view to plain text mode 

It doesn't return the complete error message, and in the message I do get, the socket descriptor is always >0, e.g. 24 or 26.

Lastly, this crash is happening in a process launched from the one I launch using QtCreator, so I don't get any debugging output beyond what's in the subject line.

Can anybody help me with this? Thank you--

Best,
Matt