Database, reusing Database object leads to segementation fault error
Hi all,
i get stucked with a weired error, and actually i have no idea what the problem is, maybe you can help or give a hint. In our app we have a configuration page where the user can write down the credentials for a local database connection and through a check mark one can activate the connection, this is saved via config class. C++ side receives these changes, shutdowns the database, waits for the shutdown event, deletes the db instance, and sets the database instance to nullptr. If check mark says activate the db connection, we try a new database connection with the new configuration and the same db object.
So here is the problem: On startup, everthing is ok. Connection established (default values given). Then i change the connection settings ones, this works. Setting the connection settings a second time and "reinitializing" the database leads to a segmentation fault error when trying to call the database "Connect" function. This is weired, because first time doing it is ok, a second time not (Sometimes it works twice, but not a third time.). It is the same code all the time. For what case do we need it? If the enduser later, tries to configure his/her database credentials, maybe he/she will probably give wrong credentials, more than one or two times. I tried to reuse the Connect function with others connection values, but it doesn´t work, shutdown is needed.
Is there something i miss using the database connection? Expspecialy when killing connections inside an app instance and reusing the database object to provide some other connection parameters.
Kind regards
Mladen