Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash using QgsComposerAttributeTableV2 after setting columns #25080

Closed
qgib opened this issue Sep 21, 2017 · 6 comments
Closed

Crash using QgsComposerAttributeTableV2 after setting columns #25080

qgib opened this issue Sep 21, 2017 · 6 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Crash/Data Corruption PyQGIS Related to the PyQGIS API

Comments

@qgib
Copy link
Contributor

qgib commented Sep 21, 2017

Author Name: Loïc BARTOLETTI (@lbartoletti)
Original Redmine Issue: 17181
Affected QGIS version: 2.18.13
Redmine category:python_bindings_/_sipify


QGis crash when you use this code into the console (with a real project):

@table = QgsComposerAttributeTableV2(iface.activeComposers()[0].composition(), False)
cols = table.columns()
newCol = QgsComposerTableColumn("test_for_crash")
newCol.setAttribute("$id")
cols.append(newCol)
table.setColumns(cols)
[i.heading() for i in table.columns()]@

Tested on Windows 7 QGis 2.18, Debian QGis 2.14 and FreeBSD 2.18.

Seems to be a bad_alloc. Here some logs from Debian:

Warning: QObject::connect: Cannot connect (null)::layerModified() to QgsComposerAttributeTableV2::refreshAttributes()
Segmentation fault

FreeBSD show a windows with this error:

cxxrt::bad_alloc


Related issue(s): #25079 (relates)
Redmine related issue(s): 17180


@qgib
Copy link
Contributor Author

qgib commented Sep 22, 2017

Author Name: Giovanni Manghi (@gioman)


Is this related to #25079 ?


  • status_id was changed from Open to Feedback

@qgib
Copy link
Contributor Author

qgib commented Sep 22, 2017

Author Name: Loïc BARTOLETTI (@lbartoletti)


No, they're different issues.
I'm working on several projects needing to use the composer and found these two bugs.

@qgib
Copy link
Contributor Author

qgib commented Sep 22, 2017

Author Name: Giovanni Manghi (@gioman)


Loïc BARTOLETTI wrote:

No, they're different issues.
I'm working on several projects needing to use the composer and found these two bugs.

thanks, so please add a description to #25079 just not leave the link to stackexchange, thanks.


  • status_id was changed from Feedback to Open

@qgib
Copy link
Contributor Author

qgib commented Sep 28, 2017

Author Name: Jürgen Fischer (@jef-n)


@qgib
Copy link
Contributor Author

qgib commented Sep 28, 2017

Author Name: Denis Rouzaud (@3nids)


  • assigned_to_id removed Denis Rouzaud

@qgib
Copy link
Contributor Author

qgib commented Sep 28, 2017

Author Name: Nyall Dawson (@nyalldawson)


Your code is a bit wrong:

cols = table.columns()
...
cols.append(newCol)
table.setColumns(cols)

table.columns() is returning a pointer to the table's columns, so any edits (such as appending columns) happens immediately. There's no need to call table.setColumns() after. This is causing the crash, because the table already has ownership of that columns object.

Admittedly, not the nicest api!


  • resolution was changed from to invalid
  • status_id was changed from Open to Closed

@qgib qgib closed this as completed Sep 28, 2017
@qgib qgib added Bug Either a bug report, or a bug fix. Let's hope for the latter! PyQGIS Related to the PyQGIS API Crash/Data Corruption labels May 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Crash/Data Corruption PyQGIS Related to the PyQGIS API
Projects
None yet
Development

No branches or pull requests

1 participant