aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2012-09-21More cosmetic changes in the "Import" dialogGravatar Lubomir I. Ivanov
Renamed the XML button and titles slightly. Generalized the dialog topmost text to "Choose what to import:". Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2012-09-21Keep the "OK" button in "Import" disabled until a DC is selectedGravatar Lubomir I. Ivanov
Only call report_dives() for GTK_RESPONSE_ACCEPT in the same dialog. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2012-09-20Only select last dive by default if no other dives are selectedGravatar Dirk Hohndel
After deleting a dive the dive list is recreated. If there are still dives selected we should select the last dive as well. If there isn't any dive selected, then the last dive is as good a default as any, I guess. Reported-by: "Lubomir I. Ivanov" <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-20Fix dive trip saving bugGravatar Dirk Hohndel
When switching the dive trips to be stored in a different data structure I forgot to update the code in save_trip() - and since we were passing the pointer around via a gpointer the compiler didn't catch this. Oops. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-20Removed obsolete debug messageGravatar Dirk Hohndel
We now handle this case correctly, so don't alert the user to something that isn't an issue at all. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-20Merge remote-tracking branch 'origin/single-threaded-gui'Gravatar Dirk Hohndel
This brings in the last of the outstanding changes that fix bugs that were discovered when hunting down the long standing crash with some 64bit OSs.
2012-09-20Convert the divelist debug helpers to the new time functions as wellGravatar Dirk Hohndel
This makes things consistent. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-20Don't update the progress bar from the dive computer import threadGravatar Linus Torvalds
There's no guarantee that gtk is thread-safe (apparently it can be broken at least on Windows, even though it should be fine on top of X). So don't update the progress bar directly from the dive computer import code, instead just update the progress information in static variables, and let the GUI thread update it while it does the idle loop polling anyway. Reported-by: Jef Driesen <jefdriesen@telenet.be> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-09-20Fix yearly statistics after 64-bit time changesGravatar Miika Turkia
One of the "+1900" cases got incorrectly dropped. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> [ I really wanted the utc_mkdate/mktime functions to use proper years, rather than the idiotic "offset by 1900". However, we still mix things with "localtime()" in one place, so for now we have to be compatible with the insane tm_year semantics. - Linus ] Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-09-20Merge branch 'divetrip-rewrite' of git://github.com/torvalds/subsurfaceGravatar Linus Torvalds
Merge the dive trip rewrite by Dirk Hohndel. This just merges the dive trip changes with the timestamp handling changes. There were multiple small data conflicts, along with some newly added 'time_t' cases in the dive trip handling that needed to be converted to 'timestamp_t' along the way. * 'divetrip-rewrite' of git://github.com/torvalds/subsurface: Convert FIND_TRIP into function Partial rewrite of the dive trip code Check if trip is NULL before calling DIVE_TRIP
2012-09-20Merge branch 'time-function'Gravatar Linus Torvalds
Merge the 64-bit timestamp_t time function branch. This makes subsurface not only safe against the 2038-year problem, but also avoids the use of thread-unsafe gmtime() etc. We still use the system time_t for initializing the calendar widget for adding a new dive, but that's cosmetic rather than anything fundamental. * time-function: FIND_TRIP: don't cast a timestamp to a pointer dive-time widget: fix incorrect use of timestamp_t Fix the incorrect data type for DIVE_DATE accesses Use a 64-bit 'timestamp_t' for all timestamps, rather than 'time_t'
2012-09-20FIND_TRIP: don't cast a timestamp to a pointerGravatar Linus Torvalds
The pointer size may not be large enough to contain a timestamp, so make FIND_TRIP() just pass the pointer to the timestamp instead. And use an inline function instead of macros with casts. That gets us proper type safety while at it, so that we get a warning if somebody doesn't pass the expected "timestamp_t *". Plus the code actually looks simpler and way more straightforward. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-09-20dive-time widget: fix incorrect use of timestamp_tGravatar Linus Torvalds
I did a global search-and-replace to make all "time_t" users use the internal subsurface 64-bit "timestamp_t" type instead, but we have one case that still uses the system time functions: the use of "localtime()" in the dive_time_widget(). Everywhere else we always just use UTC for all our time handling, and we don't really ever care about the local timezone etc. However, for the dive time widget, we initialize the calendar widget to the current time, which obviously does want to take the local timezone into account, so there we end up using the whole system time handling code. So that one should continue to use time_t, even if it might have the year-2038 problem. We also don't care about the fact that it's not thread-safe, since this is just initializing the widget which definitely doesn't happen threaded. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-09-20Convert FIND_TRIP into functionGravatar Dirk Hohndel
This helps us deal with the issue that the g_list convenience functions don't allow us to easily compare 64bit values on 32bit architectures. And since these convenience functions are truly trivial in nature, it seemed easier to simply implement our own logic here. In the process I moved all the dive_trip_list helper functions into the same spot in divelist.c Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-19Fix the incorrect data type for DIVE_DATE accessesGravatar Linus Torvalds
This is the same bugfix that Lubomir did in the master branch, but now on top of the new 64-bit timestamp_t model. So now we also remove the comment about the year 2038 problem, because it's not true any more. We do all the date handling in a 64-bit integer. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-09-19Partial rewrite of the dive trip codeGravatar Dirk Hohndel
This introduces a new data structure for dive trips - reuseing the struct dive just got way too messy. The dive_trip_t datastructure now allows the code to remember if the trip was auto generated or if its time stamp changed when dives where added to the trip during auto generation. The algorithm also distinguishes between dives that were intentionally added to a trip (either in an XML file or by adding them to trip in the UI) and dives that were added to trips via autogen. Saving dives that were added to trips via autogen makes that assignment "intentional". With this partial rewrite several of the oddities of the old code should be resolved - especially turning autogen on and off again should get the divelist back to the previous stage. Also, when dives are merged during file open or import we now try to pick the correct tripflag (instead of just ignoring the tripflag completely and resetting it to TF_NONE by mistake). Finally, the dive trip debugging code got more verbose and is trying harder to detect issues at the earliest time possible. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-19Use long instead of int when retrieving DIVE_DATE via gtk_tree_model_getGravatar Lubomir I. Ivanov
The type of the DIVE_DATE field is G_TYPE_LONG, so when accessing it we have to pass gtk_tree_model_get() the proper "long *" pointer, rather than an int. On 64-bit platforms, passing a pointer to an int would otherwise result in randomly overwriting another four bytes of stack. Sadly, there are not much safety checks to warn if our passed variable to the vararg list is of the correct type, which is unlike gtk_tree_model_get_value(), which will report typed errors. This solves a bug that may potentially result in undefined behaviour on some x64 OS (e.g Ubuntu 12.04 x64). Reported-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-09-19Use a 64-bit 'timestamp_t' for all timestamps, rather than 'time_t'Gravatar Linus Torvalds
This makes the time type unambiguous, and we can use G_TYPE_INT64 for it in the divelist too. It also implements a portable (and thread-safe) "utc_mkdate()" function that acts kind of like gmtime_r(), but using the 64-bit timestamp_t. It matches our original "utc_mktime()". Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-09-19Check if trip is NULL before calling DIVE_TRIPGravatar Lubomir I. Ivanov
Other places have this check, but for this particular one a crash can be reproduced: ./subsurface ./dives/* log -> autogroup log -> autogroup Against d14932058f191de2a Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-18Fix some of the problems reported by cppcheckGravatar Dirk Hohndel
Thanks to Christian for running the static code analysis tool against subsurface... There were some false positives, a few style issues that I'll ignore for now, and two actual potential bugs. First: Don't check unsigned variables for < 0 This has been around for a while and we are lucky that while technically a bug it still works as expected. Passing a negative idx simply turns it into a very large unsigned integer which then fails the > dive_table.nr test. So it still gets a NULL returned. A bug? Yes. Critical? No. Mismatched allocation and free This is an actual bug that potentially could cause issues. We allocate memory with malloc and free it with g_free. Not good. Reported-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn@axis.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-18When deleting dives make sure that amount_selected stays consistentGravatar Dirk Hohndel
This could cause a crash if deleting the last dive and manually adding a new one. Reported-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-18Proper placement for the file menu separator lines in MacOSXGravatar Henrik Brautaset Aronsen
After Lubomir's latest changes to the File menu, the separator were a little off. Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-18Prevent dive_from_path from dereferencing invalid iterGravatar Dirk Hohndel
This fixes a bug that Lubomir reported in a different way from the patch that he providede; I believe this to be more generic. Reported-by: "Lubomir I. Ivanov" <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-18Call xmlCleanupParser only once - when we are done with libxmlGravatar Lubomir I. Ivanov
Calling xmlCleanupParser in parse-xml.c:parse_xml_buffer() caused massive memory corruption mostly affecting gtk's FileChooser dialogs and the application menu. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-18Cosmetic changes to the NSIS installer scriptGravatar Ivan Habunek
Removed redundant /oname settings when copying files. This is not required since the file name is not changed. Signed-off-by: Ivan Habunek <ivan.habunek@gmail.com>
2012-09-18Fixed permissions in NSIS installerGravatar Ivan Habunek
Windows Vista and later require admin privileges to install to the Program Files folder. Updated RequestExecutionLevel accordingly. Signed-off-by: Ivan Habunek <ivan.habunek@gmail.com>
2012-09-18Fixed a couple of memleaks in gtk-gui.c and info.cGravatar Lubomir I. Ivanov
Related to subsurface_default_filename() and g_path_get_basename(). Against 3835faa8fb02df8edb. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-18Added an entry "New" in the "File" menuGravatar Lubomir I. Ivanov
Currently doubles the functionality of "Close" (file_close). Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-18Fix crash when simply clicking OK in import dialogGravatar Dirk Hohndel
Since the GSList is now only created if the user enters the file selection dialog, opening the import dialog and then clicking OK without selecting either a dive computer or a file would cause a crash. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-18Generalized the "Import" dialog titleGravatar Lubomir I. Ivanov
Renamed the title of the "Import" dialog to "Import", as there are a couple of supported operations. Removed the "Import:" text in the dialog body. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-18Moved "Import" in a separate section in the "File" menuGravatar Lubomir I. Ivanov
Moved the entry bellow the standard file operations and above "Print". Also placed it between separators and added the GTK_STOCK_GO_BACK icon. Later on "Export" can be placed below "Import" using GTK_STOCK_GO_FORWARD. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-17Merge branch 'defaultfile'Gravatar Dirk Hohndel
By now the default file code seems quite matured, so in preparation for 2.0 we'll bring it back into master. I made a few small clean-ups during the merge, but the merge itself is very much straight forward. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-17Make sure dive info is displayed correctly at startGravatar Dirk Hohndel
Commit cdae2869d1dd ("Show the datafile name even with no dives") was a little too aggressive in making sure that we show the correct window title - we only should call show_dive_info(NULL) if there is indeed no dive in the dive table - otherwise we display empty dive info at program start. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-17Simplify code in file_open as we now only open one fileGravatar Dirk Hohndel
This doesn't change functionality - it's just pointless to loop over a list that is known to have only one element. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-17Don't close existing data file in file_open if user cancelsGravatar Dirk Hohndel
This logic seems to make much more sense - if the user hits 'OK' then the old file is closed and the new one openened. Otherwise, leave things unchanged. Reported-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-17Once again improve existing filename handlingGravatar Dirk Hohndel
Several potential problems. - we could end up dereferencing exiting_filename when it was NULL - we could free the default_filename by mistake - subsurface_default_filename always needs to return a copy of it - closing the existing file before opening a new one repopulated the existing_filename with the default filename - preventing the opened file to become the new existing filename Also, make existing filename a const char * and make file_open have the same sensible default folder behavior as the other file related functions. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-17Fix potential crash when importing divesGravatar Dirk Hohndel
If the last of the preexisting dives gets merged with a new dive we end up dereferencing a freed pointer. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-17Correctly deal with empty XML filesGravatar Dirk Hohndel
Previously we could end up with a bogus dive with all zero data in it. Adding dives/test24.xml to be able to test that we handle this case correctly. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-17Show the datafile name even with no divesGravatar Dirk Hohndel
That's especially useful if starting without a filename and without an existing default file - this way it's clear that Subsurface still considers itself synced with the default file. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-17Mark divelist unchanged after closing the datafileGravatar Dirk Hohndel
This seems rather obvious - I'm surprised I didn't notice it earlier. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-17Put creation of the file selector box filter into helper functionGravatar Dirk Hohndel
This avoids duplication of code. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-17Reimplement the GtkFileChooserButton for importGravatar Dirk Hohndel
One of the limitations of GtkFileChooserButton is that it only allows one file to be chosen (so that it can display that file name in the button after the file chooser dialog finishes). Since in the import dialog we never want to show the button with the filename(s) filled in but want to directly execute the import once files have been selected, I reimplemented the button to simply open a multi file chooser when clicked and to then run the import function if one or more file names were selected. This does appear to require some more code but gets us a much more useful and consistent implementation. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-17The Open menu entry should open just one fileGravatar Dirk Hohndel
The single file that is our new data file (and the file that we'll change if it was modified). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-17Move Import menu entry back to File menuGravatar Dirk Hohndel
This should make things more consistent, especially now that "Open" actually does just that and no longer behaves almost like "Import". The downside is that the import from a dive computer is now in the File menu as well and no longer in the Log menu, where Linus originally had moved it to in commit 3cace090989b. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-17File Open now closes the previous file, firstGravatar Dirk Hohndel
This is a pretty significant semantic change - Open used to act more like Import; you added more dives to the divelist. With this change it instead acts more like the traditional File->Open in that it closes the previous file, first. The diff hides the minimalistic nature of the change - it seemed cleaner to move the file_open function around than to do a forward declaration of file_close. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-17Display current filename in windows titleGravatar Dirk Hohndel
This seems to make sense since we have a pretty strong concept of the "active file" that we are working on. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-15Don't show an error if we can't load the default fileGravatar Dirk Hohndel
The user may not have created it, yet. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-14Changing Miika's code to avoid global iterGravatar Dirk Hohndel
Two things I disliked in Miika's code in commit cbb5bd125b03: Having an integer variable named "something_iter" with all the GtkTreeIter around was really confusing. And having the yearly_iter as a global variable instead of cleanly passing it around really seemed suboptimal. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-14Improving the yearly statistics codeGravatar Miika Turkia
This will update the yearly statistics window (if open) whenever there are changes to the dive list. I also added a check not to open multiple statistics windows. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Reworded commit message Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-13Make sure all parts of the edit dialogs are using current_dive / edit_diveGravatar Dirk Hohndel
While most of this problem was fixed in commit 18b3dca431a4 ("Fix a long standing bug when editing dives"), it turns out that I missed a couple of the equipment callbacks. In the corner case of having an empty divelist (where therefore current_dive == NULL) manually adding a dive and trying to add equipment (cylinder or weightsystem) to it would crash subsurface as we were trying to dereference current_dive. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>