Commit Graph

179 Commits

Author SHA1 Message Date
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
John Ralls
fc637aadc7 Two more test directories needing G_LOG_DOMAIN defined.
Should fix CI failures.
2020-05-10 10:18:36 -07:00
John Ralls
5da3bf7943 [QofLog] Replace hashtable with tree of vectors.
16x speedup.
2020-05-09 14:39:08 -07:00
John Ralls
4e6c497cd1 Don't ask to save a non-existant book.
To accomplish that we separate creating a book and creating a session;
gnc_get_session no longer automatically creates a book if one isn't
connected.

We also add an initially_insensitive GtkAction array to
gnc-plugin-basic-commands with a call to make its contents insensitive
at plugin load so that the save button on the toolbar isn't lighted when
there's nothing to save.
2020-05-08 15:59:41 -07:00
John Ralls
8ff5af4c19 Decouple QofBook creation from QofSession.
So that we don't create two books when loading a session.
Step 1 to not having a dirty book when we think we should have no
book at all.
2020-05-08 15:59:41 -07:00
Geert Janssens
bbeb9a2b62 Drop all gnc-module dependencies and includes from compilation units that no longer use it
This also drops the python wrapper for gnc-module. As for the guile wrappers,
python should use other means of loading our shared libraries.

This commit required a few tweaks to the dependency chain as some units
inherited dependency information from gnc-module's public dependency
interface.
2020-04-24 22:16:24 +02:00
Geert Janssens
abf29aa196 Drop the gnc-module wrapper around the test-engine library
It's not adding anything
2020-04-24 21:29:20 +02:00
Geert Janssens
261bff1250 Drop unused module file in xml backend 2020-04-19 21:23:22 +02:00
John Ralls
f85be03bb5 Merge branch 'maint' 2020-03-29 14:46:55 -07:00
John Ralls
33902a6793 Improve test building with the Xcode generator.
Add CONFIGURATIONS keyword to unadorned tests, enables tests with
multi-config generators.
Add CONFIGURATION generator expression to libgtest.a and libgmock.a
build directory specs when building with Xcode so that it can
find them when building tests.
2020-03-23 17:52:26 -07:00
Geert Janssens
301db9020d Merge branch 'maint' 2020-02-06 16:50:08 +01:00
Geert Janssens
e79e82edcf CMake - remove parameter repetition in else() and endif() statements
This follows Professional CMake's recommended practises
2020-02-05 11:38:14 +01:00
Geert Janssens
490b20d2da Merge branch 'maint' 2020-01-17 18:35:30 +01:00
Geert Janssens
073e47801d Drop useless ifdefs
The parameter it checks is always defined these days
2020-01-17 18:25:43 +01:00
Geert Janssens
d8a304c2c9 Housekeeping - reduce the number of PACKAGE and VERSION related cmake variables
This starts by setting the gnucash version number in the 'project' call.
This will result in a number of variables set by cmake. The remainder
of this commit is to reuse the auto-generated
PROJECT_NAME, PROJECT_VERSION, PROJECT_VERSION_MAJOR
PROJECT_VERSION_MINOR, PROJECT_VERSION_PATCH and PROJECT_VERSION_TWEAK
instead of all the various instances of PACKAGE, GNUCASH_MAJOR_VERSION
and so on.

One parameter is worth mentioning - GETTEXT_PACKAGE
GnuCash is not using this directly (any more) but it has to be set before
including gi18n-lib.h.
2020-01-17 18:15:27 +01:00
Geert Janssens
4c77f7670e engine - remove gncmod boilerplate
engine is now an ordinary shared library

This requires a few more places to run gnc_engine_init as
this is no longer done as part of module loading.
2019-12-06 20:38:21 +01:00