Commit Graph

16077 Commits

Author SHA1 Message Date
Philip Withnall
57d0ec57e4 docs: Clarify costs of using the generic GObject C closure marshaller
The libffi one is slower than type-specific generated ones, but is
generally better to use.

https://bugzilla.gnome.org/show_bug.cgi?id=744060
2015-08-21 15:15:53 +01:00
Philip Withnall
e57741791e docs: Port GObject concepts to use G_DECLARE_FINAL_TYPE
And G_DECLARE_INTERFACE.

https://bugzilla.gnome.org/show_bug.cgi?id=744060
2015-08-21 15:15:53 +01:00
Philip Withnall
ab9b52e69c docs: General cleanups and rewording in the GObject concepts docs
• Remove copies of function declarations from the explanation — if
   people want those, they can follow links to the reference manual.
 • Add markup to make C code more defined.
 • Remove use of first person and irrelevant name dropping.

https://bugzilla.gnome.org/show_bug.cgi?id=744060
2015-08-21 15:15:53 +01:00
Philip Withnall
a86ef242e4 docs: Link to the GObject how-to from the GType tutorial
So that first-time users don’t fall into the trap of reading about the
gory memory layout details of GType and GObject when all they wanted to
do was derive a class.

https://bugzilla.gnome.org/show_bug.cgi?id=744060
2015-08-21 15:15:53 +01:00
Philip Withnall
cd0d605b23 docs: Mention g_clear_object() in the GObject tutorial
As an alternative to g_object_unref().

https://bugzilla.gnome.org/show_bug.cgi?id=744060
2015-08-21 15:15:53 +01:00
Philip Withnall
f9410b1647 docs: Remove pointless copy of GObject headers from tutorial
Remove a copy of the refcounting functions from gobject.h from the
GObject tutorial. It suffices to link to the functions in the API
reference.

https://bugzilla.gnome.org/show_bug.cgi?id=744060
2015-08-21 15:15:53 +01:00
Philip Withnall
92f6325509 docs: Miscellaneous formatting and wording fixes to GObject tutorial
Convert a few sections to use the passive voice, and add some more
<function> elements.

https://bugzilla.gnome.org/show_bug.cgi?id=744060
2015-08-21 15:15:53 +01:00
Philip Withnall
2aade94fcc docs: Update code examples in GObject tutorial
Use G_DECLARE_FINAL_TYPE, simplify property handling, and remove some
unnecessary braces.

https://bugzilla.gnome.org/show_bug.cgi?id=744060
2015-08-21 15:15:53 +01:00
Philip Withnall
42baaa88cd docs: Use generic marshallers in GObject how-to examples
They’re the new vogue for handling signals.

https://bugzilla.gnome.org/show_bug.cgi?id=744060
2015-08-21 15:15:53 +01:00
Philip Withnall
01962b4dd1 docs: Rename a parameter in a GObject how-to example
Make it obvious the parameter is not related to AClass.

https://bugzilla.gnome.org/show_bug.cgi?id=744060
2015-08-21 15:15:52 +01:00
Philip Withnall
a76242b35a docs: Add vfunc NULL checks to GObject how-to examples
Not setting a pure vfunc is a programmer error, so can be handled with a
g_return_if_fail() rather than needing a g_warning().

https://bugzilla.gnome.org/show_bug.cgi?id=744060
2015-08-21 15:15:52 +01:00
Philip Withnall
82abb80553 docs: Update interfaces in GObject how-to examples
Use G_DECLARE_INTERFACE and G_DEFINE_INTERFACE. Fix a couple of typos.
Add some comments to empty functions to make it obvious they’re
intentionally empty.

https://bugzilla.gnome.org/show_bug.cgi?id=744060
2015-08-21 15:15:52 +01:00
Philip Withnall
ffc248919b docs: Update instance private data in GObject how-to examples
Use get_instance_private().

https://bugzilla.gnome.org/show_bug.cgi?id=744060
2015-08-21 15:15:52 +01:00
Philip Withnall
b88ac15e65 docs: Update property handling in GObject how-to examples
Be a bit more consistent about property enum numbering.

https://bugzilla.gnome.org/show_bug.cgi?id=744060
2015-08-21 15:15:19 +01:00
Philip Withnall
2e4700d52b docs: Various wording changes in the GObject how-to
• Consistently make all titles sentence case
 • Fix various typos
 • Remove an unnecessary footnote
 • Remove first person phrasing

https://bugzilla.gnome.org/show_bug.cgi?id=744060
2015-08-21 15:15:19 +01:00
Philip Withnall
f1287a9b2f docs: Remove commented out sections from GObject how-to
Unused, outdated, and unsalvagable.

https://bugzilla.gnome.org/show_bug.cgi?id=744060
2015-08-21 15:15:19 +01:00
Philip Withnall
0344e6cb83 docs: Add missing <function> elements to GObject how-to
Break the text up a little with some formatting.

https://bugzilla.gnome.org/show_bug.cgi?id=744060
2015-08-21 15:15:19 +01:00
Philip Withnall
b6b0f5f305 docs: Update GObject how-to for G_DECLARE_*_TYPE macros
Restructure the section of the how-to which covers the header and source
code boilerplate for declaring and defining GObjects to use the new
G_DECLARE_*_TYPE macros. Present both final and derivable types.

Trim various supporting paragraphs.

Rename ‘class functions’ to ‘virtual functions’ to use consistent,
modern terminology.

https://bugzilla.gnome.org/show_bug.cgi?id=744060
2015-08-21 15:15:19 +01:00
Ryan Lortie
b6fc1df022 GLocalFileInfo: don't content-sniff zero-length files
This will prevent attempting to read from some files that appear normal but are
really device-like, such as those in /proc and /sys.

If we can't stat() the file then don't bother attempting to sniff, either.

https://bugzilla.gnome.org/show_bug.cgi?id=708525
2015-08-21 01:00:49 -04:00
Ting-Wei Lan
8f662e7259 glocalfileinfo: Support file creation time on FreeBSD and NetBSD
FreeBSD and NetBSD have field st_birthtim and st_birthtime in struct stat,
respectively, which can be used to get file creation time on supported file
systems such as UFS2 and tmpfs.

https://bugzilla.gnome.org/show_bug.cgi?id=749492
2015-08-21 00:52:50 -04:00
Christophe Fergeau
60a6ae6f0b Fix GError leak in g_file_query_writable_namespaces()
gvfs commit b358ca "Make sure metadata is always returned by
query_writable_namespaces()" changed the
query_writable_namespaces vfunc to never return NULL, but the error
checking in g_daemon_file_query_writable_namespaces still assumes vfunc
failure implies NULL return value and GError set. This causes a memory
leak as on failure the GError will be set but the vfunc implementation
will have created its own default list so NULL will not be returned, and
the GError will never be cleared.

This commit directly checks if the GError is set to detect failures,
my_error is directly dereferenced in the error block anyway.

This also removes an unneeded call to g_file_attribute_info_new(); as
the vfunc always returns us a non-NULL GFileAttributeInfoList.

https://bugzilla.gnome.org/show_bug.cgi?id=747364
2015-08-21 00:45:00 -04:00
Matthias Clasen
fa17536598 Code cleanup 2015-08-21 00:43:54 -04:00
Matthias Clasen
b67dac56e3 Add a test for cross dir moves
This is a test that is described in

https://bugzilla.gnome.org/show_bug.cgi?id=742849
2015-08-21 00:41:09 -04:00
Matthias Clasen
3498f29b81 Test resource filesystem attributes 2015-08-21 00:08:57 -04:00
Matthias Clasen
d942c64267 resource file: Return some filesystem info
We now return "resource" as the filesystem type, and state
that the filesystem if readonly.
2015-08-21 00:01:12 -04:00
Matthias Clasen
1bfdcc8499 resource file: Add a dummy file monitor
This avoids the fallback to polling in GFile, which is unnecessarily
expensive for a resource which can never change.
2015-08-20 23:48:51 -04:00
Matthias Clasen
b995c08bf3 Remove unused files
We no longer have GLocalDirectoryMonitor implementations.
These files were not included in the build for a while now.
2015-08-20 22:31:41 -04:00
Matthias Clasen
d66e3f57cd Add more directory monitoring tests
These tests clear up a misunderstanding of mine: Monitoring
nonexisting files and directories *does* work with the inotify
implementation, it just has a very long timeout for scanning
for missing locations, so the test needs to take that into
account.
2015-08-20 22:30:19 -04:00
Matthias Clasen
ee31d492d8 poll file monitor: Don't reimplement g_strcmp0
We have that function now, so use it.
2015-08-20 21:10:49 -04:00
Matthias Clasen
09b618f0a1 Avoid a false deprecation
gtk-doc misinterprets this comment and marks
g_find_program_in_path as deprecated, which it isn't.
2015-08-20 20:20:48 -04:00
Debarshi Ray
fa0f51ddf8 fileinfo: Add a G_FILE_ATTRIBUTE_STANDARD_IS_VOLATILE attribute
This is meant for opaque, non-POSIX-like backends to indicate that the
URI is not persistent. Applications should look at
G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET for the persistent URI.
Examples of such backends could be a portal for letting sandboxed
applications access the file-system, or a database-backed storage like
Google Drive.

In these cases, the user visible file and folder names are different
from the real identifiers, used by the backend. So, a request to
create google-drive://user@gmail.com/foo/New\ File, would actually
lead to google-drive://user@gmail.com/foo/bar on the server even though
the user visible name is still "New File". Since the server-defined URI
is persistent and sanity-checked by the backend, it is recommended that
applications switch to it as soon as possible. Backends will try to
keep a mapping from "fake" to "real" URIs, but those are only on a
best effort basis. They might not be persistent or have the same
guarantees as the "real" URIs.

