Qt 6.9.0 GraphicScene scrollbars give wrong value ( nan or inf )
-
Hello,
The problem occurs with Qt 6.9.0 on Mac Intel and silicon but not with Linux.
I joined a QGraphicsView with a QGraphicsScene . I initialize
g_scene..setSceneRect( 0,0,0,0 );
and then plot a lot of points ( in ex 300 ) :QGraphicsTextItem * pt
pt->setPos( x, y )
gscene.addItem( pt );If many plots in a normal range are inserted the scrollbars is stucked because the coord of de scene give qreal that are inf nan.
to test I do this :
QRectF R = g_scene.sceneRect();
and I obseved that the values in R were not a number or infinite. No real values.It happens when many graphiics are inserted . And these wrong real values do not appear with Qt 6.8.0 on Mac and do not appear with Qt 6.9.0 on Linux
When a certain amount of items are inserted the coordinates of the graphic turns to give wrong real values lile not a number or infinite.
I suspect a bug.
-
g_scene..setSceneRect( 0,0,0,0 );
(preserved your typo)
You have told the scene that it has zero width and height (and set the view's default scrolling area also). I do not find it surprising that the view has issues scrolling a zero-size area .
Perhaps you meant to set a null QRectF:
g_scene.setSceneRect(QRectF());
-
No it's not a problem setting to zero gives extended size . That does not make any change as I've just tested. The wrong real values appears affter inserting smalll text items.
If i posted it's because this misbehaviour appears only with Qt 6.9.0 on Mac not on Linux . I did not test on Windiows. Qt 6.8.0 was right on Mac.
I discovered the bug with
int is_nan( qreal a ) { return ( boost::math::isinf(a) || boost::math::isnan(a) ) ; }
Some more updated information if I compile a debug version the bug does not appear but with some optimization
- QMAKE_CXXFLAGS += -std=c++17 -O3 -ffast-math -flto -funroll-loops -march=native -DNDEBUG
goes wrong
- QMAKE_CXXFLAGS += -std=c++17 -Og
goes well
Regards
-
last minute . I found the right way.
In fact it is the -ffast-math compiler option which beheave differently on Mac and Linux with Qt 6.9.0Qt 6.9.0 does not support any more very fast compiler optiion
on Mac MxCFLAGS = -pipe -Ofast $(EXPORT_ARCH_ARGS) -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=15.0 -Wall -Wextra $(DEFINES) CXXFLAGS = -pipe -stdlib=libc++ -std=c++17 -Ofast -funroll-loops -flto -march=native -DNDEBUG -Ofast -std=gnu++1z $(EXPORT_ARCH_ARGS) -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=15.0 -Wall -Wextra $(DEFINES)
Fast optimisation does not work any more on 6.9.0. Is it Qt or Apple difficult to say.
Thank you anyway .