Author: cazfi
Date: Tue Nov 22 06:44:17 2016
New Revision: 34606

URL: http://svn.gna.org/viewcvs/freeciv?rev=34606&view=rev
Log:
Fixed clang alignment warning from Qt-client zealous_crop_rect()

See bug #25315

Modified:
    trunk/client/gui-qt/canvas.cpp

Modified: trunk/client/gui-qt/canvas.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/canvas.cpp?rev=34606&r1=34605&r2=34606&view=diff
==============================================================================
--- trunk/client/gui-qt/canvas.cpp      (original)
+++ trunk/client/gui-qt/canvas.cpp      Tue Nov 22 06:44:17 2016
@@ -355,17 +355,24 @@
 QRect zealous_crop_rect(QImage &p)
 {
   int r, t, b, l;
-
-  l = p.width();
+  int oh, ow;
+
+  ow = p.width();
+  l = ow;
   r = 0;
-  t = p.height();
+  oh = p.height();
+  t = oh;
   b = 0;
-  for (int y = 0; y < p.height(); ++y) {
-    QRgb *row = (QRgb *)p.scanLine(y);
+  for (int y = 0; y < oh; y++) {
+    QRgb row[ow];
     bool row_filled = false;
     int x;
 
-    for (x = 0; x < p.width(); ++x) {
+    /* Copy to a location with guaranteed QRgb suitable alignment.
+     * That fixes clang compiler warning. */
+    memcpy(row, p.scanLine(y), ow * sizeof(QRgb));
+
+    for (x = 0; x < ow; ++x) {
       if (qAlpha(row[x])) {
         row_filled = true;
         r = qMax(r, x);


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to