shock High priority Sweet Home 3D 6.5A bug was found in Sweet Home 3D

This topic has been viewed 9051 times and has 8 replies
Thread status: Active
Questions about extending features and developing plug-ins [img]http://www.sweethome3d.com/images/flags/en_small.gif[/img]
Post Reply New Topic
User avatar
YGYL
Posts: 157
Joined: Tue Feb 05, 2013 4:00 pm

Sweet Home 3D 6.5A bug was found in Sweet Home 3D

Post by YGYL »

In SweetHome3D.jar inside com\eteks\sweethome3d\model\LengthUnit_zh_CN.properties
Inside should be changed to
centimerUnit=\u5398\u7c73
The original has a few extra letters in front of it

This can lead to errors in area calculation units
Please fix as soon as possible

The full content of the correct LengthUnit_zh_CN.properties
----------------------------------------------
# LengthUnit_zh_CN.properties 16 Mar. 2009
#
# Translated to Chinese (Simplified) by Zhao Si-cong
#
# Sweet Home 3D, Copyright (c) 2008 Emmanuel PUYBARET / eTeks <[email protected]>
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
# Place, Suite 330, Boston, MA 02111-1307 USA

# Units (\u00b2 is the symbol for supercript 2)
centimerUnit=\u5398\u7c73
inchUnit=\u82f1\u5bf8
millimeterUnit=\u6beb\u7c73
meterUnit=\u7c73
squareMeterUnit=m\u00b2
squareFootUnit=\u5e73\u65b9\u82f1\u5c3a
User avatar
Puybaret
Posts: 9440
Joined: Mon Nov 07, 2005 12:00 pm
Country: Paris, France
Contact:

Re: Sweet Home 3D 6.5A bug was found in Sweet Home 3D

Post by Puybaret »

I checked, even double checked with a binary editor and don’t see any hidden character in the [font=courier new]centimeterUnit[/font] line of LengthUnit_zh_CN.properties.
How do you see the bug that you encountered?
Emmanuel Puybaret, Sweet Home 3D creator
User avatar
YGYL
Posts: 157
Joined: Tue Feb 05, 2013 4:00 pm

Re: Sweet Home 3D 6.5A bug was found in Sweet Home 3D

Post by YGYL »

centimerUnit
centimeterUnit
These 2 words are not the same
User avatar
YGYL
Posts: 157
Joined: Tue Feb 05, 2013 4:00 pm

Re: Sweet Home 3D 6.5A bug was found in Sweet Home 3D

Post by YGYL »

It seems that the same mistake occurs in Russian
User avatar
dorin
Posts: 824
Joined: Thu Apr 24, 2014 9:14 am
Country: Vatra Dornei, Suceava, Romania

Re: Sweet Home 3D 6.5A bug was found in Sweet Home 3D

Post by dorin »

@YGYL You've right. That is what I've discover earlier.
BUT
@Emmanuel Is something strange:
centimeterUnit must be the correct.
In this case CN & RU don't work as aspect but TW which have centimerUnit = work.
If change CN & RU to incorrect form = work.
I suspect it is also a misspelling in other place of translations.
How to verify and reproduce:
1. Open a home with rooms;
2. Set preferences to English & centimeter;
3. Menu->Tools->RoomsInfo ==> in table are m₂ => OK
4. Set preferences to Chinese or Russian and repeat step 3 ==> ft₂ => Not OK.
If change centimerUnit with centimerUnit in CN & RU files will work but it has no logic (at least for me).
A computer program does what you tell it to do, not what you want it to do. Murphy's Law
When all else fails, read the instructions. Murphy's Law
If you don't like "AS IS", DIY. Dorin's law
User avatar
Puybaret
Posts: 9440
Joined: Mon Nov 07, 2005 12:00 pm
Country: Paris, France
Contact:

Re: Sweet Home 3D 6.5A bug was found in Sweet Home 3D

Post by Puybaret »

I fixed this error in LengthUnit_zh_TW.properties, but it was the only wrong file.
In all cases, surface texts shouldn't be based on [font=courier new]centimerUnit[/font] property but on [font=courier new]squareMeterUnit[/font] or [font=courier new]squareFootUnit[/font] properties according to the current unit set in preferences, and to avoid wondering how to format surface texts, programs should use [font=courier new]getAreaFormatWithUnit[/font] in [font=courier new]LengthUnit[/font] class, like in the PlanComponent class.
Dorin, did you use the same way?
Emmanuel Puybaret, Sweet Home 3D creator
User avatar
dorin
Posts: 824
Joined: Thu Apr 24, 2014 9:14 am
Country: Vatra Dornei, Suceava, Romania

Re: Sweet Home 3D 6.5A bug was found in Sweet Home 3D

Post by dorin »

@Emmanuel
I don't remember what I've use (it was long time ago) but probably I don't use this way.
At the moment I steel fight with roofs.
After I finish somehow this, I'll reanalyze RoomsInfo plugin and I'll tray to improve it.
Thanks for the clue!! I really need it.
A computer program does what you tell it to do, not what you want it to do. Murphy's Law
When all else fails, read the instructions. Murphy's Law
If you don't like "AS IS", DIY. Dorin's law
User avatar
Puybaret
Posts: 9440
Joined: Mon Nov 07, 2005 12:00 pm
Country: Paris, France
Contact:

Re: Sweet Home 3D 6.5A bug was found in Sweet Home 3D

Post by Puybaret »

I just checked the source code of the [font=courier new]TotalResult[/font] class you programmed, and you formatted surface texts another way in [font=courier new]UpdateCalc[/font] method.
As you compute the text of the surface unit [font=courier new]unitSurf[/font] from the name of the current length unit, this can lead to errors for languages where this name is localized (like Chinese or Russian).

A quick fix could consist of testing the current unit and not its name. Therefore, the line:

Code: Select all

if (unitName.equalsIgnoreCase("mm") || unitName.equalsIgnoreCase("cm") || unitName.equalsIgnoreCase("m")) {
should rather be:

Code: Select all

if (preferences.getLengthUnit() == LengthUnit.MILLIMETER || preferences.getLengthUnit() == LengthUnit.CENTIMETER || preferences.getLengthUnit() == LengthUnit.METER) {
Good luck for the roofs!
Emmanuel Puybaret, Sweet Home 3D creator
User avatar
dorin
Posts: 824
Joined: Thu Apr 24, 2014 9:14 am
Country: Vatra Dornei, Suceava, Romania

Re: Sweet Home 3D 6.5A bug was found in Sweet Home 3D

Post by dorin »

Many thanks Emmanuel!!
Today I'll take a break from roof and I'll try to fix RoomsInfo.
If succeed I'll publish a fixed version.
Thanks again, without You, I have to spend mounts to find the bug (if I find)
A computer program does what you tell it to do, not what you want it to do. Murphy's Law
When all else fails, read the instructions. Murphy's Law
If you don't like "AS IS", DIY. Dorin's law
Post Reply New Topic

Who is online

Users browsing this forum: No registered users and 1 guest