Commit Graph

186 Commits

Author SHA1 Message Date
John Ralls
b391754ff6 Correct -Wunused warnings
The actual change to configure.ac (at line 1106) to enable -Wunused -- or rather to un-disable it -- is not included in order to not break the build for folks with buggy versions of swig.
(For example, https://sourceforge.net/tracker/?func=detail&aid=3530021&group_id=1645&atid=101645)

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22203 57a11ea4-9604-0410-9ed3-97b8803252fd
2012-05-26 23:47:34 +00:00
Phil Longstaff
0809170098 Fix some small problems (including a memory leak) found by running qof unit test with valgrind.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22193 57a11ea4-9604-0410-9ed3-97b8803252fd
2012-05-21 18:35:59 +00:00
Phil Longstaff
9267e80726 Since 2.32, GCache is deprecated and should be replaced by GHashTable.
In the new string cache (split out from qofutil.c/.h), the GHashTable has the
string as key and a small heap-allocated guint refcount as data.  The value is
allocated rather than being used by value because there is no way to just
modify the data field of an existing key.  The key would need to be changed at
the same time, which would free the old key value and invalidate all gchar
pointers of objects which have refs to the key.

Unit tests added as well.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22190 57a11ea4-9604-0410-9ed3-97b8803252fd
2012-05-21 17:28:30 +00:00
Christian Stimming
374747c4f6 Check whether header <pow.h> really exists before including it.
The windows build has been failing for several days due to this.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22146 57a11ea4-9604-0410-9ed3-97b8803252fd
2012-04-13 20:43:23 +00:00
John Ralls
6d32b6f693 [Testing] Separate unit test functions from make check functions.
I'd originally put the functions supporting log detection, qof event handling, and mock-counting in test-stuff along with the functions that support the older "make check" integration tests. There are now more unit test support functions than there are of the older functions, so it's time for them to move out on their own.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22132 57a11ea4-9604-0410-9ed3-97b8803252fd
2012-04-03 21:35:19 +00:00
Christian Stimming
176fba9b9f Rename internal function names for read-only option of r22107 also to "auto-read-only".
(Initially I thought there were a relation to the "freeze" state of a
transaction, but this turned out to be not the case.)

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22118 57a11ea4-9604-0410-9ed3-97b8803252fd
2012-03-24 22:34:59 +00:00
Christian Stimming
bfbe9b87c4 Add option for automatically setting old transactions to read-only.
The number of days for this read-only threshold can be chosen.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22107 57a11ea4-9604-0410-9ed3-97b8803252fd
2012-03-21 22:18:29 +00:00
Christian Stimming
43b51df596 Re-indentation of source code.
As usual, re-indentation was done using astyle-1.24 using the following options:

  astyle --indent=spaces=4 --brackets=break --pad-oper --pad-header --suffix=none

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22089 57a11ea4-9604-0410-9ed3-97b8803252fd
2012-03-16 20:27:09 +00:00
Christian Stimming
35ac83374e Replace g_list_append by g_list_prepend to increase performance.
To my surprise, this apparently also fixes a memory leak, but I don't know why.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22074 57a11ea4-9604-0410-9ed3-97b8803252fd
2012-03-11 21:55:53 +00:00
Christian Stimming
d90301b2bd Remove obsolete strspn() call that causes valgrind warnings about invalid read().
The strspn() call was added in r8500 but the usage of its return value
was removed in r10315, so it isn't neccesary anyway.

The macro GNC_DEPRECATED is defined nowhere and used nowhere else, so
we can remove that block altogether.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22071 57a11ea4-9604-0410-9ed3-97b8803252fd
2012-03-08 22:47:59 +00:00
J. Alex Aycinena
7c03e237b2 Update xml file backend to recognize a newer version file on load attempt, not load, and alert user of need to upgrade Gnucash.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21908 57a11ea4-9604-0410-9ed3-97b8803252fd
2012-01-29 01:12:30 +00:00
John Ralls
f32bccfbaa Fix missing-prototype warnings from r21829
Thanks, Alex.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21837 57a11ea4-9604-0410-9ed3-97b8803252fd
2012-01-10 05:06:05 +00:00
John Ralls
55b1a8a5f7 [Bug 666329] - Empty database after a little while
Separate the two uses of QofBook::dirty -- indicating that the book object
itself has been edited and indicating that some object in the dataset has
been changed -- into two separate variables with separate getters & setters.

The latter purpose, indicating that some object has been changed, is moved
to a new member variable of QofBook, session_dirty. Its new setter
qof_book_mark_session_dirty() and canceler qof_book_mark_session_saved()
are called only from the xml backend or gnc-autosave(). Its tester,
qof_book_session_not_saved() is used to check for the need to autosave
and to activate FileSaveAction.

BP

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21832 57a11ea4-9604-0410-9ed3-97b8803252fd
2012-01-09 23:10:20 +00:00
John Ralls
614052092e [GSOC][Testing] Unit tests for qofsession
Author: Muslim Chochlov

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21830 57a11ea4-9604-0410-9ed3-97b8803252fd
2012-01-09 23:09:57 +00:00
John Ralls
5ed0fbb480 [GSOC][Testing] Modifications to qofsession for testability
Author: Muslim Chochlov

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21829 57a11ea4-9604-0410-9ed3-97b8803252fd
2012-01-09 23:09:47 +00:00
Christian Stimming
3fcdf59adf Re-indentation of source code.
As usual, re-indentation was done using astyle-1.24 using the following options:

  astyle --indent=spaces=4 --brackets=break --pad-oper --pad-header --suffix=none

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21816 57a11ea4-9604-0410-9ed3-97b8803252fd
2012-01-01 20:36:46 +00:00
Christian Stimming
e707b1227c Read-only mode: When using qof_session_swap_data, don't swap the read_only flag but only the rest of the QofBook.
Otherwise the temporary new session during "Save As" is read-only where in reality
it shouldn't be (but the old session should).

This makes "Save As" work correctly, but many UI elements don't get updated
to reflect the fact we've now got a read-write book again. (E.g., all open registers.)

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21795 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-12-29 22:14:43 +00:00
John Ralls
47edcb2090 Fix circular dependency between test-core and qof-test.
Compile test-core/test-stuff.c into test-qof, then recompile test-core as a module for dealing with noise from Guile and Python tests.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21736 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-12-17 19:32:27 +00:00
Christian Stimming
bb3642e6cf Improve comments a bit: Add clarifications about which second of the day is returned.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21704 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-12-10 21:09:53 +00:00
John Ralls
3df0b35b4f [Testing] Stifle error messages from QOF testing.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21702 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-12-09 23:50:03 +00:00
Geert Janssens
7f40be5302 Fix some static warnings and errors as a result of Eclipse's static code
analysis.
As a result, some unused functions and function prototypes are removed.

It did expose one real bug in Transaction.c so far.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21687 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-12-08 17:11:21 +00:00
John Ralls
db9d8ee570 Make distcheck fixes.
Fix some errors in r21570 which cause "make distcheck" to fail, and a couple of others besides.

While this gets distcheck to work on the Mac, there are still some problems with the standard-reports test on Linux related to trying to load reports from the installation directory (make install is run *after* make check during make distcheck). This test passes on the Mac, fails on Linux.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21645 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-11-29 21:29:37 +00:00
Christian Stimming
d25a992701 Add unittest for gnc_dmy2gdate() function to verify the correct behaviour of the by-value returned value.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21563 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-11-13 20:39:53 +00:00
Christian Stimming
bbb529263b Add two more helper functions dealing with GDate.
In particular, glib doesn't offer a function for easily accessing
the "today" date as a GDate. What a pity. It's added now as gnc_g_date_new_today().

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21559 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-11-11 21:57:52 +00:00
Christian Stimming
e782c612f6 Simplify QofSession to own only exactly one QofBook.
No more, no less. This object isn't used in any other way in gnucash, so
we better get rid of the extra potential complexity here.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21548 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-11-09 21:45:12 +00:00
Christian Stimming
66ddf0c74f Revert r21517 "Add is_readonly attribute to QofSession class."
This is not needed. See
http://lists.gnucash.org/pipermail/gnucash-devel/2011-November/032793.html
and thread.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21547 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-11-09 21:44:58 +00:00
Christian Stimming
13ca8524d1 Remove qof_session_add_book() - a QofSession is used only with one book throughout gnucash.
Subsequently, the QofBook pointer in QofSession can be changed from
a GList to a QofBook*.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21526 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-11-06 20:53:59 +00:00
John Ralls
f2fcf51cbd [Engine Unit Testing] Unit tests for Account.c
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21525 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-11-05 23:05:00 +00:00
Christian Stimming
4a5ec547e8 Add is_readonly attribute to QofSession class.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21517 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-11-03 21:48:00 +00:00
John Ralls
dffd44139d Handle specifying a directory as a dataset file.
The file chooser dialog would return a directory if the user selected
one and clicked "Open"; then, or if the users specified a directory on
the command line, Gnucash would present the rather misleading error "No
backend found".

So, first, if the user selects a directory and clicks open, the chooser
will now open the directory for browsing, just as if she had
double-clicked on the directory name in the tree view.

Next, if a directory is presented to qof_session_begin it will detect
that and set ERR_BACKEND_BAD_URL, which gnc_post_file_open will detect
and re-present the file chooser, open to that directory. (To prevent
confusion, gnc_post_file_open will put up the error dialog for BAD_URL;
the new file chooser dialog will open after that's dismissed. Since
there are other possible causes of a BAD_URL, if the filename isn't a
directory the chooser will open to the registered default directory from
GConf.)

BP

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21459 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-10-19 00:02:59 +00:00
Geert Janssens
62e1b1ac57 Bug #661220 - Critical errors when closing down Gnucash
Patch by Robert Fewell

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21417 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-10-14 14:57:54 +00:00
John Ralls
b2e7182d0c [Bug #645216] Wrong permissions on server result in bogus error message
Author: John W. O'Brien <john@saltant.com>
In gnc-backend-dbi.c, accept enumerated result from conn_test_dbi_library(),
then throw ERR_SQL_DBI_UNTESTABLE if the test setup failed, or ERR_SQL_BAD_DBI
if at least one test case failed.

Define ERR_SQL_DBI_UNTESTABLE error code and message.
Define GncDbiTestResult enumerated type.

BP

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21269 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-09-18 17:57:28 +00:00
John Ralls
ee913abb61 Delete the often-conflicting and occasionally unsafe Gnucash local
variables which have leaked in over the years.

Emacs users should add the following to their .emacs files:
(c-add-style "gnucash"
                '("k&r"
                  (c-basic-offset . 4)
                  (c-offsets-alist . ((case-label . +)) )
                  (c-hanging-braces-alist . ((substatement-open before after)
                                              (block-close before after)) )
                  ))

Users with Emacs version 23 and later can add this as well:

(dir-locals-set-class-variables 'gnucash-project
                                '((indent-tabs-mode . nil)
                                  (fill-column . 80)
                                  (c-mode . ((c-file-style . "gnucash")))
                                  (c++-mode . ((c-file-style . "gnucash")))))
