Commit Graph

194 Commits

Author SHA1 Message Date
luz paz
ba94730a23 Fix various typos
Found via `codespell`
2022-09-06 10:44:29 -04:00
luz paz
cfc6e9d7e0 Fix source typo begining->beginning 2022-06-27 07:16:54 -04:00
luz paz
8adedc2248 Fix various typos
Found via `codespell -q 3 -S *.po,./po,*.min.js,./ChangeLog*,./NEWS,./borrowed,./doc/README*,./AUTHORS,./libgnucash/tax/us/txf-de*,./data/accounts -L ans,ba,cas,dragable,gae,iff,iif,mut,nd,numer,parm,parms,startd,stoll`
2022-04-08 14:12:50 -04:00
Christopher Lam
4a75baa4c6 [gnc-xml-backend.cpp] gchar* must be freed after use.
It is used as a constructor for std::string which makes a copy but
doesn't take ownership.
2022-03-21 07:26:45 +08:00
John Ralls
916caa25f2 Integrate Windows gzopen differences so that only one ifdef is needed.
Clarifies code.
2022-03-05 16:20:08 -08:00
John Ralls
250b4ed733 Remove stray line left from earlier refactoring. 2022-03-04 14:53:02 -08:00
Robert Fewell
7e299cb2b0 Remove print statement left in commit c3f8daa 2022-03-04 10:16:14 +00:00
John Ralls
8ef8d3807c Silence spurious conditional uninitialized warning in gnc-owner-sql.cpp. 2022-03-03 13:21:51 -08:00
John Ralls
93f5e23cf5 Open gzfile if thread creation fails. 2022-03-03 13:20:41 -08:00
John Ralls
81b9a02235 Bug 798458 - Build failure with gcc 12
Refactor try_gz_open to return a std::pair<FILE*, thread>. That removes
the need for the threads hash-table and wait_for_gzip().

The cause of the gcc12 error was that we were using the thread's pipe's
FILE* as the key to the hash-table and had to close it before calling
wait_for_gzip(file) to remove the thread from the hash-table. gcc12
considers that a use-after-free. It happens to be wrong, but removing the
need for it results in a cleaner implementation as well as silencing the
warning.
2022-03-01 12:49:12 -08:00
John Ralls
67e8c317da [xml backend] Extract functions to make gz_trhead_func more readable. 2022-03-01 12:49:12 -08:00
John Ralls
74d0630867 Bug 798237 - Logging during XML file loading degrades performance...
significantly

Modify the DEBUG and PINFO macros to return unless qof_log_check is
true. Replace almost all direct calls to g_debug and g_message with
DEBUG and PINFO respectively.

Track the highest logging level sent to qof_log_set_level to provide a
short-circuit return in qof_log_check. Remove setting GNC_MOD_TESTS to
QOF_LOG_DEBUG so that the short-circuit threshold isn't defeated by
always being DEBUG.

Net result: 33% improvement in xml load times.
2021-09-14 15:15:11 -07:00
John Ralls
574f567b62 Refactor GncXmlBackend::get_file_lock.
Moving all of the error-handling to it for better clarity and
simplicity. Drop the unnecessary stat call, open will fail with
EEXIST if there's already a lock file. Provide specific messages
for file system failures.
2021-09-14 09:32:12 -07:00
John Ralls
d7eae0664f [gz_open] Use compress and write consistent with calling functions. 2021-09-14 08:29:11 -07:00
John Ralls
c3f8daaf7d Bug 798250 - Gnucash permanent hang on save while loading report
Prevent WebKit's fork from getting a copy of the pipe's file descriptors
and so keeping the pipe from closing.

