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

PR: Prevent segfaults when importing QtAwesome out of a of QApplication #70

Merged
merged 7 commits into from
Jan 28, 2017

Conversation

dalthviz
Copy link
Member

@dalthviz dalthviz commented Jan 25, 2017

@dalthviz dalthviz self-assigned this Jan 25, 2017
@dalthviz dalthviz requested a review from goanpeca January 25, 2017 22:34

return self._icon_by_painter(self.painter, api_options)
return self._icon_by_painter(self.painter, api_options)
Copy link
Member

@goanpeca goanpeca Jan 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the else should return an empty QIcon plus some warning?

else:
   warning.warn('You need to have a running QApplication to use QtAwesome!')
   return QIcon()

@SylvainCorlay ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think adding the warning is fine ;-)

@goanpeca
Copy link
Member

goanpeca commented Jan 25, 2017

@dalthviz could we create a test that does the direct import (Like what @jitseniesen pointed out).

Just create a new tests folder inside the main module, ok?

import pytest

def test_segfault_import():
subprocess.call('python -c qtawesome')
Copy link
Member

@ccordoba12 ccordoba12 Jan 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change this to

output_number = subprocess.call('python -c qtawesome')
assert output_number == 0

Remember that you always have to assert something on tests :-)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we try to import every file in the submodule also?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The most important import's for QtAwesome are on its __init__.py, so I don't see the need for that.

@@ -0,0 +1,14 @@
r"""
Tests for QtAwesome
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dot at the end of a docstring (it is a sentence)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have to be too strict about style on test files, but sure, why not :-)

@ccordoba12 ccordoba12 added this to the v0.4.4 milestone Jan 27, 2017
@ccordoba12 ccordoba12 changed the title PR: Add validation to check the existence of a QApplication instance PR: Prevent segfaults when importing QtAwesome out of a of QApplication Jan 27, 2017
@ccordoba12
Copy link
Member

@ghisvail, this is kind of important in case you want to pick it up for Debian.

@ccordoba12
Copy link
Member

@dalthviz, please also add the new tests folder to MANIFEST.in, like we do it in qtpy:

https://github.com/spyder-ide/qtpy/blob/master/MANIFEST.in#L5

That's necessary to add our tests to our released packages too, which was requested by @ghisvail for Debian.

@goanpeca
Copy link
Member

Then can we also update the CI code to run the test?

https://github.com/spyder-ide/qtawesome/blob/master/appveyor.yml#L60
- "%CMD_IN_ENV% py.test qtawesome"

https://github.com/spyder-ide/qtawesome/blob/master/circle.yml

    - export PATH="$HOME/miniconda/bin:$PATH" && source activate test && py.test qtawesome: # note the colon
        parallel: true

@ccordoba12
Copy link
Member

Ok, sure. All of that have to be part of this PR.

@dalthviz, sorry for putting you more work ;-)

@ghisvail
Copy link
Contributor

I can cherry-pick this, but have to wait for the last upload of qtawesome-0.4.3 to transition with the rest of the stack, i.e. qtpy-1.2.1 and spyder-3.1.2. Otherwise, none of them will make it for the freeze.

@ccordoba12
Copy link
Member

@dalthviz, I know why our tests are failing. I'll help you to fix them :-)

@ccordoba12
Copy link
Member

Ok, I think this one is ready! Thanks @dalthviz for your hard work to solve this nasty problem :-)

@ccordoba12 ccordoba12 merged commit d7d7238 into spyder-ide:master Jan 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants