Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FOGL-7375 : Modified to return default value as blank for type:script #953

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

gnandan
Copy link
Contributor

@gnandan gnandan commented Jan 30, 2023

Signed-off-by: nandan nandan.ghildiyal@gmail.com

Signed-off-by: nandan <nandan.ghildiyal@gmail.com>
Copy link
Contributor

@MarkRiddoch MarkRiddoch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is not what is needed. The default should not be hard coded in the config category class. The filter sets its default to the empty string. Please find out what is adding the extra quotes and fix the problem where it is broken.

@gnandan
Copy link
Contributor Author

gnandan commented Jan 30, 2023

No, this is not what is needed. The default should not be hard coded in the config category class. The filter sets its default to the empty string. Please find out what is adding the extra quotes and fix the problem where it is broken.

Hi Mark,

Constructor of CategoryItem itself is adding extra quotes in case of blank values to default.

Below are the details from config_category.cpp file at line number# 1267

ConfigCategory::CategoryItem::CategoryItem(const string& name,
					   const Value& item)
{
....
if (m_default.empty())
			{
				m_default = "\"\""; <=== Line number 1267 of config_category.cpp
			}
.....
}

So it's ok to modify constructor itself ?

@MarkRiddoch
Copy link
Contributor

Fixing the constructor would be the right place to fix this.

…lank value or default config item

Signed-off-by: nandan <nandan.ghildiyal@gmail.com>
@gnandan
Copy link
Contributor Author

gnandan commented Jan 31, 2023

Fixing the constructor would be the right place to fix this.

It is done

…es for blank value or default config item"

This reverts commit 7615dc0.
@gnandan
Copy link
Contributor Author

gnandan commented Jan 31, 2023

Reverted changes as fixing in constructor failing during reconfigure because JSON is having blank value for default instead of quotes

Value after fix ==> "default" : 
expected value  ==>  "default": "" 

Signed-off-by: nandan <nandan.ghildiyal@gmail.com>
@MarkRiddoch
Copy link
Contributor

We do not have to do this for any other configuration type, why do we need to do this for scripts? Where did it fail when you fixed the constructor?

@gnandan
Copy link
Contributor Author

gnandan commented Feb 3, 2023

We do not have to do this for any other configuration type, why do we need to do this for scripts? Where did it fail when you fixed the constructor?

Well if config item is of type script / code then constructor explicitly sets it to quotes rather

if (m_itemType == ScriptItem ||
		    m_itemType == CodeItem)
		{
			// Get content of script type item as is
			rapidjson::StringBuffer strbuf;
			rapidjson::Writer<rapidjson::StringBuffer> writer(strbuf);
			item["default"].Accept(writer);
			if (m_default.empty())
			{
				m_default = "\"\"";
			}
		}

If I change m_default = "" then final value in JSON is shown as

"default": <blank space> instead of "default" : ""

So it gets crashed due to Invalid JSON. That's why in case of script/code we should not use escape character sequence ""\" otherwise in final JSON default will like "default" : "\"\""

So instead of blank it translates to quotes and GUI get quotes as a value of length 2 instead of empty value of length zero. That's why GUI fails here.

Let me know further action on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants