Getting an odd crash when trying to save settings
Widdershins Studio
Posts: 539
Code as follows, reads a string from a QLineEdit and tries to save it.
On closing DS and trying to save the setting it crashes.
QString foo = leDimWidth->text(); QString setting(foo); DzAppSettings settings("WiddershinsApp"); settings.setStringValue("stgDimWidth", setting);
Reason given by DS is :
DAZStudio.exe caused ACCESS_VIOLATION in module "C:\Program Files\DAZ 3D\DAZStudio4\QtGui4.dll" at 0033:0000000059CD03A6, QLineEdit::text()+6 byte(s)
Is there some other way ?
Thanks.
Post edited by Widdershins Studio on
Comments
I suspect that your problem is with "leDimWidth" and not the "settings.setStringValue("
As long as you have initialised leDimWidth correctly in your code somewhere e.g. leDimWidt = new QLineEdit(m_myExampleWidget);
before you call on it.
The following should work
DzAppSettings settings("WiddershinsApp");
settings.setStringValue("stgDimWidth", leDimWidth->text());
Do a test using
DzAppSettings settings("WiddershinsApp");
settings.setStringValue("stgDimWidth", "This is a test");
If that works, check how and when you have initialised "leDimWidth" in your code. You may be calling on it before you have initialised it, or calling on it after you have destroyed/disposed of it.
I did try the test with just a regular string and it does work. Like you say it might be destroyed before I try to use it.
I'm not sure if I really need persistant settings across sessions, panes keep the temporary settings even after being closed I found, I'll work around it.
Thanks again for the help :)
Still having problems with this on something similar.
I cannot seem to refer to line edits or check boxes in my main code.
When I do this :
Or this
Daz crashes all the time.
Is there some step I am missing please ?
isChecked() should return a bool, so the "? true : false" is redundant. But that is merely a distraction and not the problem.
It is impossible to tell where your problem is from just the two lines of code.
Check your DAZ3D log file to see if that helps you find why it is crashing. In Daz3d the menu HELP > TROUBLESHOOTING > VEIW LOG FILE...
Hi,
Yep agreed on the boolean bit.
I found the problem with the help of the Qt forum.
I had declared the QLineEdit in the header file and had then declared it again in the main ccp with new - so I was doing it twice in effect. That's what the problem was.