thomers
10th October 2011, 12:56
Hi,
I have sort of a big problem: my qt app is more or less randomly throwing a "integer division by zero"-error while processing an emitted signal (the function created in the moc'd cpp file).
This is the situation:
- Qt App with a QGraphicsView containing one PixmapItem that repeatedly gets updated and one QDeclarativeComponent for the UI that overlays the PixmapItem.
- I have one QThread that collects data from a picture grabbing device and once finished grabbing enough data it emits a "onNewImage()" signal without any parameters.
- the according slot "newImage()" in my MainWindow then creates a QImage/QPixmap from the data (BYTE *) and gives this image to the PixmapItem
In general, this work very much to my satisfaction.
But now an then, an more or less reproducible (3 out of 10), my app gets an "integer devision by zer"-error an crashes:
http://img12.imageshack.us/img12/7442/errormessages.th.png (http://img12.imageshack.us/i/errormessages.png/)
This error is thrown INSIDE the handling of the emitted signal in the according moc'd cpp file:
http://img69.imageshack.us/img69/2223/errorsignal.th.png (http://img69.imageshack.us/i/errorsignal.png/)
This is what the debugger-log says:
http://img546.imageshack.us/img546/4867/errordebuglog.th.png (http://img546.imageshack.us/i/errordebuglog.png/)
FYI: I do not even have one division in the whole code ...
And here some snippets:
- emitting function in Thread:
void GrabberController::run() {
if(!_inited)
return;
_fpsTimer.start();
_running = true;
while(_running) {
if(_grabber->Download(_data)) {
_fps++;
emit onNewImage();
}
else
qDebug(_grabber->GetLastError().c_str());
}
_running = false;
}
with:
signals:
void onNewImage();
- the receiving end:
void MainWindow::newImage() {
QSize size = _grabber->imageSize();
_currentImage = QImage(_grabber->data(), size.width(), size.height(), _grabber->imageFormat());
if(_currentImage.isNull())
return;
//_imgItem.setImage(_currentImage);
_pixItem.setPixmap(QPixmap::fromImage(_currentImag e));
_graphicsView->update();
}
with:
connect(_grabber, SIGNAL(onNewImage()), SLOT(newImage()), Qt::QueuedConnection);
- and finaly the error throwing moc'd cpp:
/************************************************** **************************
** Meta object code from reading C++ file 'grabbercontroller.h'
**
** Created: Mon 10. Oct 13:28:02 2011
** by: The Qt Meta Object Compiler version 62 (Qt 4.7.4)
**
** WARNING! All changes made in this file will be lost!
************************************************** ***************************/
#include "../grabbercontroller.h"
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'grabbercontroller.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 62
#error "This file was generated using the moc from 4.7.4. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
static const uint qt_meta_data_GrabberController[] = {
// content:
5, // revision
0, // classname
0, 0, // classinfo
3, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
2, // signalCount
// signals: signature, parameters, type, tag, flags
19, 18, 18, 18, 0x05,
36, 32, 18, 18, 0x05,
// slots: signature, parameters, type, tag, flags
47, 18, 18, 18, 0x0a,
0 // eod
};
static const char qt_meta_stringdata_GrabberController[] = {
"GrabberController\0\0onNewImage()\0fps\0"
"onFps(int)\0updateFps()\0"
};
const QMetaObject GrabberController::staticMetaObject = {
{ &QThread::staticMetaObject, qt_meta_stringdata_GrabberController,
qt_meta_data_GrabberController, 0 }
};
#ifdef Q_NO_DATA_RELOCATION
const QMetaObject &GrabberController::getStaticMetaObject() { return staticMetaObject; }
#endif //Q_NO_DATA_RELOCATION
const QMetaObject *GrabberController::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
}
void *GrabberController::qt_metacast(const char *_clname)
{
if (!_clname) return 0;
if (!strcmp(_clname, qt_meta_stringdata_GrabberController))
return static_cast<void*>(const_cast< GrabberController*>(this));
return QThread::qt_metacast(_clname);
}
int GrabberController::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QThread::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
switch (_id) {
case 0: onNewImage(); break;
case 1: onFps((*reinterpret_cast< int(*)>(_a[1]))); break;
case 2: updateFps(); break;
default: ;
}
_id -= 3;
}
return _id;
}
// SIGNAL 0
void GrabberController::onNewImage()
{
QMetaObject::activate(this, &staticMetaObject, 0, 0);
}
// SIGNAL 1
void GrabberController::onFps(int _t1)
{
void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
QMetaObject::activate(this, &staticMetaObject, 1, _a);
}
QT_END_MOC_NAMESPACE
Can anyone help me here?
Cheers
Thomas
I have sort of a big problem: my qt app is more or less randomly throwing a "integer division by zero"-error while processing an emitted signal (the function created in the moc'd cpp file).
This is the situation:
- Qt App with a QGraphicsView containing one PixmapItem that repeatedly gets updated and one QDeclarativeComponent for the UI that overlays the PixmapItem.
- I have one QThread that collects data from a picture grabbing device and once finished grabbing enough data it emits a "onNewImage()" signal without any parameters.
- the according slot "newImage()" in my MainWindow then creates a QImage/QPixmap from the data (BYTE *) and gives this image to the PixmapItem
In general, this work very much to my satisfaction.
But now an then, an more or less reproducible (3 out of 10), my app gets an "integer devision by zer"-error an crashes:
http://img12.imageshack.us/img12/7442/errormessages.th.png (http://img12.imageshack.us/i/errormessages.png/)
This error is thrown INSIDE the handling of the emitted signal in the according moc'd cpp file:
http://img69.imageshack.us/img69/2223/errorsignal.th.png (http://img69.imageshack.us/i/errorsignal.png/)
This is what the debugger-log says:
http://img546.imageshack.us/img546/4867/errordebuglog.th.png (http://img546.imageshack.us/i/errordebuglog.png/)
FYI: I do not even have one division in the whole code ...
And here some snippets:
- emitting function in Thread:
void GrabberController::run() {
if(!_inited)
return;
_fpsTimer.start();
_running = true;
while(_running) {
if(_grabber->Download(_data)) {
_fps++;
emit onNewImage();
}
else
qDebug(_grabber->GetLastError().c_str());
}
_running = false;
}
with:
signals:
void onNewImage();
- the receiving end:
void MainWindow::newImage() {
QSize size = _grabber->imageSize();
_currentImage = QImage(_grabber->data(), size.width(), size.height(), _grabber->imageFormat());
if(_currentImage.isNull())
return;
//_imgItem.setImage(_currentImage);
_pixItem.setPixmap(QPixmap::fromImage(_currentImag e));
_graphicsView->update();
}
with:
connect(_grabber, SIGNAL(onNewImage()), SLOT(newImage()), Qt::QueuedConnection);
- and finaly the error throwing moc'd cpp:
/************************************************** **************************
** Meta object code from reading C++ file 'grabbercontroller.h'
**
** Created: Mon 10. Oct 13:28:02 2011
** by: The Qt Meta Object Compiler version 62 (Qt 4.7.4)
**
** WARNING! All changes made in this file will be lost!
************************************************** ***************************/
#include "../grabbercontroller.h"
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'grabbercontroller.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 62
#error "This file was generated using the moc from 4.7.4. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
static const uint qt_meta_data_GrabberController[] = {
// content:
5, // revision
0, // classname
0, 0, // classinfo
3, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
2, // signalCount
// signals: signature, parameters, type, tag, flags
19, 18, 18, 18, 0x05,
36, 32, 18, 18, 0x05,
// slots: signature, parameters, type, tag, flags
47, 18, 18, 18, 0x0a,
0 // eod
};
static const char qt_meta_stringdata_GrabberController[] = {
"GrabberController\0\0onNewImage()\0fps\0"
"onFps(int)\0updateFps()\0"
};
const QMetaObject GrabberController::staticMetaObject = {
{ &QThread::staticMetaObject, qt_meta_stringdata_GrabberController,
qt_meta_data_GrabberController, 0 }
};
#ifdef Q_NO_DATA_RELOCATION
const QMetaObject &GrabberController::getStaticMetaObject() { return staticMetaObject; }
#endif //Q_NO_DATA_RELOCATION
const QMetaObject *GrabberController::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
}
void *GrabberController::qt_metacast(const char *_clname)
{
if (!_clname) return 0;
if (!strcmp(_clname, qt_meta_stringdata_GrabberController))
return static_cast<void*>(const_cast< GrabberController*>(this));
return QThread::qt_metacast(_clname);
}
int GrabberController::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QThread::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
switch (_id) {
case 0: onNewImage(); break;
case 1: onFps((*reinterpret_cast< int(*)>(_a[1]))); break;
case 2: updateFps(); break;
default: ;
}
_id -= 3;
}
return _id;
}
// SIGNAL 0
void GrabberController::onNewImage()
{
QMetaObject::activate(this, &staticMetaObject, 0, 0);
}
// SIGNAL 1
void GrabberController::onFps(int _t1)
{
void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
QMetaObject::activate(this, &staticMetaObject, 1, _a);
}
QT_END_MOC_NAMESPACE
Can anyone help me here?
Cheers
Thomas