(dir-locals-set-directory-class "/path/to/gnucash-svn" 'gnucash-project)

Users with earlier versions should at least add
(setq indent-tabs-mode nil)
and should consider adding
(c-default-style ('((c-mode . "gnucash"))))

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21221 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-08-25 21:38:33 +00:00
Christian Stimming
1961766c99 Re-indentation of source code.
As usual, re-indentation was done using astyle-1.24 using the following options:

  astyle --indent=spaces=4 --brackets=break --pad-oper --pad-header --suffix=none

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21205 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-08-22 07:10:56 +00:00
John Ralls
c318a112a5 Delete qofinstance_gemini and all related functions; they were left over from the clone-the-book-when-closing code abandoned in 2005
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21203 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-08-22 03:58:10 +00:00
John Ralls
71cd886e99 Remove unused functions from kvp_frame
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21193 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-08-20 03:45:08 +00:00
John Ralls
b3c49d4514 Delete unused functions from qofinstance.c
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21192 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-08-20 03:44:59 +00:00
John Ralls
8d53e67560 Delete unused functions from qofbook.c
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21191 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-08-20 03:44:50 +00:00
John Ralls
0ac8f02da4 Delete unused QofInstance copy functions from qofsession.c
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21190 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-08-20 03:44:40 +00:00
Geert Janssens
8a7c5d622c Add note for qofmath128.c include in the source file itself
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21130 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-08-08 14:31:23 +00:00
Christian Stimming
8c5f6ebf5d Revert r21121, "Fix a weird include", and improve documentation of that.
Note: The qofmath128 functions are used mostly here and almost
nowhere else. Hence, we inline the C code directly into here so
that the compiler can potentially inline the code as-is and speed
up the gnc-numeric.c functions.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21127 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-08-08 06:59:54 +00:00
John Ralls
28f9c45de1 [GSOC 2011 Unit Testing] Test QofObject.
Author: Muslim Chochlov

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21126 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-08-07 21:30:17 +00:00
Geert Janssens
269102cde7 Fix a weird include
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21121 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-08-07 09:15:30 +00:00
John Ralls
ed13b73866 [GSOC 2011 Unit Testing] Test KVPFrame.
Author: Muslim Chochlov

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@20937 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-07-17 21:21:59 +00:00
John Ralls
c40cdc2300 [GSOC2011 Unit Testing] Unit tests for QofInstance.
Author: Muslim Chochlov

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@20811 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-07-01 05:33:41 +00:00
John Ralls
04a90d6098 Revert "[GSOC2011 Unit Testing] Unit tests for QofInstance: Incomplete
changeset."

This reverts commit c7b6b45e9e97f210d2bb145ef2e355f1c660d35f.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@20810 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-07-01 04:56:47 +00:00
John Ralls
e245eeeecc [GSOC2011 Unit Testing] Fix memory error by not trying to test pointers in deallocated objects.
Author: Muslim Chochlov

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@20808 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-06-30 17:06:47 +00:00
John Ralls
ea7a20b4d5 [GSOC2011 Unit Testing] Unit tests for QofInstance.
Author: Muslim Chochlov

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@20807 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-06-30 17:06:35 +00:00
John Ralls
ed732e6a39 Unit test QofBook
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@20769 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-06-18 23:20:30 +00:00
John Ralls
fb0f27b043 Add unit test utility macros
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@20768 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-06-18 23:20:20 +00:00