t-artistik / qtscriptgenerator

Automatically exported from code.google.com/p/qtscriptgenerator
0 stars 0 forks source link

QGraphicsItemAnimation causes crash when calling setItem(QGraphicsProxyWidget) (with Qt 4.6) #66

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create new QGraphicsProxyWidget
2. Create new QGraphicsItemAnimation 
3. call setItem with QGraphicsProxyWidget

Code:
  this.graphicsItem = this.scene.addWidget(new QPushButton("Hello"));
  this.animation = new QGraphicsItemAnimation;
  this.animation.setItem(this.graphicsItem); // CRASHES HERE

Instead of doing what is expected, qs_eval.exe crashes without explanation.

What version of the product are you using? On what operating system?

I am using Windows XP with Qt 4.6 and QtScriptgenerator dated 30. november
2009.

Code works fine with Qt 4.5.

Additional code for testing:

/* -- code for testing QGraphicsItemAnimation and QGraphicsProxyWidget */
function QtAnimationExperiments(parent) {
  QWidget.call(this, parent);

  this.scene = new QGraphicsScene(this);

  this.view = new QGraphicsView(this.scene, this);
  this.view.setRenderHint(QPainter.Antialiasing);
  this.view.viewportUpdateMode = QGraphicsView.FullViewportUpdate;

  this.button = new QPushButton("Click me!");
  this.button.clicked.connect(this, function() {
    switch(this.timer.state()) { 
      case QTimeLine.Running:
        this.timer.setPaused(true);
        this.button.text = "resume";
        break;
      case QTimeLine.Paused:
        this.timer.resume();
        this.button.text = "pause";
        break;
      default:
        this.timer.start();
        break;
      }
    }
   );

  this.graphicsItem = this.scene.addWidget(this.button);

  this.timer = new QTimeLine(6000);
  this.timer.curveShape = QTimeLine.LinearCurve;
  this.timer.setFrameRange(0, 360);
  this.timer.loopCount = 0; // loops forever

  debugger;

  this.animation = new QGraphicsItemAnimation;
  this.animation.setItem(this.graphicsItem); // CRASHES HERE ON 4.6 !!
  this.animation.setTimeLine(this.timer);

  var center = new Object();
  center.y = 0;
  center.x = 0;
  var radius = 100;
  var step = 360/10;
  for(var i = 0; i < 360; i+=step) {
    this.animation.setPosAt(i/360.0, 
      new QPointF(
        center.x - (radius * Math.cos(i * Math.PI/180)), 
        center.y + (radius * Math.sin(i * Math.PI/180))
      )
    );
  }
  this.animation.setPosAt(1,this.animation.posAt(0));

  this.animation.setRotationAt(0.5, 180);
  this.animation.setRotationAt(1, 360);

  var layout = new QGridLayout();
  layout.addWidget(this.view, 0,0);
  this.setLayout(layout);

  this.resize(400,400);

  // Start the animation
  this.timer.start();
}

QtAnimationExperiments.prototype = new QWidget();

var wdgt = new QtAnimationExperiments();
wdgt.show();

QCoreApplication.exec();

Original issue reported on code.google.com by arto.sal...@gmail.com on 18 Jan 2010 at 11:00

Attachments:

GoogleCodeExporter commented 8 years ago
I can reproduce the crash on Windows with 4.6.
However, it doesn't crash in the generated bindings, but rather 
inside Qt itself:

ASSERT: "w->testAttribute(Qt::WA_WState_Created)" in file 
inputmethod\qwininputcontext_win.cpp, line 377

I suggest converting the example code to C++, try to boil it down to the 
smallest snippet that reproduces the issue, and then file a bugreport at 
http://bugreports.qt.nokia.com

Original comment by kentm...@gmail.com on 24 Mar 2010 at 9:48