Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Workaround bug with some versions of Qt, when the two pairs of
authorArnaud Giersch <arnaud.giersch@free.fr>
Sun, 10 Nov 2013 17:30:10 +0000 (18:30 +0100)
committerArnaud Giersch <arnaud.giersch@free.fr>
Sun, 10 Nov 2013 17:30:10 +0000 (18:30 +0100)
coordinates are the same for drawLine or drawRect.

CHANGES
COPYRIGHT
DrawingWindow.cpp

diff --git a/CHANGES b/CHANGES
index 2944576..7177072 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,27 +1,33 @@
--- ven., 03 déc. 2010 09:34:15 +0100
+-- dim. 10 nov. 2013 18:26:00 +0100
+
+        * Contournement d'un bug avec certaines versions de Qt,
+          lorsque les deux paires de coordonnées sont égales pour
+          drawLine ou drawRect.
+
+-- ven. 03 déc. 2010 09:34:15 +0100
 
         * Ajout des méthodes setAntialiasing et setPenWidth.
           Merci à Yoann Blein pour sa suggestion.
 
--- mer., 01 déc. 2010 12:11:36 +0100
+-- mer. 01 déc. 2010 12:11:36 +0100
 
         * Autorise un paramètre de type std::string pour drawText et drawTextBg.
 
--- lun., 22 nov. 2010 21:27:00 +0100
+-- lun. 22 nov. 2010 21:27:00 +0100
 
         * Ajout des méthodes drawTriangle et fillTriangle.
         * Ajout des méthodes getFont et setFont.
         * Indique que les chaînes sont encodées en UTF8 pour drawText.
 
--- mar., 27 avr. 2010 17:30:13 +0200
+-- mar. 27 avr. 2010 17:30:13 +0200
 
         * Rend les méthodes *sleep statiques.
         * Recodé en UTF8.
 
--- mer., 20 jan. 2010 19:20:49 +0100
+-- mer. 20 jan. 2010 19:20:49 +0100
 
         * Ajout des méthodes waitMousePress et mousePressEvent.
 
--- mar., 27 nov. 2007 09:31:18 +0100
+-- mar. 27 nov. 2007 09:31:18 +0100
 
         * Version initiale.
index a210510..0329744 100644 (file)
--- a/COPYRIGHT
+++ b/COPYRIGHT
@@ -1,4 +1,4 @@
-Copyright (c) 2007-2010, Arnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
+Copyright (c) 2007-2013, Arnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
index ad74339..1ab14ee 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007-2010, Arnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
+ * Copyright (c) 2007-2013, Arnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -37,7 +37,7 @@
  *  \brief Fenêtre de dessin.
  *
  * \author Arnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
- * \date 2007-2010
+ * \date 2007-2013
  *
  * Cette classe décrit un widget Qt permettant d'écrire des
  * applications graphiques simples.  Pour cela, il faut définir une
@@ -433,10 +433,14 @@ void DrawingWindow::drawPoint(int x, int y)
  */
 void DrawingWindow::drawLine(int x1, int y1, int x2, int y2)
 {
-    safeLock(imageMutex);
-    painter->drawLine(x1, y1, x2, y2);
-    dirty(x1, y1, x2, y2);
-    safeUnlock(imageMutex);
+    if (x1 == x2 && y1 == y2) {
+        drawPoint(x1, y1);
+    } else {
+        safeLock(imageMutex);
+        painter->drawLine(x1, y1, x2, y2);
+        dirty(x1, y1, x2, y2);
+        safeUnlock(imageMutex);
+    }
 }
 
 //! Dessine un rectangle.
@@ -452,14 +456,18 @@ void DrawingWindow::drawLine(int x1, int y1, int x2, int y2)
  */
 void DrawingWindow::drawRect(int x1, int y1, int x2, int y2)
 {
-    QRect r;
-    r.setCoords(x1, y1, x2 - 1, y2 - 1);
-    r = r.normalized();
-    safeLock(imageMutex);
-    painter->drawRect(r);
-    r.adjust(0, 0, 1, 1);
-    dirty(r);
-    safeUnlock(imageMutex);
+    if (x1 == x2 && y1 == y2) {
+        drawPoint(x1, y1);
+    } else {
+        QRect r;
+        r.setCoords(x1, y1, x2 - 1, y2 - 1);
+        r = r.normalized();
+        safeLock(imageMutex);
+        painter->drawRect(r);
+        r.adjust(0, 0, 1, 1);
+        dirty(r);
+        safeUnlock(imageMutex);
+    }
 }
 
 //! Dessine un rectangle plein.