Thanks to Simon Arlott for recognizing the FD duplication.
2021-09-13 13:18:10 -07:00
John Ralls
901fea158f Merge Simon Arlott's 'xml-locking-fixes' into maint. 2021-09-06 15:22:49 -07:00
John Ralls
38cd06e54a Remove the lock-file-link-count test from the XML backend.
This was an effort of somewhat dubious value to detect if a process
on another ocmputer had a hsrd-link to a lockfile on an NFS share.
NFS is rarely used now and SMB doesn't support hard links so this check
adds complexity with no real value.
2021-09-06 15:18:34 -07:00
Simon Arlott
0665208299
xml-backend: Lock file is deleted even if the lock is not acquired
The lock file is set in m_lockfile and then unlinked in session_end even if
the lock was not acquired.

Clear m_lockfile if locking was not successful.
2021-08-24 09:29:47 +01:00
Simon Arlott
e4619fdae6
xml-backend: Don't try to close m_lockfd if it's not open
m_lockfd is not initialised. If the file is locked then it will not be set
before session_end and close() will be called on an uninitialised int.

Initialise it to -1 in the class definition.
Consistently use -1 instead of "< 0" or "< 1" as the definition of invalid.
Always set it to -1 after closing it.
2021-08-24 09:29:45 +01:00
Christopher Lam
c9db551693 g_free qof_print_date which returns a new char* 2021-08-05 09:23:28 +08:00
John Ralls
d099d39afd Merge Simon Arlott's 'commit-root-on-load' into maint. 2021-08-04 15:52:51 -07:00
John Ralls
fd56512cf7 Merge Simon Arlott's 'load-test-xml' into maint. 2021-08-04 15:48:42 -07:00
Christopher Lam
23bd716451 g_free gnc-path's gchar* intermediate strings 2021-08-03 12:14:12 +08:00
Simon Arlott
bf8fe1123c
Commit root accounts after loading from XML
The root accounts start with a non-zero editlevel because BeginEdit is
called for them during loading but not committed after loading.

If the book is then closed without performing any further edits that would
require a commit, the Account book_end process does nothing because the
root account is still being edited and so none of the accounts are freed.
2021-07-11 15:04:57 +01:00
Simon Arlott
f15402a9a6
Load test data from XML properly
If qof_session_new() is called without a book then qof_session_load()
won't do anything.

Set up a book for it to use.
2021-07-11 14:56:56 +01:00
Christopher Lam
e653c30193 [gnc-xml-backend] g_free char* 2021-06-22 18:57:55 +08:00
Christopher Lam
f37fa85705 build dom_tree_to_list_kvp_value more efficiently
seems to be unused however
2021-05-30 11:09:39 +08:00
Christopher Lam
59386b4081 gchar* dom_tree_to_text must be g_freed 2021-05-30 08:10:19 +08:00
Christopher Lam
c1cb29df53 GncGUIDs should be freed with guid_free instead of g_free 2021-05-17 21:00:59 +08:00
John Ralls
bbb4113a5a Bug 798156 - glib 2.68.0 breaks gnucash
Move all of the #include <glib> to before the extern "C" blocks
so that the include guards will protect against headers inside
the extern "C" block also including glib.h.
2021-04-20 11:03:23 -07:00
John Ralls
170502c6c5 Bug 797906 - GnuCash data file is locked after a "save-as"...
to mysql database.

It's more general, any save-as to a different backend type, i.e.
xml->sql or sql->xml, left the previous book locked.

Ensure that the session is ended and the book unlocked in the
backend's destructor. This also fixes a memory leak in the SQL
backend because the GncSqlConnection wasn't being deleted.
2021-03-23 11:27:37 -07:00
John Ralls
c49b45d8f1 Finish the glib 2.67 fixes for CI tests. 2021-03-22 14:02:37 -07:00
Frank H. Ellenberger
93e2829ee5 Merge PR #899 into maint 2021-03-02 01:17:26 +01:00
luz paz
16b4976381 Fix typos in libgnucash/
Found via `codespell -q 3 -L ans,ba,parm,parms,numer`
2021-03-02 01:15:32 +01:00
John Ralls
7a7c26f87e Move glib and gtk includes out of extern C for tests.
Needed to compile with glib 2.67 and later.
2021-02-16 13:23:48 -08:00
Bill Nottingham
c0f2c3ae25 Fix build with glib2 2.67.x.
glib headers should not be included with 'extern "C"'.
2021-02-16 13:23:16 -08:00
John Ralls
ba0e412815 Bug 798112 - An error occurred while processing mysql ...
A "Feature" of MYSQL is that it allows C-style backslash escapes
in string constants and replaces them with the actual character
(e.g. \n is converted to 0x0a). This causes round trip problems
if the escape is one of the allowed ones and a MYSQL error if it
isn't.

