Can't save configuration because indipropertybasic's & overload is protected
ktgilliam opened this issue · 4 comments
Describe the bug
Can't save a property to the configuration file in saveConfigItems(), as shown here:
bool MyCustomDriver::saveConfigItems(FILE *fp)
{
INDI::DefaultDevice::saveConfigItems(fp);
IUSaveConfigText(fp, &WhatToSayTP);
return true;
}
because the & overload is protected. Compiling as shown generates the error:
error: ‘INDI::PropertyView<T>* INDI::PropertyBasic<T>::operator&() [with T = _IText]’ is protected within this context [build] 745 | IUSaveConfigText(fp, &WhatToSayTP);
Removing the ampersand gives a deprecation warning:
warning: ‘INDI::Property::operator INDI::PropertyViewText*() const’ is deprecated: Do not use INDI::Property as pointer. [-Wdeprecated-declarations]
Expected behavior
Example code should compile without errors or warnings.
How is WhatToSayTP defined?
It is highly probable that WhatToSayTP
is of a new type, hence the error.
@ktgilliam Instead
IUSaveConfigText(fp, &WhatToSayTP);
use
WhatToSayTP.save(fp);
Got it - that did it, thanks.
@pawel-soja Should the tutorial at docs.indilib.org be updated, and if so, is this git issue the correct place to put a ticket for that? If not, I will go ahead and close it.
Thanks again!
@ktgilliam oh, I see. Thank you! I will make a fix in the documentation soon.