aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qtsupport/screenshotcropper.cpp
diff options
context:
space:
mode:
authorAlessandro Portale <alessandro.portale@nokia.com>2012-03-27 16:37:33 +0200
committerFriedemann Kleint <Friedemann.Kleint@nokia.com>2012-03-27 16:41:08 +0200
commit1da95bc12900dc90793cb06d9166dd0a815f5c69 (patch)
tree5f980dfef4c9aa3862c19c42b7f4d3708b9a0ca4 /src/plugins/qtsupport/screenshotcropper.cpp
parenta3d244e9706ae9534abbb17f1e4a38e9a0c6909d (diff)
Remove usages of Q_GLOBAL_STATIC_WITH_INITIALIZER in Qt Creator
Q_GLOBAL_STATIC_WITH_INITIALIZER will be removed in Qt5, since it interferes with multi threading. Change-Id: I2013091ecb0613a168cd77f56ac88edb3b97fe1d Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Diffstat (limited to 'src/plugins/qtsupport/screenshotcropper.cpp')
-rw-r--r--src/plugins/qtsupport/screenshotcropper.cpp25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/plugins/qtsupport/screenshotcropper.cpp b/src/plugins/qtsupport/screenshotcropper.cpp
index 0209cbc370b..59d1585e9b5 100644
--- a/src/plugins/qtsupport/screenshotcropper.cpp
+++ b/src/plugins/qtsupport/screenshotcropper.cpp
@@ -43,13 +43,20 @@
namespace QtSupport {
namespace Internal {
+class AreasOfInterest {
+public:
+ AreasOfInterest();
+ QMap<QString, QRect> areas;
+};
+
+AreasOfInterest::AreasOfInterest()
+{
#ifdef QT_CREATOR
-Q_GLOBAL_STATIC_WITH_INITIALIZER(AreasOfInterest, areasOfInterest, {
- *x = ScreenshotCropper::loadAreasOfInterest(Core::ICore::resourcePath() + QLatin1String("/welcomescreen/images_areaofinterest.xml"));
-})
-#else
-Q_GLOBAL_STATIC(AreasOfInterest, areasOfInterest)
+ areas = ScreenshotCropper::loadAreasOfInterest(Core::ICore::resourcePath() + QLatin1String("/welcomescreen/images_areaofinterest.xml"));
#endif // QT_CREATOR
+}
+
+Q_GLOBAL_STATIC(AreasOfInterest, welcomeScreenAreas)
static inline QString fileNameForPath(const QString &path)
{
@@ -81,7 +88,7 @@ static QRect cropRectForAreaOfInterest(const QSize &imageSize, const QSize &crop
QImage ScreenshotCropper::croppedImage(const QImage &sourceImage, const QString &filePath, const QSize &cropSize)
{
- const QRect areaOfInterest = areasOfInterest()->value(fileNameForPath(filePath));
+ const QRect areaOfInterest = welcomeScreenAreas()->areas.value(fileNameForPath(filePath));
if (areaOfInterest.isValid()) {
const QRect cropRect = cropRectForAreaOfInterest(sourceImage.size(), cropSize, areaOfInterest);
@@ -113,9 +120,9 @@ static const QString xmlAttributeY = QLatin1String("y");
static const QString xmlAttributeWidth = QLatin1String("width");
static const QString xmlAttributeHeight = QLatin1String("height");
-AreasOfInterest ScreenshotCropper::loadAreasOfInterest(const QString &areasXmlFile)
+QMap<QString, QRect> ScreenshotCropper::loadAreasOfInterest(const QString &areasXmlFile)
{
- AreasOfInterest areasOfInterest;
+ QMap<QString, QRect> areasOfInterest;
QFile xmlFile(areasXmlFile);
if (!xmlFile.open(QIODevice::ReadOnly)) {
qWarning() << Q_FUNC_INFO << "Could not open file" << areasXmlFile;
@@ -144,7 +151,7 @@ AreasOfInterest ScreenshotCropper::loadAreasOfInterest(const QString &areasXmlFi
return areasOfInterest;
}
-bool ScreenshotCropper::saveAreasOfInterest(const QString &areasXmlFile, AreasOfInterest &areas)
+bool ScreenshotCropper::saveAreasOfInterest(const QString &areasXmlFile, QMap<QString, QRect> &areas)
{
QFile file(areasXmlFile);
if (!file.open(QIODevice::WriteOnly))