After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 783136 - SpinButton::signal_input() should take a double& as the output parameter, not a double*
SpinButton::signal_input() should take a double& as the output parameter, not...
Status: RESOLVED FIXED
Product: gtkmm
Classification: Bindings
Component: general
3.89.x
Other All
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2017-05-26 19:30 UTC by Daniel Boles
Modified: 2017-06-05 07:45 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
SpinButton: Pass signal_input double&, not double* (1.52 KB, patch)
2017-05-26 19:31 UTC, Daniel Boles
committed Details | Review
convert_gtk.m4: Remove tautological conversions (971 bytes, patch)
2017-05-26 19:36 UTC, Daniel Boles
none Details | Review

Description Daniel Boles 2017-05-26 19:30:16 UTC
TSIA, patch on the way
Comment 1 Daniel Boles 2017-05-26 19:31:12 UTC
Created attachment 352668 [details] [review]
SpinButton: Pass signal_input double&, not double*

The double* argument is to store the converted value from the text in
the SpinButton, so there is always a target to write to. Therefore, to
correctly use C++ style, this should use a reference and not a pointer.
Comment 2 Daniel Boles 2017-05-26 19:36:06 UTC
Created attachment 352669 [details] [review]
convert_gtk.m4: Remove tautological conversions

char and gchar are equal, and therefore so are their pointers. There is
no purpose to defining conversions for these.
Comment 3 Kjell Ahlstedt 2017-06-02 17:20:13 UTC
Both patches look fine and quite obvious.

Though I don't think that gmmproc agrees with you that "therefore so are their
pointers". The m4 macros just compare text strings. They don't understand that
gchar** is equal to char** because gchar is equal to char. The conversions you
want to remove are unnecessary because of
  _EQUAL(gchar**,char**)
in glibmm/tools/m4/convert_glib.m4.
Comment 4 Daniel Boles 2017-06-02 17:23:20 UTC
That explains it - thanks.

Should I push the second patch, then? i.e. is it fine to rely on conversions from convert_glib, or do you tend to prefer explicitly having them in convert_gtk too, even if redundant?
Comment 5 Daniel Boles 2017-06-02 17:58:03 UTC
While we are thinking about updating the API here:

This function returns an int. The really valid values are:

 * 0 (false): input was not handled
 * 1 (true) : successful conversion
 * -1       : input error

Should there perhaps be a specific enum for this? Something like

class SpinButton {
[...]
  enum class InputResult {
    InputError = -1,
    NotHandled,
    Successful Conversion
  };
};

and then an m4 conversion back to int for GTK+ (assuming that would work)
Comment 6 Kjell Ahlstedt 2017-06-02 18:36:09 UTC
> is it fine to rely on conversions from convert_glib

Sure, that's why convert_glib.m4 and several other files are included in
convert_gdk.m4 and convert_gtk.m4. Gtkmm relies on m4 macros in glibmm, atkmm
and pangomm. You can push the second patch, if gmmproc can still generate all
the .h and .cc files. (I suppose it can.)
The first patch, of course, is only for the master branch, as it changes ABI
and API.

> Should there perhaps be a specific enum for this?
(the output value of signal_input()'s signal handlers)

Murray didn't quite like it at
https://mail.gnome.org/archives/gtkmm-list/2017-May/msg00045.html
unless it's added in gtk+. I tend to agree with him. We should only rarely add
enums that don't correspond to enums in gtk+.
Comment 7 Daniel Boles 2017-06-02 18:48:12 UTC
(In reply to Kjell Ahlstedt from comment #6)
> > is it fine to rely on conversions from convert_glib
> 
> Sure, that's why convert_glib.m4 and several other files are included in
> convert_gdk.m4 and convert_gtk.m4. Gtkmm relies on m4 macros in glibmm, atkmm
> and pangomm. You can push the second patch, if gmmproc can still generate all
> the .h and .cc files. (I suppose it can.)

Thanks. As for 3-22, I'll give it a try and see; I expect it to be fine.


> > Should there perhaps be a specific enum for this?
> (the output value of signal_input()'s signal handlers)
> 
> Murray didn't quite like it at
> https://mail.gnome.org/archives/gtkmm-list/2017-May/msg00045.html
> unless it's added in gtk+. I tend to agree with him. We should only rarely
> add
> enums that don't correspond to enums in gtk+.

Oh yeah, I forgot about that. Thank you! The reasoning makes sense. I'm asking in gtk+ whether they'll consider a patch for this; so far, it sounds like it's worth a try.
Comment 8 Daniel Boles 2017-06-03 09:55:11 UTC
(In reply to Kjell Ahlstedt from comment #6)
> > is it fine to rely on conversions from convert_glib
> 
> Sure, that's why convert_glib.m4 and several other files are included in
> convert_gdk.m4 and convert_gtk.m4. Gtkmm relies on m4 macros in glibmm, atkmm
> and pangomm. You can push the second patch, if gmmproc can still generate all
> the .h and .cc files. (I suppose it can.)

Most of the top of convert_gtk.m4 is a direct paste of convert_glib.m4. Would it be a good idea to remove that and just keep the stuff that gtkmm adds?
Comment 9 Kjell Ahlstedt 2017-06-04 13:25:09 UTC
With a little help from 'git blame' I found that some lines were copied from
convert_gtk.m4 to convert_glib.m4 by commit
https://git.gnome.org/browse/glibmm/commit/?id=ac5deb9dad49a2919aa7b5e1b4e50fba81b64c03
but they were not deleted from convert_gtk.m4. I see no reason why they should
be kept in convert_gtk.m4, except possibly for one of the copied lines:
  _EQUAL(GdkAtom,Gdk::Atom)
This line should not be in convert_glib.m4. If it shall exist at all, it shall
be in convert_gtk.m4 or convert_gdk.m4. But I doubt that there is a Gdk::Atom.
Comment 10 Daniel Boles 2017-06-04 13:50:09 UTC
Thanks again - I'll push the commit removing the redundant conversions to both branches, then the API change to master.

Indeed, at a quick glance, methods documented as returning Gdk::Atom actually return std::string or Glib::ustring, thanks to conversions in convert_glib.m4 - and removing that conversion from convert_gtk.m4 means both branches still build fine. So I guess that one can be dropped too.
Comment 11 Daniel Boles 2017-06-05 07:45:14 UTC
Pushed. Then I realised I should probably move the double* => double& conversion out of convert_gtk to convert_glib, right? If so, I can do that later on.