Disable the feature so that MYSQL follows the SQL standard.
2021-02-07 13:53:00 -08:00
John Ralls
fe4f9ed64a [test-backend-dbi] Fix copying hidden property.
So that it actually copies it to the *other* root account.
2021-02-07 13:50:29 -08:00
John Ralls
12ad4fadae Bug 798101 - Do not #undef __STRICT_ANSI__
Remove defines and undefines for Windows, they were needed with
MinGW classic but are not with MinGW-w64.
2021-01-30 17:38:37 -08:00
John Ralls
94a68dca7c Bug 797983 - v4.2 report numbers change over gnucash restarts;...
Price Database dropping user:price-editor entries.

A wider problem: QofInstance was unmarking itself dirty as long as the
backend raised an error and unconditionally marking itself non-infant.

This matters because the SQL backend depends on infant status to decide
whether to do an insert or update query; either will fail if the infant
status is wrong.

The price editor dialog clones a price having only its commodity set and
GncSqlPriceBackend declines to save if the currency isn't set. Since the
instance marked itself non-infant even though it wasn't saved subsequent
commits tried to use an update query and since the price wasn't in the
table that inevitably failed.

Requiring that QofBackend::commit should doing the marking-clean
required implementing it in the backends where it wasn't already.
2020-10-18 16:09:41 -07:00
John Ralls
44fc52f5c6 Fix unnecessary copy in range-for loop
Flagged by new clang Apple version 12.
2020-09-25 12:31:13 -07:00
Gaming4JC
cca4524055
Fix warnings: missing sentinel in function calls
When compiling with -Werror, GNUCash fails to build due to various error: missing sentinel in function call.
This patch resolves the issue by passing nullptr instead of C-style casting NULL.
2020-09-06 00:50:54 -04:00
John Ralls
d308028353 Merge branch 'maint' 2020-06-20 15:36:58 -07:00
John Ralls
50329df082 Bug 797811 - GnuCash crashes with segfault when saving to mysql...
when database already exists.

Crashed because of dereferencing GncSqlBackend::m_conn when it's nullptr
after the DB create failed. Protect all such dereferences.
2020-06-19 15:08:58 -07:00
Robert Fewell
d4e90132d9 Fix a missing mode == in 'Replace the three bool parameters
to qof_session_begin to an enum'.
2020-06-05 11:10:16 +01:00
John Ralls
b8d514e157 Don't try to unlock the GncDbiSqlConnection when it was connected read-only.
If it's locked it's not *our* lock.
2020-06-04 14:07:28 -07:00
John Ralls
6a1cb5eecd Replace the three bool parameters to qof_session_begin to an enum.
For clarity. In so doing found the backend behavior a bit inconsistent
so it's modified to do what the enum values indicate.

In the course of changing the various calls I found some implementation
errors in the back end and corrected them.
2020-06-04 14:07:28 -07:00
John Ralls
c73a1bd475 Extract function template drop_database. 2020-06-04 14:07:28 -07:00
John Ralls
a320035f42 QofSession, QofBackend: Change book_id to uri.
It's more descriptive and less likely to be confused with the book:id value
in XML files that is the book's GUID.
Also changed the QofSessionImpl::begin new_uri parameter from std::string to
const char*. There's no point in allocating a string just to call
new_uri.c_str() all over the place.
2020-06-04 14:07:28 -07:00
John Ralls
65e2639de4 Delete QOF_STDOUT.
Apparently a hack for the long-gone QSF backend.
2020-06-04 14:07:28 -07:00