[Qt-jambi-interest] QtJambi: Exception pending in native code

Aekold Helbrass helbrass at gmail.com
Wed May 13 16:07:02 CEST 2009


Hi All!

I got strange exception, sounds like "QtJambi: Exception pending in
native code in file
'..\cpp\com_trolltech_qt_gui\qtjambishell_QGraphicsRectItem.cpp':727"
and whole application hangs writing those lines for ever.

Steps to reproduce - compile following code, run it (using Qt Jambi
4.5.0 downloaded hour ago), and try to drag some rectangles outside of
the view. It's because view.fitInView(this); line, without it bug will
not be reproduced.

Here is application code:

import com.trolltech.qt.core.*;
import com.trolltech.qt.gui.*;

public class Main {

    public static void main(String[] args) {
        QApplication.initialize(args);

        new Main().createAndShowGui();

        QApplication.exec();
    }

    private QMainWindow mainWindow;

    private void createAndShowGui() {
        mainWindow = new QMainWindow();
        mainWindow.setWindowTitle("Graphics");

        final QGraphicsScene scene = new QGraphicsScene(mainWindow);

        final QGraphicsView view = new QGraphicsView(scene);
        view.setRenderHint(RenderHint.Antialiasing);
        view.setBackgroundBrush(new QBrush(QColor.lightGray));

        for (int i = 0; i < 10; i++) {
            QGraphicsRectItem item = new QGraphicsRectItem(1 * i * 10,
1 * i * 10, 10, 10) {

                @Override
                public void mousePressEvent(QGraphicsSceneMouseEvent event) {
                }

                @Override
                public void mouseMoveEvent(QGraphicsSceneMouseEvent event) {

                    QPointF lastPos = event.lastPos();
                    QPointF pos = event.pos();

                    double moveX = pos.x() - lastPos.x();
                    double moveY = pos.y() - lastPos.y();
                    if (moveX == 0 && moveY == 0) {
                        return;
                    }

                    QRectF rect = rect();
                    setRect(rect.x() + moveX, rect.y() + moveY,
rect.width(), rect.height());

                    view.fitInView(this);

                }

            };
            item.setBrush(new QBrush(new QColor(256 / 10 * i, 256 / 10
* i, 256 / 10 * i)));

            scene.addItem(item);
        }

        QGridLayout gridLayout = new QGridLayout();
        gridLayout.addWidget(view, 0, 0);
        QWidget centralWidget = new QWidget(mainWindow);
        centralWidget.setLayout(gridLayout);
        mainWindow.setCentralWidget(centralWidget);

        mainWindow.show();
    }

}



More information about the Qt-jambi-interest mailing list