Hot Door CORE Forum
preferences->getIntPref seems to malfunction - Printable Version

+- Hot Door CORE Forum (http://hotdoorcore.com/forum)
+-- Forum: All forums (http://hotdoorcore.com/forum/forumdisplay.php?fid=1)
+--- Forum: Bugs (http://hotdoorcore.com/forum/forumdisplay.php?fid=5)
+--- Thread: preferences->getIntPref seems to malfunction (/showthread.php?tid=328)



preferences->getIntPref seems to malfunction - Rick Johnson - 11-24-2022

I noticed in CORE 0.8.1 an unexpected behavior. When requesting a preference that has not yet been created:

Code:
int n = 3;
bool success = HDI_CORE_ILLUSTRATOR->preferences()->getIntPref("foo", "bar", n);
// success now equals true
// n now equals 0

I had expected success to be set to false and n to remain set to 3.

As a workaround, I did this:

Code:
std::string str;
HDI_CORE_ILLUSTRATOR->preferences()->getStringPref("foo", "bar", str);
if (str != "")
   n = stoi(str);



RE: preferences->getIntPref seems to malfunction - garrett - 11-29-2022

This is strange, as we made no changes whatsoever to the ai::Preferences class between releases of hdi_core. The class itself is just a thin wrapper over the SDK AIPreferenceSuite, so might be worth checking whether you see the same issue/change purely via the SDK (perhaps between AI 25/26/27 or so).


RE: preferences->getIntPref seems to malfunction - Rick Johnson - 03-04-2023

I'd been meaning to test this with the SDK, but hadn't gotten around to it. Then fellow CORE user Tom Raisk wrote and said that he had done some tests, and said: "Turns out if you want to obtain a pref value without preliminary check for existence Adobe Illustrator creates this pref value. AI 2022 makes it with "0" value, AI 2023 - with some random number.

But sAIPref->PreferenceExists works nominally.  At least this code below (both for AI 2022 and 2023) does:

Code:
AIBoolean isAppPrefExists;
error = sAIPref->PreferenceExists(NULL, "somePref", &isAppPrefExists);
if (isAppPrefExists)
{
  int prefIntValue;
  error = sAIPref->GetIntegerPreference(NULL, "somePref", &prefIntValue);
  hdi::core::alerts::message("App Pref value is:  " + to_string(prefIntValue));
}


It correctly determines that "somePref" does not exist.

Unfortunately, the PreferenceExists function has no counterpart in CORE.


RE: preferences->getIntPref seems to malfunction - garrett - 03-08-2023

Thanks for the catch that we did not include a method to check for the existence of a pref. I have just added this to hdi_core and it will be present in our next release.


RE: preferences->getIntPref seems to malfunction - Rick Johnson - 04-15-2023

As of Illustrator 27.4, that Illustrator preferences bug is fixed. Now when you try to read a non-existent preference, it creates it, either with a null string or a value of 0, and it returns the correct corresponding value.