[Python-modules-commits] [python-qtawesome] 02/09: Import python-qtawesome_0.4.4+ds1.orig.tar.gz
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Wed Apr 5 17:38:07 UTC 2017
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch master
in repository python-qtawesome.
commit 1852c97f07a08c89330741387f9ea36dee74a8bf
Author: Ghislain Antony Vaillant <ghisvail at gmail.com>
Date: Thu Mar 16 12:48:44 2017 +0000
Import python-qtawesome_0.4.4+ds1.orig.tar.gz
---
CHANGELOG.md | 14 ++++++
MANIFEST.in | 1 +
PKG-INFO | 2 +-
QtAwesome.egg-info/PKG-INFO | 2 +-
QtAwesome.egg-info/SOURCES.txt | 4 +-
qtawesome/_version.py | 2 +-
qtawesome/iconic_font.py | 92 ++++++++++++++++++++++-----------------
qtawesome/tests/test_qtawesome.py | 16 +++++++
8 files changed, 88 insertions(+), 45 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 198a9ae..1fd70dc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,19 @@
# History of changes
+## Version 0.4.4 (2017-01-28)
+
+### Bugs fixed
+
+**Pull requests**
+
+* [PR 70](https://github.com/spyder-ide/qtawesome/pull/70) - PR: Prevent segfaults when importing QtAwesome out of a of QApplication
+
+In this release 1 pull request was merged
+
+
+----
+
+
## Version 0.4.3 (2017-01-22)
### Bugs fixed
diff --git a/MANIFEST.in b/MANIFEST.in
index 2d9cf15..b925af1 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -3,3 +3,4 @@ recursive-include docs *
exclude docs/*.yml
include CHANGELOG.md LICENSE README.md
include example.py
+recursive-include qtawesome/tests *
diff --git a/PKG-INFO b/PKG-INFO
index 0e03e26..3c7e1bd 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: QtAwesome
-Version: 0.4.3
+Version: 0.4.4
Summary: FontAwesome icons in PyQt and PySide applications
Home-page: https://github.com/spyder-ide/qtawesome
Author: Sylvain Corlay
diff --git a/QtAwesome.egg-info/PKG-INFO b/QtAwesome.egg-info/PKG-INFO
index 0e03e26..3c7e1bd 100644
--- a/QtAwesome.egg-info/PKG-INFO
+++ b/QtAwesome.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: QtAwesome
-Version: 0.4.3
+Version: 0.4.4
Summary: FontAwesome icons in PyQt and PySide applications
Home-page: https://github.com/spyder-ide/qtawesome
Author: Sylvain Corlay
diff --git a/QtAwesome.egg-info/SOURCES.txt b/QtAwesome.egg-info/SOURCES.txt
index 397b88a..4e9c612 100644
--- a/QtAwesome.egg-info/SOURCES.txt
+++ b/QtAwesome.egg-info/SOURCES.txt
@@ -24,4 +24,6 @@ qtawesome/iconic_font.py
qtawesome/fonts/elusiveicons-webfont-charmap.json
qtawesome/fonts/elusiveicons-webfont.ttf
qtawesome/fonts/fontawesome-webfont-charmap.json
-qtawesome/fonts/fontawesome-webfont.ttf
\ No newline at end of file
+qtawesome/fonts/fontawesome-webfont.ttf
+qtawesome/tests/test_qtawesome.py
+qtawesome/tests/__pycache__/test_qtawesome.cpython-35-PYTEST.pyc
\ No newline at end of file
diff --git a/qtawesome/_version.py b/qtawesome/_version.py
index a8422cc..0b2f76c 100644
--- a/qtawesome/_version.py
+++ b/qtawesome/_version.py
@@ -1,2 +1,2 @@
-version_info = (0, 4, 3)
+version_info = (0, 4, 4)
__version__ = '.'.join(map(str, version_info))
diff --git a/qtawesome/iconic_font.py b/qtawesome/iconic_font.py
index 597bd59..af67000 100644
--- a/qtawesome/iconic_font.py
+++ b/qtawesome/iconic_font.py
@@ -18,11 +18,13 @@ from __future__ import print_function
import json
import os
import hashlib
+import warnings
# Third party imports
from qtpy.QtCore import QObject, QPoint, QRect, qRound, Qt
from qtpy.QtGui import (QColor, QFont, QFontDatabase, QIcon, QIconEngine,
QPainter, QPixmap)
+from qtpy.QtWidgets import QApplication
from six import unichr
@@ -205,38 +207,41 @@ class IconicFont(QObject):
os.path.dirname(os.path.realpath(__file__)), 'fonts')
# Load font
- id_ = QFontDatabase.addApplicationFont(os.path.join(directory,
- ttf_filename))
- loadedFontFamilies = QFontDatabase.applicationFontFamilies(id_)
- if(loadedFontFamilies):
- self.fontname[prefix] = loadedFontFamilies[0]
- else:
- raise FontError(u"Font at '{0}' appears to be empty. "
- "If you are on Windows 10, please read "
- "https://support.microsoft.com/en-us/kb/3053676 "
- "to know how to prevent Windows from blocking "
- "the fonts that come with QtAwesome.".format(
- os.path.join(directory, ttf_filename)))
-
- with open(os.path.join(directory, charmap_filename), 'r') as codes:
- self.charmap[prefix] = json.load(codes, object_hook=hook)
-
- # Verify that vendorized fonts are not corrupt
- if not SYSTEM_FONTS:
- md5_hashes = {'fontawesome-webfont.ttf':
- 'a3de2170e4e9df77161ea5d3f31b2668',
- 'elusiveicons-webfont.ttf':
- '207966b04c032d5b873fd595a211582e'}
- ttf_hash = md5_hashes.get(ttf_filename, None)
- if ttf_hash is not None:
- hasher = hashlib.md5()
- with open(os.path.join(directory, ttf_filename), 'rb') as f:
- content = f.read()
- hasher.update(content)
- ttf_calculated_hash_code = hasher.hexdigest()
- if ttf_calculated_hash_code != ttf_hash:
- raise FontError(u"Font is corrupt at: '{0}'".format(
- os.path.join(directory, ttf_filename)))
+ if QApplication.instance() is not None:
+ id_ = QFontDatabase.addApplicationFont(os.path.join(directory,
+ ttf_filename))
+ loadedFontFamilies = QFontDatabase.applicationFontFamilies(id_)
+ if(loadedFontFamilies):
+ self.fontname[prefix] = loadedFontFamilies[0]
+ else:
+ raise FontError(u"Font at '{0}' appears to be empty. "
+ "If you are on Windows 10, please read "
+ "https://support.microsoft.com/"
+ "en-us/kb/3053676 "
+ "to know how to prevent Windows from blocking "
+ "the fonts that come with QtAwesome.".format(
+ os.path.join(directory, ttf_filename)))
+
+ with open(os.path.join(directory, charmap_filename), 'r') as codes:
+ self.charmap[prefix] = json.load(codes, object_hook=hook)
+
+ # Verify that vendorized fonts are not corrupt
+ if not SYSTEM_FONTS:
+ md5_hashes = {'fontawesome-webfont.ttf':
+ 'a3de2170e4e9df77161ea5d3f31b2668',
+ 'elusiveicons-webfont.ttf':
+ '207966b04c032d5b873fd595a211582e'}
+ ttf_hash = md5_hashes.get(ttf_filename, None)
+ if ttf_hash is not None:
+ hasher = hashlib.md5()
+ with open(os.path.join(directory, ttf_filename),
+ 'rb') as f:
+ content = f.read()
+ hasher.update(content)
+ ttf_calculated_hash_code = hasher.hexdigest()
+ if ttf_calculated_hash_code != ttf_hash:
+ raise FontError(u"Font is corrupt at: '{0}'".format(
+ os.path.join(directory, ttf_filename)))
def icon(self, *names, **kwargs):
"""Return a QIcon object corresponding to the provided icon name."""
@@ -247,17 +252,22 @@ class IconicFont(QObject):
error = '"options" must be a list of size {0}'.format(len(names))
raise Exception(error)
- parsed_options = []
- for i in range(len(options_list)):
- specific_options = options_list[i]
- parsed_options.append(self._parse_options(specific_options,
- general_options,
- names[i]))
+ if QApplication.instance() is not None:
+ parsed_options = []
+ for i in range(len(options_list)):
+ specific_options = options_list[i]
+ parsed_options.append(self._parse_options(specific_options,
+ general_options,
+ names[i]))
- # Process high level API
- api_options = parsed_options
+ # Process high level API
+ api_options = parsed_options
- return self._icon_by_painter(self.painter, api_options)
+ return self._icon_by_painter(self.painter, api_options)
+ else:
+ warnings.warn("You need to have a running "
+ "QApplication to use QtAwesome!")
+ return QIcon()
def _parse_options(self, specific_options, general_options, name):
options = dict(_default_options, **general_options)
diff --git a/qtawesome/tests/test_qtawesome.py b/qtawesome/tests/test_qtawesome.py
new file mode 100644
index 0000000..130921a
--- /dev/null
+++ b/qtawesome/tests/test_qtawesome.py
@@ -0,0 +1,16 @@
+r"""
+Tests for QtAwesome.
+"""
+# Standard library imports
+import subprocess
+
+# Test Library imports
+import pytest
+
+def test_segfault_import():
+ output_number = subprocess.call('python -c "import qtawesome '
+ '; qtawesome.icon()"', shell=True)
+ assert output_number == 0
+
+if __name__ == "__main__":
+ pytest.main()
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-qtawesome.git
More information about the Python-modules-commits
mailing list