qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.51k stars 2.99k forks source link

QGIS crashes when the symbol sub-panel is open and the project is being closed by another project opening #40497

Closed nirvn closed 3 years ago

nirvn commented 3 years ago

Describe the bug When closing a project (due to loading another project) while the symbol sub-panel of the graduated renderer is open, QGIS crashes.

How to Reproduce

  1. Open the test project attached here: prisons.zip
  2. Open the style panel, select the prisons layer, and open the symbol sub-panel by clicking on the graduated renderer's symbol button
  3. Without closing the sub-panel, reload the test project by going to Project -> Open Recent -> prisons[.qgz]
  4. boom QGIS dies

QGIS and OS versions

QGIS master on Ubuntu 20.20.

nirvn commented 3 years ago

Trace:

Thread 1 "qgis" received signal SIGSEGV, Segmentation fault.
std::__atomic_base<int>::load (__m=std::memory_order_relaxed, this=0x0) at /usr/include/c++/10/bits/atomic_base.h:426
426     return __atomic_load_n(&_M_i, int(__m));
(gdb) where
#0  std::__atomic_base<int>::load(std::memory_order) const (__m=std::memory_order_relaxed, this=0x0) at /usr/include/c++/10/bits/atomic_base.h:426
#1  QAtomicOps<int>::loadRelaxed<int>(std::atomic<int> const&) (_q_value=...) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qatomic_cxx11.h:239
#2  0x00007ffff240adfe in QBasicAtomicInteger<int>::loadRelaxed() const (this=0x0) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qbasicatomic.h:107
#3  0x00007ffff2403c86 in QtPrivate::RefCount::ref() (this=0x0) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qrefcount.h:55
#4  0x00007ffff2615908 in QList<QgsSymbolLayer*>::QList(QList<QgsSymbolLayer*> const&) (this=0x7fffffffb400, l=...)
    at /usr/include/x86_64-linux-gnu/qt5/QtCore/qlist.h:839
#5  0x00007ffff26219d5 in QgsSymbol::hasDataDefinedProperties() const (this=0x555558f61500)
    at /home/webmaster/dev/cpp/QGIS/src/core/symbology/qgssymbol.cpp:797
#6  0x00007ffff25f1a44 in QgsSymbolLayerUtils::symbolPreviewPixmap(QgsSymbol const*, QSize, int, QgsRenderContext*, bool, QgsExpressionContext const*, QgsLegendPatchShape const*) (symbol=0x555558f61500, size=..., padding=0, customContext=0x0, selected=false, expressionContext=0x0, shape=0x0)
    at /home/webmaster/dev/cpp/QGIS/src/core/symbology/qgssymbollayerutils.cpp:794
#7  0x00007ffff25f17f9 in QgsSymbolLayerUtils::symbolPreviewIcon(QgsSymbol const*, QSize, int, QgsLegendPatchShape*)
    (symbol=0x555558f61500, size=..., padding=0, shape=0x0) at /home/webmaster/dev/cpp/QGIS/src/core/symbology/qgssymbollayerutils.cpp:764
#8  0x00007ffff5fa17ed in SymbolLayerItem::updatePreview() (this=0x555559bb1e30)
    at /home/webmaster/dev/cpp/QGIS/src/gui/symbology/qgssymbolselectordialog.cpp:162
#9  0x00007ffff5fa16e6 in SymbolLayerItem::setSymbol(QgsSymbol*) (this=0x555559bb1e30, symbol=0x555558f61500)
    at /home/webmaster/dev/cpp/QGIS/src/gui/symbology/qgssymbolselectordialog.cpp:148
#10 0x00007ffff5fa163c in SymbolLayerItem::SymbolLayerItem(QgsSymbol*) (this=0x555559bb1e30, symbol=0x555558f61500)
    at /home/webmaster/dev/cpp/QGIS/src/gui/symbology/qgssymbolselectordialog.cpp:132
#11 0x00007ffff5f9c755 in QgsSymbolSelectorWidget::loadSymbol(QgsSymbol*, SymbolLayerItem*) (this=
    0x555558ef64b0, symbol=0x555558f61500, parent=0x55555c2a0c00) at /home/webmaster/dev/cpp/QGIS/src/gui/symbology/qgssymbolselectordialog.cpp:398
#12 0x00007ffff5f9c9b1 in QgsSymbolSelectorWidget::reloadSymbol() (this=0x555558ef64b0)
    at /home/webmaster/dev/cpp/QGIS/src/gui/symbology/qgssymbolselectordialog.cpp:423
#13 0x00007ffff5f9d56c in QgsSymbolSelectorWidget::symbolChanged() (this=0x555558ef64b0)
    at /home/webmaster/dev/cpp/QGIS/src/gui/symbology/qgssymbolselectordialog.cpp:562
#14 0x00007ffff5f9b2cb in operator()() const (__closure=0x55555c48e7d0) at /home/webmaster/dev/cpp/QGIS/src/gui/symbology/qgssymbolselectordialog.cpp:338
#15 0x00007ffff5f9f3f4 in QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, QgsSymbolSelectorWidget::QgsSymbolSelectorWidget(QgsSymbol*, QgsStyle*, QgsVectorLayer*, QWidget*)::<lambda()> >::call(struct {...} &, void **) (f=..., arg=0x7fffffffb970)
    at /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:146
#16 0x00007ffff5f9f316 in QtPrivate::Functor<QgsSymbolSelectorWidget::QgsSymbolSelectorWidget(QgsSymbol*, QgsStyle*, QgsVectorLayer*, QWidget*)::<lambda()>, 0>::call<QtPrivate::List<>, void>(struct {...} &, void *, void **) (f=..., arg=0x7fffffffb970)
    at /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:256
#17 0x00007ffff5f9f291 in QtPrivate::QFunctorSlotObject<QgsSymbolSelectorWidget::QgsSymbolSelectorWidget(QgsSymbol*, QgsStyle*, QgsVectorLayer*, QWidget*)::<lambda()>, 0, QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase *, QObject *, void **, bool *)
    (which=1, this_=0x55555c48e7c0, r=0x555558ef64b0, a=0x7fffffffb970, ret=0x0) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:443
#18 0x00007ffff45bf2e6 in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#19 0x00007ffff23f1923 in QgsProject::projectColorsChanged() (this=0x555555dbf180)
    at /home/webmaster/dev/cpp/bm-qt5/src/core/qgis_core_autogen/EWIEGA46WW/moc_qgsproject.cpp:1133
#20 0x00007ffff2d2dd02 in QgsProject::clear() (this=0x555555dbf180) at /home/webmaster/dev/cpp/QGIS/src/core/qgsproject.cpp:837
nirvn commented 3 years ago

@nyalldawson , this is a regression caused by the introduction of the QgsProject::projectColorsChanged() signal, which triggers the cascade of functions leading to the crash.

nyalldawson commented 3 years ago

There was a related fix for the classified renderer a few cycles back -- I can't recall it off hand, but you could trawl through the merged prs and find the commit to apply here..

nirvn commented 3 years ago

@nyalldawson , I just tested with classified, it also crashes.

nirvn commented 3 years ago

@nyalldawson , better steps to reproduce

  1. Load the above project
  2. Close the project via Project -> Close menu item
  3. Re-open the project (via Project -> Recent -> prisons.qgz)
  4. boom