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 770541 - Build Failure against GNOME 3.21.x
Build Failure against GNOME 3.21.x
Status: RESOLVED FIXED
Product: gnote
Classification: Applications
Component: build
3.21.x
Other Linux
: Normal normal
: ---
Assigned To: gnote-maint
gnote-maint
Depends on:
Blocks:
 
 
Reported: 2016-08-29 10:23 UTC by Dominique Leuenberger
Modified: 2016-09-07 09:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix build (it's rather crude - but so far in my tests seems to work) (10.27 KB, patch)
2016-08-31 20:19 UTC, Dominique Leuenberger
rejected Details | Review
Changes the if (m_buffer) return true; else return false; constructs to (10.03 KB, patch)
2016-08-31 20:59 UTC, Dominique Leuenberger
committed Details | Review

Description Dominique Leuenberger 2016-08-29 10:23:41 UTC
GNOTE 3.21.0 fails to build on the openSUSE BuildService in the GNOME 3.21.x staging project:

[   97s]   CXX      backlinksnoteaddin.lo
[   97s]   ITMRG  backlinks.desktop
[   99s] In file included from ../../../src/noteaddin.hpp:38:0,
[   99s]                  from backlinksnoteaddin.hpp:27,
[   99s]                  from backlinksnoteaddin.cpp:25:
[   99s] ../../../src/note.hpp: In member function 'bool gnote::Note::has_buffer() const':
[   99s] ../../../src/note.hpp:127:14: error: cannot convert 'const Glib::RefPtr<gnote::NoteBuffer>' to 'bool' in return
[   99s]        return m_buffer;
[   99s]               ^~~~~~~~
[   99s] ../../../src/note.hpp: In member function 'bool gnote::Note::is_loaded() const':
[   99s] ../../../src/note.hpp:142:23: error: cannot convert 'const Glib::RefPtr<gnote::NoteBuffer>' to 'bool' in return
[   99s]        return (m_buffer);
[   99s]                        ^
[  100s] make[4]: *** [Makefile:534: backlinksnoteaddin.lo] Error 1
[  100s] make[4]: Leaving directory '/home/abuild/rpmbuild/BUILD/gnote-3.21.0/src/addins/backlinks'
[  100s] make[3]: *** [Makefile:452: all-recursive] Error 1
[  100s] make[3]: Leaving directory '/home/abuild/rpmbuild/BUILD/gnote-3.21.0/src/addins'
[  100s] make[2]: *** [Makefile:1391: all-recursive] Error 1
[  100s] make[2]: Leaving directory '/home/abuild/rpmbuild/BUILD/gnote-3.21.0/src'
[  100s] make[1]: *** [Makefile:485: all-recursive] Error 1
[  100s] make[1]: Leaving directory '/home/abuild/rpmbuild/BUILD/gnote-3.21.0'
[  100s] make: *** [Makefile:417: all] Error 2
Comment 1 Dominique Leuenberger 2016-08-31 19:56:56 UTC
CCing Murray - the changes in glibmm seem to be responsible here

Things the no longer works:


Glib::RefPtr<NoteBuffer> m_buffer;

  bool has_buffer() const
    {
      return m_buffer; /* implicit conversion to bool /*
    }

This is likely a side effect of https://git.gnome.org/browse/glibmm/commit/?id=aee3a6fa6a37e1178b43437966b4225a34f9c6e2

what works (but is ugly):

Glib::RefPtr<NoteBuffer> m_buffer;

  bool has_buffer() const
    {
      if (m_buffer) return true; else return false; /* explicit conversion to bool /*
    }


There are a couple similar things like failing furher down in the build of gnote, where
this fails:

  gnote::DepthNoteTag::Ptr depth = get_buffer()->find_depth_tag(p_start);
  if(depth != 0) {
    /* do stuff *?
  }
Comment 2 Dominique Leuenberger 2016-08-31 20:00:11 UTC
notewindow.cpp:207:29: error: no match for ‘operator!=’ (operand types are ‘Glib::RefPtr<Gdk::Window>’ and ‘int’)
     if(parent->get_window() != 0


According to the unstable doc, this should still be valid:

https://developer.gnome.org/glibmm/unstable/classGlib_1_1RefPtr.html#ade68fc2a3cdb54e51b0f136aee95c074
Comment 3 Dominique Leuenberger 2016-08-31 20:19:57 UTC
Created attachment 334553 [details] [review]
Fix build (it's rather crude - but so far in my tests seems to work)

has_buffer and is_loaded both expect to return a bool, so returning
plain m_buffer won't cut it

Fixes build error

[   89s] In file included from ../../../src/noteaddin.hpp:38:0,
[   89s]                  from backlinksnoteaddin.hpp:27,
[   89s]                  from backlinksnoteaddin.cpp:25:
[   89s] ../../../src/note.hpp: In member function 'bool gnote::Note::has_buffer() const':
[   89s] ../../../src/note.hpp:127:14: error: cannot convert 'const Glib::RefPtr<gnote::NoteBuffer>' to 'bool' in return
[   89s]        return m_buffer;
[   89s]               ^~~~~~~~
[   89s] ../../../src/note.hpp: In member function 'bool gnote::Note::is_loaded() const':
[   89s] ../../../src/note.hpp:142:23: error: cannot convert 'const Glib::RefPtr<gnote::NoteBuffer>' to 'bool' in return
[   89s]        return (m_buffer);
Comment 4 Murray Cumming 2016-08-31 20:38:14 UTC
This is intentional. You really shouldn't be relying on implicit conversions to bool, or to an int. I guess that a simple explicit (bool) will do what you want. For instance:

 bool has_buffer() const
 {
   return (bool)m_buffer;
 }
Comment 5 Dominique Leuenberger 2016-08-31 20:49:38 UTC
(In reply to Murray Cumming from comment #4)
> This is intentional. You really shouldn't be relying on implicit conversions
> to bool, or to an int. I guess that a simple explicit (bool) will do what
> you want. For instance:
> 
>  bool has_buffer() const
>  {
>    return (bool)m_buffer;
>  }

For the bool case that indeed works (and is a bit nice that whatever I wrote) - will update the patch and re-attach
Comment 6 Dominique Leuenberger 2016-08-31 20:59:23 UTC
Created attachment 334559 [details] [review]
Changes the if (m_buffer) return true; else return false; constructs to

return (bool)m_buffer;

much cleaner again
Comment 7 Kjell Ahlstedt 2016-09-06 06:45:25 UTC
(In reply to Dominique Leuenberger from comment #2)
> notewindow.cpp:207:29: error: no match for ‘operator!=’ (operand types are
> ‘Glib::RefPtr<Gdk::Window>’ and ‘int’)
>      if(parent->get_window() != 0
>
> According to the unstable doc, this should still be valid:
>
> https://developer.gnome.org/glibmm/unstable/classGlib_1_1RefPtr.
> html#ade68fc2a3cdb54e51b0f136aee95c074

The link goes to
bool Glib::RefPtr<T_CppObject>::operator!=(const RefPtr<T_CppObject>& src) const
showing that it's possible to compare two Glib::RefPtr<>s for inequality.

  parent->get_window() != 0
is not a comparison between two Glib::RefPtr<>s. Just like the error message
says, it's a comparison between a Glib::RefPtr<Gdk::Window> and an int.
That kind of comprison was possible when Glib::RefPtr could be implicitly
converted to bool, which was then implicitly converted to int.

In this case I think it would be possible to write
  if(parent->get_window())
because a conversion to bool in such a test is considered explicit.
Comment 8 Dominique Leuenberger 2016-09-06 07:32:04 UTC
(In reply to Kjell Ahlstedt from comment #7)
> In this case I think it would be possible to write
>   if(parent->get_window())
> because a conversion to bool in such a test is considered explicit.

Indeed, and this is also what the patch I attached actually does
Comment 9 Aurimas Černius 2016-09-07 09:50:25 UTC
Comment on attachment 334553 [details] [review]
Fix build (it's rather crude - but so far in my tests seems to work)

Rejecting this in favor of the other patch.
Comment 10 Aurimas Černius 2016-09-07 09:51:03 UTC
This problem has been fixed in the unstable development version. The fix will be available in the next major software release. You may need to upgrade your Linux distribution to obtain that newer version.