QObject: Cannot create children
for a parent that is in a different thread.
QObject: Cannot create children
for a parent that is in a different thread.
*** glibc detected *** double free or corruption (!prev): 0x08b8ad00 ***
*** Process aborted ***
QObject: Cannot create children for a parent that is in a different thread.
QObject: Cannot create children for a parent that is in a different thread.
*** glibc detected *** double free or corruption (!prev): 0x08b8ad00 ***
*** Process aborted ***
To copy to clipboard, switch view to plain text mode
void Window::sendFile()
{
cancelButton->setEnabled(true);
sendButton->setEnabled(false);
quitButton->setEnabled(false);
browseButton->setEnabled(false);
protocolComboBox->setEnabled(false);
directoryComboBox->setEnabled(false);
printerComboBox->setEnabled(false);
// The Two Files are here.
QString ticketName
= ticketComboBox
->currentText
();
QString fileName
= directoryComboBox
->currentText
();
// now put the two files together.
//first write the ticket
qint64 totalSize = ticket->size();
qint64 chunkSize = 2048;
char *readBuffer = new char[chunkSize];
while ( totalSize )
{
if( chunkSize > totalSize )
chunkSize = totalSize;
qint64 actuallyRead = ticket->read( readBuffer, chunkSize );
if( actuallyRead > 0 )
outPrn.write( readBuffer, actuallyRead );
else
break;
totalSize -= actuallyRead;
delete[] readBuffer;
outPrn.flush();
}
qint64 ptotalSize = file->size();
qint64 pchunkSize = 2048;
char *preadBuffer = new char[pchunkSize];
while ( ptotalSize )
{
if( pchunkSize > ptotalSize )
pchunkSize = ptotalSize;
qint64 pactuallyRead = file->read( preadBuffer, pchunkSize );
if( pactuallyRead > 0 )
outPrn.write( preadBuffer, pactuallyRead );
else
break;
ptotalSize -= pactuallyRead;
delete[] preadBuffer;
outPrn.flush();
}
connect(ftp, SIGNAL(stateChanged(int)),
this, SLOT(ftp_stateChanged(int)));
connect(ftp, SIGNAL(commandFinished(int, bool)),
this, SLOT(ftpCommandFinished(int, bool)));
// FTP the final File to the printer here.
}
void Window::sendFile()
{
cancelButton->setEnabled(true);
sendButton->setEnabled(false);
quitButton->setEnabled(false);
browseButton->setEnabled(false);
protocolComboBox->setEnabled(false);
directoryComboBox->setEnabled(false);
printerComboBox->setEnabled(false);
// The Two Files are here.
QString ticketName = ticketComboBox->currentText();
QFile *ticket = new QFile(ticketName, ftp);
ticket->open(QIODevice::ReadOnly);
QFileInfo ti( ticketName );
QString fileName = directoryComboBox->currentText();
QFile *file = new QFile(fileName, ftp);
file->open(QIODevice::ReadOnly);
QFileInfo fi( fileName );
// now put the two files together.
QFile outPrn("out.prn");
//first write the ticket
qint64 totalSize = ticket->size();
qint64 chunkSize = 2048;
char *readBuffer = new char[chunkSize];
while ( totalSize )
{
if( chunkSize > totalSize )
chunkSize = totalSize;
qint64 actuallyRead = ticket->read( readBuffer, chunkSize );
if( actuallyRead > 0 )
outPrn.write( readBuffer, actuallyRead );
else
break;
totalSize -= actuallyRead;
delete[] readBuffer;
outPrn.flush();
}
qint64 ptotalSize = file->size();
qint64 pchunkSize = 2048;
char *preadBuffer = new char[pchunkSize];
while ( ptotalSize )
{
if( pchunkSize > ptotalSize )
pchunkSize = ptotalSize;
qint64 pactuallyRead = file->read( preadBuffer, pchunkSize );
if( pactuallyRead > 0 )
outPrn.write( preadBuffer, pactuallyRead );
else
break;
ptotalSize -= pactuallyRead;
delete[] preadBuffer;
outPrn.flush();
}
ftp = new QFtp(this);
connect(ftp, SIGNAL(stateChanged(int)),
this, SLOT(ftp_stateChanged(int)));
connect(ftp, SIGNAL(commandFinished(int, bool)),
this, SLOT(ftpCommandFinished(int, bool)));
// FTP the final File to the printer here.
}
To copy to clipboard, switch view to plain text mode
Bookmarks