https://bugzilla.gnome.org/show_bug.cgi?id=741602
2015-08-20 18:40:02 +02:00
Matthias Clasen
4a076032cf More file monitor tests
Test regular writes and attribute changes with a file monitor,
as well as various file changes under a directory monitor.
2015-08-19 20:33:46 -04:00
Matthias Clasen
b8aad73af9 2.45.6 2015-08-19 16:24:22 -04:00
Dan Winship
8d8a1c205b fix previous 2015-08-19 16:21:46 -04:00
Dan Winship
c686245141 gdbus: don't warn when returning a value on a closed connection
g_dbus_method_invocation_return_value(), etc, don't have GError
parameters (which makes sense since they won't usually return errors,
and there's not much you could do if they did), so in the rare case
when something does go wrong, they print a warning.

However, there is at least one situation where the warning is a bad
idea: if you are using private bus connections, and a client connects,
makes a request, and then disconnects before getting the response.
Given that there's nothing the caller can do to prevent this case from
getting hit (since the client might not disconnect until after the
call to g_dbus_method_invocation_return_value() starts) and given that
the server can never actually know for sure that the client has
received the response (it might disconnect after reading the response,
but before processing it), just kill the warning in this case.

https://bugzilla.gnome.org/show_bug.cgi?id=753839
2015-08-19 16:08:48 -04:00
Matthias Clasen
fc38156cba 2.45.5 2015-08-19 15:46:49 -04:00
Dan Winship
656494a784 gpermission: fix async error returns
a8eedd00 broke the error return values from
g_permission_acquire/release_async() on GSimplePermission. Fix that.
2015-08-19 15:45:11 -04:00
Matthias Clasen
8c32f7c448 Add some file monitoring tests
Add a new test which checks that atomically replacing a file that
is being monitored by GFileMonitor produced the expected events.

The test can easily be expanded to cover other file monitoring
scenarios.
2015-08-19 14:57:53 -04:00
Matthias Clasen
ac78d14125 inotify: Fix handling of paired events for atomic replace
After the big file monitoring rewrite, we only put the IN_MOVED_FROM event
in the queue for such pairs. It matches INOTIFY_DIR_MASK and thus we call
ip_dispatch_event on it, but that function was filtering it out because
the filename in the 'from' event is the one of the temp file, not the
one we are monitoring. That name is in the 'to' event, so compare it as
well, and let the event passin that case.

There is another instance of this check in glocalfilemonitor.c, which is
corrected here as well.

https://bugzilla.gnome.org/show_bug.cgi?id=751358
2015-08-19 14:57:53 -04:00
Daniel Mustieles
780b48c4cd Updated Spanish translation 2015-08-19 20:35:38 +02:00
Philip Withnall
5a642651c7 gmessages: Mention g_return_if_fail() in g_warning() and g_error() docs
It seems to be common for people to use g_warning() or g_error() as pre-
and post-condition error reporting functions, which is not really what
they’re intended for. Similarly, it is generally a sign of bad API
design to use g_warning() to report errors — use GError instead.

Try and suggest this to the user in the hope that nice code results.

https://bugzilla.gnome.org/show_bug.cgi?id=741779
2015-08-19 12:56:38 +01:00
Philip Withnall
ef1ba452b3 gsignal: Document memory management best practices for signal handlers
It’s quite common to see naked g_signal_connect() calls without a paired
g_signal_handler_disconnect(). This is commonly a bug which could lead
to uses of the callback user data after it’s been freed.

Document the best practices for avoiding this kind of bug by properly
disconnecting all signal handlers.

https://bugzilla.gnome.org/show_bug.cgi?id=741779
2015-08-19 12:56:38 +01:00
Philip Withnall
db8455f07d gmain: Document memory management best practices for GSources
It’s very common to see code where a timeout is scheduled using
g_timeout_add(), yet the owning object could be destroyed shortly
afterwards, before the timeout is fired, leading to use-after-free.

Try and prevent this happening with new code by documenting best
practices for memory management of user data for GSource callbacks.

https://bugzilla.gnome.org/show_bug.cgi?id=741779
2015-08-19 12:56:38 +01:00
Philip Withnall
c5cd1c5f02 gobject: Add cross-links from GObject reference docs to tutorials
Add some brief links from the GObject reference documentation to the
existing tutorial and overview sections on GObjects.

https://bugzilla.gnome.org/show_bug.cgi?id=743018
2015-08-19 12:54:50 +01:00
Philip Withnall
9874fe3c40 gobject: Cross-link from GType reference docs to GType conventions page
Make it a little easier to find the GType conventions page, which I
guess should be the canonical guide to how to name things.

This adds a brief mention of the valid characters in a type name to the
conventions page.

https://bugzilla.gnome.org/show_bug.cgi?id=743018
2015-08-19 12:54:50 +01:00
Dušan Kazik
10f96a914d Updated Slovak translation 2015-08-19 10:59:44 +00:00
Philip Withnall
d624bf4e66 gthread: Suggest using *_async() functions instead of threads
It’s unfortunately common to see worker threads being spawned all over
the place to do operations which could be brought into the main thread
with an async call, simplifying everything.

https://bugzilla.gnome.org/show_bug.cgi?id=741779
2015-08-19 11:38:55 +01:00
Philip Withnall
5ee333e4cb gstrfuncs: Add a string formatting note about using G_GUINT64_FORMAT
…and friends. The ‘String precision pitfalls’ section is already linked
to from all the relevant printf()-style functions, so this documentation
should hopefully be easy to find.

https://bugzilla.gnome.org/show_bug.cgi?id=741779
2015-08-19 11:36:43 +01:00
Philip Withnall
8c858a018d gvariant: Clarify that nullable strings should use maybe types
Otherwise people might try to encode a NULL string as "NULL". I’m not
even kidding.

https://bugzilla.gnome.org/show_bug.cgi?id=741779
2015-08-19 11:36:43 +01:00
Janusz Lewandowski
5d014a802a Add a g_dbus_connection_register_object_with_closures function
This is a binding-friendly version of g_dbus_connection_register_object.
Based on a patch by Martin Pitt and the code of g_bus_watch_name_with_closures.

https://bugzilla.gnome.org/show_bug.cgi?id=656325
2015-08-18 16:41:12 -04:00