Watch, Follow, &
Connect with Us

Welcome, Guest
Guest Settings
Help

Thread: TBindNavigator::Visible won't compile


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 3 - Last Post: Sep 12, 2017 3:58 PM Last Post By: Remy Lebeau (Te...
Greg Reese

Posts: 74
Registered: 7/15/05
TBindNavigator::Visible won't compile  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 12, 2017 12:46 PM
I have a FireMonkey TBindNavigator control (called guiMainGridNavigator) on a form. If I write code to set its Visible property, e.g.

guiMainGridNavigator->Visible = true;


I get the compiler error


[bcc32c Error] import_unit.cpp(83): no viable conversion from 'bool' to 'Data::Bind::Controls::TNavigateButtons' (aka 'Set<Data::Bind::Controls::TNavigateButton, TNavigateButton::nbFirst, TNavigateButton::nbCancelUpdates>')

sysset.h(43): candidate constructor (the implicit copy constructor) not viable: no known conversion from 'bool' to 'const System::Set<Data::Bind::Controls::TNavigateButton, 0, 11> &' for 1st argument

Fmx.Bind.Navigator.hpp(133): passing argument to parameter 'Value' here

I have Builder 10.2, Update 1.

Any ideas?

Thanks.
Greg Reese

Remy Lebeau (Te...


Posts: 8,645
Registered: 12/23/01
Re: TBindNavigator::Visible won't compile  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 12, 2017 1:12 PM   in response to: Greg Reese in response to: Greg Reese
Greg Reese wrote:

guiMainGridNavigator->Visible = true;


I get the compiler error

[bcc32c Error] import_unit.cpp(83): no viable conversion from 'bool'
to 'Data::Bind::Controls::TNavigateButtons' (aka
'Set<Data::Bind::Controls::TNavigateButton, TNavigateButton::nbFirst,
TNavigateButton::nbCancelUpdates>')

That error cannot happen when assigning a bool to the Visible property.
It would happen if you tried assigning a bool to the VisibleButtons
property instead.

--
Remy Lebeau (TeamB)
Greg Reese

Posts: 74
Registered: 7/15/05
Re: TBindNavigator::Visible won't compile  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 12, 2017 3:17 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
Greg Reese wrote:

guiMainGridNavigator->Visible = true;


I get the compiler error

[bcc32c Error] import_unit.cpp(83): no viable conversion from 'bool'
to 'Data::Bind::Controls::TNavigateButtons' (aka
'Set<Data::Bind::Controls::TNavigateButton, TNavigateButton::nbFirst,
TNavigateButton::nbCancelUpdates>')

That error cannot happen when assigning a bool to the Visible property.
It would happen if you tried assigning a bool to the VisibleButtons
property instead.

--
Remy Lebeau (TeamB)

Remy,

It is happening. Try it yourself by compiling these lines.

TBindNavigator* nav = new TBindNavigator( nullptr );
nav->Visible = true;


I think I see what's going on though:

The TBindNavigator stuff is in Fmx.Bind.Navigator.hpp

TBindNavigator is derived from TCustomBindNavigator and just publishes the latter's Visible property.

In TCustomBindNavigator Visible is a public property. The only declaration of SetVisible in the file is in TCustomBindNavigator, namely,

HIDESBASE void __fastcall SetVisible(Data::Bind::Controls::TNavigateButtons Value);


TCustomBindNavigator inherits (indirectly) from TControl, which also declares SetVisible but with a
different signature:

virtual void __fastcall SetVisible(const bool Value);


By the C++ hiding rule, TCustomBindNavigator::SetVisible hides TControl::SetVisible and this leads to the compiler error. A way around the problem is to explicitly invoke TControl's SetVisible, e.g.,

TBindNavigator* nav = new TBindNavigator( nullptr );
nav->TControl::Visible = true;


Not exactly intuitive, but HIDESBASE must be a hint to this.

What's your take Remy?

Greg Reese
Remy Lebeau (Te...


Posts: 8,645
Registered: 12/23/01
Re: TBindNavigator::Visible won't compile  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 12, 2017 3:58 PM   in response to: Greg Reese in response to: Greg Reese
Greg Reese wrote:

TBindNavigator is derived from TCustomBindNavigator and just
publishes the latter's Visible property.

Which is the TControl::Visible property.

In TCustomBindNavigator Visible is a public property.

TCustomBindNavigator does not define a new Visible property, just the
inherited one from TControl.

The only declaration of SetVisible in the file is in
TCustomBindNavigator, namely,

HIDESBASE void __fastcall
SetVisible(Data::Bind::Controls::TNavigateButtons Value); 


TCustomBindNavigator inherits (indirectly) from TControl, which also
declares SetVisible but with a different signature:

virtual void __fastcall SetVisible(const bool Value);

TCustomBindNavigator does not define a new Visible property, but it
does define a VisibleButtons property, and the
TCustomBindNavigator::SetVisible() method is the setter method for the
VisibleButtons property, so it should have been named accordingly.

However, TCustomBindNavigator::SetVisible() is declared as
'reintroduce' in its Pascal source code, which is why it is declared as
HIDESBASE in C++.

There is absolutely no good reason why
TCustomBindNavigator::SetVisible() sholud have been reintroduced in
this manner. I would consider this a bug. And I'm surprised that
noone has encountered this before, since the bug has existed since
TBindNavigator was first introduced in XE2 (6 years ago!). I have filed
a report in Quality Portal:

RSP-19037: TBindNavigator::Visible property does not compile in C++
https://quality.embarcadero.com/browse/RSP-19037

By the C++ hiding rule, TCustomBindNavigator::SetVisible hides
TControl::SetVisible and this leads to the compiler error.

TControl::SetVisible() is virtual, and TCustomBindNavigator does not
override it but does reintroduce it, that is why
TCustomBindNavigator::SetVisible() is marked as HIDESBASE in C++.

A way around the problem is to explicitly invoke TControl's
SetVisible, e.g.,

TBindNavigator* nav = new TBindNavigator( nullptr );
nav->TControl::Visible = true;

Yes, that is a viable workaround until Embarcadero fixes their bug.

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02