Commit graph

3843 commits

Author SHA1 Message Date
Bertrand Lorentz 859832f6e4 Merge pull request #89 from knocte/master
glib: fix IntPtr.Zero being dereferenced in GLib.Value.ToBoxed()
2013-11-09 08:08:40 -08:00
Bertrand Lorentz e48ac63d54 generator: Dispose ownable method parameters in VM callback (bxc#237)
Some virtual methods are passed a native object that is wrapped in an
IDisposable managed object, which is then passed on to the managed
overrides. We need to dispose those objects as soon as possible,
otherwise their native counterpart will not be freed until the next
garbage collection. Requiring the overrides to dispose them would be
cumbersome and error-prone.

Those parameters will now be disposed in a finally {...} block, after
the virtual method has returned. This means that overrides should not
keep a reference to such a parameter outside of the scope of the method,
as it will be diposed when the method returns.

This change only affects Cairo.Context parameter for now, but it was
particularly needed for them, as they could happily hold on to tens of
MBs of memory until the next garbage collection.
2013-11-09 16:26:17 +01:00
Andrés G. Aragoneses 2967482762 Revert "gtk: Mark the Cairo.Context in Widget.Drawn as owned"
This reverts commit 21bfaa7a9d.

After fixing the memory leak when finalizing a Context object in the
previous commit, native crashes would happen when using a Gtk#-based
app. The reason is that this commit tried to fix the leak with the wrong
approach of marking the CairoContext as owned. This avoided the leak by
not incrementing the reference count, but now that the leak is fixed,
cairo_destroy is called one time too much.

The CairoContext passed in the Draw signal is not marked as
transfer-ownership=full in GObject-Introspection metadata. So unmarking
this as owned fixes the "potential double-free" assertion that was
causing the crash.
2013-11-03 17:01:34 +01:00
Andrés G. Aragoneses 53e884dd22 gtk: fix Application to be more robust when embedding mono
When embedding mono, Environment.GetCommandLineArgs() would not return
an array with any element.

Reported in the mailing list, by Vardar Sahin.
2013-11-03 16:11:42 +01:00
Andrés G. Aragoneses 41eeecbf9a cairo: fix leak when Context object is finalized
When the finalizer calls Dispose(), disposing is false, it means that
CairoDebug traces should be printed, but the reference count on the
native context should still be decreased. Otherwise a real leak
would appear, as the native context would never be freed when the
managed object is GCed.
2013-11-03 15:21:49 +01:00
Bertrand Lorentz fc9746013d gtk: Fix TreeView.GetTooltipContext method signature (bxc#14678)
The x and y parameters of gtk_tree_view_get_tooltip_context() are marked
as inout in the Gtk+ docs, so we need to mark them as ref.
2013-11-03 14:42:39 +01:00
Stephan Sundermann cfdbb3b9a7 glib: fix IntPtr.Zero being dereferenced in GLib.Value.ToBoxed() 2013-11-02 16:52:25 +01:00
Bertrand Lorentz 0d781f485f gio: Delete DBusInterfaceVTable class
It was never included in the build, and never modified since it was
first created.
2013-11-02 15:53:29 +01:00
Andrés G. Aragoneses 10546e2ffa MSBuild: fix the solution build (except audit and sample projects)
This commit makes it possible to build any project of the gtk-sharp.sln
from an IDE (except audit and sample projects, which require a bit more
work).

This doesn't mean that autotools is deprecated, but just that it is more
comfortable to use an IDE when working on gtk-sharp because it will
offer better auto-completion, and will stop highlight misleading
semantic errors, from now on.
2013-11-02 15:48:58 +01:00
Andrés G. Aragoneses efdf6463bb Simplify instructions about choosing the installation prefix
Clarify the README thanks to the use of pkg-config, and add a
configure-time warning so people notice about the problem without having
to read the README.
2013-11-02 15:33:31 +01:00
Lluis Sanchez 78fd18e0b7 Merge pull request #88 from knocte/guithreadcheck_whitelist
gui-thread-check: add two more methods to the whitelist
2013-10-31 02:22:31 -07:00
Andrés G. Aragoneses 7dafb39c01 gui-thread-check: add two more methods to the whitelist
At application shutdown, it's very likely to be spammed by
gui-thread-check with a river of:

*** GTK CALL NOT IN GUI THREAD: Widget.Dispose
*** GTK CALL NOT IN GUI THREAD: Widget.remove_InternalDestroyed
*** GTK CALL NOT IN GUI THREAD: Widget.Dispose
*** GTK CALL NOT IN GUI THREAD: Widget.remove_InternalDestroyed
...

From what I gather, these two methods (in gtk-sharp master[1]) could
be called by the finalizers, but do not call any unmanaged functions,
so it should be ok to not report them as violations.

[1] https://github.com/mono/gtk-sharp/blob/master/gtk/Widget.cs

Cherry-picked from 77a40599ca
2013-10-31 10:18:02 +01:00
Lluis Sanchez 68c64bedc0 Merge pull request #87 from knocte/guithreadcheck_fflush
gui-thread-check: use fflush() after printf()
2013-10-30 11:14:21 -07:00
Andrés G. Aragoneses dcc2850a39 gui-thread-check: use fflush() after printf()
Using fflush() right away after printf() calls avoids the buffers to
be written in an apparently complete-out-of-sync way from the point
of view of the developer. This problem would specially occur when
redirecting all output to a file this way:

  mono Foo.exe > out.txt 2>&1

Without this fix, all the output from gui-thread-check would appear
at the end of the file, instead of in between the output generated by
the program.

Cherry-picked from 6988cd4cd2
2013-10-28 21:57:29 +01:00
Bertrand Lorentz 21ef50ec48 Merge pull request #83 from knocte/msbuild_tweaks
Various tweaks and updates to the .csproj files
2013-10-22 12:55:30 -07:00
Bertrand Lorentz bd9cde5e61 Merge pull request #82 from knocte/cleanup
Various small cleanups in generator and glib
2013-10-22 12:52:08 -07:00
Bertrand Lorentz a4c42994e8 Merge pull request #81 from knocte/properties_class_init
glib: install properties before class_init finishes
2013-10-22 12:34:45 -07:00
Andrés G. Aragoneses 8eca15e8bd glib: fix warning
`t` was not being used.
2013-10-22 14:06:12 +02:00
Andrés G. Aragoneses 3a45406665 glib: include recent files committed in master to the MSBuild csproj 2013-10-22 12:34:08 +02:00
Andrés G. Aragoneses 5ce4e63bd9 gtk: reference Cairo in MSBuild csproj 2013-10-22 12:33:24 +02:00
Andrés G. Aragoneses 6f2d80eab0 gdk: enable Unsafe in MSBuild 2013-10-22 12:33:06 +02:00
Andrés G. Aragoneses f9f654a06a generator: add reference to System.Core in the MSBuild csproj
Extension methods (such as the one we have in XmlElementExtensions.cs)
need to link to System.Runtime.CompilerServices.ExtensionAttribute
class in order to compile. In .NET 3.5, this was part of System.Core
(not mscorlib like in .NET 4.5) [1], so we need to link to it in order
to compile via MSBuild.

[1] http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.extensionattribute%28v=vs.90%29.aspx
2013-10-22 12:17:50 +02:00
Andrés G. Aragoneses 077836a227 generator: fix AssemblyName in MSBuild csproj
To be the same as what is generated via Makefiles.
2013-10-22 12:17:44 +02:00
Andrés G. Aragoneses 5600b2cb29 gio: update MSBuild csproj file to account for recent changes 2013-10-22 12:17:38 +02:00
Bertrand Lorentz 2022141ddd Merge pull request #80 from knocte/master
atk: add metadata fixup to avoid crash due to ABI break
2013-10-22 02:38:47 -07:00
Andrés G. Aragoneses 516fc1d9f0 generator: leverage framework's String.IsNullOrEmpty() call
This makes the code a bit more readable and it is a
micro-optimization.
2013-10-21 17:13:31 +02:00
Andrés G. Aragoneses fcc775d658 generator: drop unneeded parameter in WriteLine() call 2013-10-21 17:10:11 +02:00
Andrés G. Aragoneses b13d51a32d generator: simplify bool logic in Method class
There are two elements repeated in this expression:

(( ((A) || (B)) || (B)) && C)

We can simplify "(A || B) || B" to simply "A || B",
so the result is a bit more readable this way:

(A || B) && C
2013-10-21 17:09:40 +02:00
Andrés G. Aragoneses e9d5d1803d glib: install properties before class_init finishes
Recently glib started to warn about the future deprecation of adding
interfaces after class_init, which we fixed here [1].

Now, a similar warning has started to happen for the addition of
properties, example:

(Nereid:23225): GLib-GObject-WARNING **: Attempt to add property __gtksharp_33_Banshee_Widgets_TileView::gtk-sharp-managed-instance after class was initialised

So we need to add them before class_init finishes too, and this
change makes it this way.

[1] 9ff7ec8b2c
2013-10-21 00:37:29 +02:00
Stephan Sundermann 31ed6cc6a9 atk: add metadata fixup to avoid crash due to ABI break
The ABI of ATK has been broken recently [1], so the best way
to deal with this is removing the pads from all the interfaces
found by GAPI in the atk namespace.

This avoids that some mono-based apps crash with new version
of Atk (i.e. 2.10.0, the one that Ubuntu 13.10 ships), and
still works for older versions (i.e. 2.8.0, the one that
Ubuntu 13.04 ships).

[1] https://git.gnome.org/browse/atk/commit/?id=b1f70e81ef1d7287dcb2cafa9a115ff5752ece55
2013-10-18 11:30:13 +02:00
Andrés G. Aragoneses 8b998861e1 Convert some dynamic casts to static casts
There is no null check after these casts so if they fail they would
generate a NullReferenceException. By changing them to static casts
we would get a InvalidCastException which are much less misleading.
2013-10-13 19:10:03 +02:00
Bertrand Lorentz b2fb84d14b Clean up .gitignore files 2013-10-13 18:38:33 +02:00
Andrés G. Aragoneses b15f2eede1 generator: provide a GType static property for adapters
In the same way all GLib.Object-derived classes provided by the
generator have a GType static property (i.e. Gtk.Widget), we need
the same for the *Adapter classes, to access their GType without having
an instance of it. (The first use case would be GStreamerSharp's
Gst.Bin.IterateAllByInterface ().)

For this, we cannot simply add the property to all adapter classes
and be done, because it would clash with a property which is already
there, but is non-static, that has the same name and same value
(this property is needed for complying GInterfaceAdapter abstract
class), so we rename this property to GInterfaceGType because
using this name for the static one would not be consistent with the
rest of the classes generated which already provide the static one
with the name "GType".
2013-10-13 17:45:09 +02:00
Andrés G. Aragoneses ea07082952 generator: avoid another Implementor suffix hardcode
This "Implementor" suffix was refactored recently (in commit
6cb03440c1) to be accessed via the ImplementorName property. So we
eliminate now the last occurrence of it in hardcoded form.
2013-10-13 17:20:37 +02:00
Andrés G. Aragoneses 634f9e5f27 generator: add a link to the README from the project
This way people who work on the generator using an IDE will see the file
2013-10-13 17:05:41 +02:00
Bertrand Lorentz 2d83fb3073 Move the fixup tool from the parser to the generator folder
The parser will be going away at some point in the future, but we
will still need the fixup step. And the fixup step is really more
of a preliminary step for the generator anyway.
2013-10-13 17:04:56 +02:00
Bertrand Lorentz ac9da8d4aa gio: Fix up first ApplicationFlags enum to be None instead of FlagsNone 2013-10-13 15:44:59 +02:00
Stephan Sundermann 72b51cc712 generator: Implement attribute to hide method parameters
A hidden parameter is dropped from the signature and the default value is filled in.
2013-10-11 23:36:20 +02:00
Stephan Sundermann 8e307d8eaa generator: Remove redundant class name from method name
If you move a global method to a class, you often end up with something
like Tag.TagExists(). This will now be automatically renamed to
Tag.Exists().
2013-10-11 23:03:53 +02:00
Bertrand Lorentz 68780a6226 gio: Fix up returns type for several GSettings methods 2013-10-11 22:32:46 +02:00
Bertrand Lorentz c83c196150 Merge pull request #73 from xDarkice/master
GLib.Object: Fix FindClassProperty method
2013-10-11 02:21:18 -07:00
Stephan Sundermann f978c8f705 GLib.Object: Fixed FindClassProperty
g_object_class_find_property takes a GObjectClass which can be retrieved by
reading an IntPtr from the GObject's Handle
2013-10-11 11:13:08 +02:00
Bertrand Lorentz 9b9512a3ce generator: Remove unused variables in NativeStructGen 2013-10-10 23:47:12 +02:00
Bertrand Lorentz 741360020c generator: Remove unused variable in FieldBase class 2013-10-10 23:44:24 +02:00
Bertrand Lorentz 46068e7add generator: Remove unused field in Constant class 2013-10-10 23:43:55 +02:00
Bertrand Lorentz 57938c321e generator: Add missing copyright headers in files added by Stephan 2013-10-10 23:38:03 +02:00
Bertrand Lorentz 46cd80aea0 Merge pull request #72 from knocte/bindinator
glib: fix FindClassProperty()'s copy-paste error
2013-10-10 13:51:10 -07:00
Andrés G. Aragoneses 7d75adf68c glib: fix FindClassProperty()'s copy-paste error
The implementation of FindClassProperty() was the same as the
implementation of FindInterfaceProperty(), both receiving an iface
instead of a GObjectClass* [1].

The reason of this oversight can well be explained by the fact that
FindClassProperty() is private and not used, actually. However, we
may need it soonish as a good bind to g_object_class_find_property.

[1] https://developer.gnome.org/gobject/unstable/gobject-The-Base-Object-Type.html#g-object-class-find-property
2013-10-10 20:25:23 +02:00
Bertrand Lorentz 5f8e0953cf gtk: Use native function for GtkTextIter.Equals(GtkTextIter)
As GtkTextIter has no public properties, the default generated Equals
implementation would be "return true;". We now suppress that and with a
fix-up now use the native gtk_text_iter_equal to implement the Equals
method.
2013-10-10 16:28:37 +02:00
Bertrand Lorentz bc498ff650 generator: Add support for suppressing the Equals(T) method in structs
Similarly to what exists for GetHashCode, add a noequals attribute to
indicate we don't want the default Equals implementation.
2013-10-10 16:27:13 +02:00