2023-03-06 GnuCash IRC logs
00:43:54 *** jralls has quit IRC
00:44:41 *** jralls has joined #gnucash
00:44:41 *** ChanServ sets mode: +o jralls
01:31:15 *** gandalf has joined #gnucash
01:57:14 *** fell has quit IRC
01:58:33 *** fell has joined #gnucash
01:58:33 *** ChanServ sets mode: +o fell
03:10:05 <Simon> c_str() is only valid at the point it's executed
03:11:16 <Simon> chris: returning c_str() is invalid
03:11:40 <Simon> chris: even "std::string a; const char *b = a.c_str();" is invalid
03:12:05 <Simon> well, unsafe...
03:12:22 <Simon> the problem is here:
03:12:24 <Simon> auto value{odb->lookup_string_option(section, name)};
03:12:35 <Simon> as soon as the function returns, "value" goes out of scope and gets destroyed
03:15:27 <Simon> lookup_string_option is returning a copy of the std::string so you don't have any option but to duplicate it if you want a const char*
03:15:54 <Simon> "@return the static char* of the value or nullptr if the option isn't found"
03:16:07 <Simon> that's going to be impossible unless you amend lookup_string_option() so that it can return a string reference
03:16:45 <Simon> "static const std::string empty_string{};" is pointless because lookup_string_option() returns a copy anyway
03:18:03 <Simon> if you can return a std::string& out of lookup_string_option() then you can return the .c_str() value and it'll be valid as long as the optiondb isn't modified, which is long enough for the caller to strdup
03:18:39 <Simon> but in that case the caller probably needs to strdup for its use to be safe
03:18:53 <Simon> so you may as well make gnc_option_db_lookup_string_value() always return a strdup copy
03:18:58 <Simon> and stop copying it in the caller
03:20:46 <Simon> gnc_option_db_lookup_string_value() is *only* called from C++ code
03:20:53 <Simon> just make it return a std::string!
04:07:55 *** chris has quit IRC
05:38:52 *** gjanssens has joined #gnucash
05:38:53 *** ChanServ sets mode: +o gjanssens
08:06:34 *** chris has joined #gnucash
08:06:34 *** ChanServ sets mode: +v chris
08:06:38 *** gncbot sets mode: +o chris
08:06:54 <chris> Simon: thx sounds like the right answer
09:30:45 *** jervin has joined #gnucash
09:42:18 *** gandalf1 has joined #gnucash
09:42:45 *** gandalf has quit IRC
09:42:45 *** gandalf1 is now known as gandalf
12:22:55 *** gjanssens has quit IRC
12:43:30 *** gandalf1 has joined #gnucash
12:43:58 *** gandalf has quit IRC
12:43:58 *** gandalf1 is now known as gandalf
12:57:11 *** gandalf1 has joined #gnucash
12:57:38 *** gandalf has quit IRC
12:57:38 *** gandalf1 is now known as gandalf
13:01:03 <jralls> chris, Simon, since gnc_option_db_lookup_string_value is used only by gnc_plugin_page_report_option_change_cb in gnc-plugin-page-options.cpp, the right thing to do is to lose it and call `priv->curdb->lookup_string_option()` directly.
13:03:52 <jralls> I see there's a potential crash in option_change_cb if new_value == nullptr: strcmp isn't NULL protected.
13:26:59 <jralls> meh. GncOptionDB::lookup_string_option is concealed, it has to go through the free-function wrapper. But it can return a const string& instead of a string, and that can be passed along.
13:35:10 *** palerider has joined #gnucash
13:36:30 *** palerider has left #gnucash
13:49:19 <jralls> Nope, can't get there from here without publicly specializing GncOption<std::string>::get_value() to return const std::string&. RV copy elision makes sure that there's only one temp, but a temp there must be.
14:26:16 *** gjanssens has joined #gnucash
14:26:16 *** ChanServ sets mode: +o gjanssens
14:36:29 *** gncbot has joined #gnucash
14:36:58 *** Unhammer has joined #gnucash
14:37:05 *** bertbob has joined #gnucash
14:37:06 *** ChanServ sets mode: +v bertbob
14:38:22 *** antonlada[m] has joined #gnucash
14:41:37 *** gjanssens has quit IRC
15:09:47 *** gncbot has joined #gnucash
15:10:20 *** Unhammer has joined #gnucash
15:24:26 *** luwum[m] has joined #gnucash
15:54:21 *** gandalf1 has joined #gnucash
15:55:10 *** gandalf has quit IRC
15:55:10 *** gandalf1 is now known as gandalf
16:35:55 *** jervin has quit IRC
16:38:01 *** jervin has joined #gnucash
16:46:11 *** gandalf has quit IRC
16:46:22 *** ArtGravity has joined #gnucash
16:46:22 *** ChanServ sets mode: +v ArtGravity
16:56:27 *** MatrixTravelerbot[m] has joined #gnucash
16:56:46 *** shukonmatrix[m] has joined #gnucash
17:01:45 *** FestplattenSchnitzel[m] has joined #gnucash
17:16:10 *** gncbot has joined #gnucash
17:16:43 *** Unhammer has joined #gnucash
17:17:21 *** PeterScholtens[m] has joined #gnucash
17:44:52 *** sunyibo[m] has joined #gnucash
18:20:15 *** Felix[m] has joined #gnucash
18:25:35 *** chrislck[m] has joined #gnucash
18:28:24 *** Kevin[m]1 has joined #gnucash
18:35:06 *** roycroft has joined #gnucash
18:35:06 *** ChanServ sets mode: +v roycroft
18:35:54 <roycroft> hello, folks. i am starting to use gnucash and want to access my data from multiple computers (not simultaneously)
18:36:10 <roycroft> as such, i decided to save to a mysql database instead of local xml
18:36:34 <roycroft> i set up the database, set the grants correctly (i think), and can access the database from the current gnucash machine
18:36:56 <roycroft> when i go to save to mysql, though, i get a non-helpful error saying it can't save
18:37:52 <roycroft> i did create the database on the mysql server, but i did not set up the schema, as the gnucash documentation did not indicate that i needed to do so, nor do i know where to find it
18:38:24 <roycroft> does the app create the schema on its own when it discovers an empty database, or am i missing that step
18:38:38 <roycroft> if the latter, can someone point me to the schema setup script?
18:39:55 *** jralls_afk is now known as jralls
18:40:39 *** ChanServ sets mode: +o jralls
18:40:47 <jralls> roycroft GnuCash insists on creating the database, not just the schema.
18:41:07 <roycroft> oh, ok
18:41:19 <roycroft> so if i drop the db then it may work
18:41:43 <jralls> Yes, as long as you've also granted create database to the mysql role.
18:41:45 <roycroft> i guess i'll need to modify the user as well to add create db capability
18:43:10 *** mrlemke has quit IRC
18:50:45 <roycroft> that worked fine - thank you
18:54:22 <jralls> you're welcome.
19:00:28 *** technicus[m] has joined #gnucash
19:07:57 *** Ablu[m] has joined #gnucash
19:20:53 *** dtux[m] has joined #gnucash
19:22:01 *** peter-butler[m] has joined #gnucash
19:33:26 *** JokerGermany has joined #gnucash
20:06:48 *** reactormonk[m] has joined #gnucash
20:15:46 *** Milou[m] has joined #gnucash
20:19:30 *** Julianold[m] has joined #gnucash
20:20:08 *** Trygve[m] has joined #gnucash
20:25:43 *** antonlada[m] has joined #gnucash
20:27:49 *** ElonSatoshi[m] has joined #gnucash
20:56:22 *** luwum[m] has joined #gnucash
21:00:54 *** MatrixTravelerbot[m] has joined #gnucash
21:08:22 *** ArtGravity has quit IRC
21:12:31 *** jervin has quit IRC
21:29:13 *** shukonmatrix[m] has joined #gnucash
21:34:58 *** FestplattenSchnitzel[m] has joined #gnucash
21:55:42 *** chockey has joined #gnucash
22:11:07 *** CodePenguin has quit IRC
22:14:22 *** CodePenguin has joined #gnucash
22:25:38 *** ChanServ sets mode: +v chockey
23:55:58 *** chockey has quit IRC