After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 161040 - dia: the grid is destroyed when drawing an object at zoom level
dia: the grid is destroyed when drawing an object at zoom level
Status: RESOLVED FIXED
Product: dia
Classification: Other
Component: general
0.94
Other Linux
: Normal normal
: ---
Assigned To: Dia maintainers
Dia maintainers
Depends on:
Blocks:
 
 
Reported: 2004-12-11 20:08 UTC by Roland Stigge
Modified: 2005-10-08 20:24 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to fix grid drawing when update rectangle has negative coordinates (458 bytes, patch)
2004-12-17 21:26 UTC, Laurence Withers
committed Details | Review

Description Roland Stigge 2004-12-11 20:08:48 UTC
A Debian user reported the following:

=================================================================================
The grid goes fubar when drawing objects, some part of the grid get shifted
on the left/right/top/bottom depending on the moment.

To reproduce, launch dia, leave all default settings, zoom at 400% then draw
a simple line. Leave the button pressed and watch the grid shift near the
start of your line. Drag the mouse around, and the grid will shift under your
mouse.
=================================================================================

See also http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=284329
(there's also an example screenshot)
Comment 1 Hans Breuer 2004-12-11 20:45:50 UTC
I'd say 'extremly annoying' is quite strong wording for a cosmetical issue, but
noticed this myself - and plan to eventually fix it (pathes accepted;)
BTW: is it for sure this is with dia-0.94 or does only HEAD does 
have the problem?
Comment 2 Roland Stigge 2004-12-11 21:11:43 UTC
That's why I didn't quote the "extremely annoying". :)

I only checked with 0.94.
Comment 3 Laurence Withers 2004-12-17 21:26:55 UTC
Created attachment 34948 [details] [review]
Patch to fix grid drawing when update rectangle has negative coordinates

I believe this patch should fix the issue. The problem arises because of the
behaviour of C's % operator when presented with a negative numerator. This of
course happens fairly regularly (whenever the update rectangle has a negative
coordinate). The fix is simply to make the number positive in such a way that
it does not affect the modulo calculation.

Apparently, C99 better specifies the behaviour of the % operator under these
circumstances, but that was just from a random Google hit rather than any real
research on my part.

The patch is against 0.94, app/grid.c . It's trivial enough that if it doesn't
apply to CVS head you can just merge in the code by hand.
Comment 4 Lars Clausen 2005-02-14 14:33:28 UTC
Adding PATCH keyword
Comment 5 Roland Stigge 2005-02-14 21:25:05 UTC
I wonder what the major_lines factor is good for.
Comment 6 Lars Clausen 2005-02-15 13:25:07 UTC
That's to say how far apart the "thicker" grid lines are, in terms of number of
grid lines.
Comment 7 Roland Stigge 2005-02-15 17:37:08 UTC
Of course, but why is it used as a factor in the case of negative major_count?
Comment 8 Lars Clausen 2005-02-17 15:59:09 UTC
In the patch?  A very good question.
Comment 9 Laurence Withers 2005-02-17 17:28:58 UTC
Think about it in terms of the maths and the modulo arithmetic; we have a 
number P such that P < 0, and we want to find a number Q such that Q >= 0, but 
(P % major_count) == (Q % major_count). To do this, we say Q = P - (P * 
major_count), which is guaranteed to give a correct answer if major_count > 0 
(since the addition of anf multiple of major_count won't alter the modulo). 
Comment 10 Roland Stigge 2005-02-17 17:51:49 UTC
Thanks, sounds reasonable. :) Maybe these lines should be added as comments into
the code (and a possibly a note why we do it).
Comment 11 Lars Clausen 2005-03-06 09:12:50 UTC
Thank you for an insightful patch.  It has been applied to CVS and the
explanation added as a comment.
Comment 12 Hans Breuer 2005-10-08 20:24:00 UTC
Adjusting target to help finding 0.94 dups already fixed