lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] [lmi-commits] master 5bb0b55 2/3: Update statusbar smoothly (V


From: Vadim Zeitlin
Subject: Re: [lmi] [lmi-commits] master 5bb0b55 2/3: Update statusbar smoothly (VZ)
Date: Wed, 27 Jun 2018 15:58:35 +0200

On Wed, 27 Jun 2018 13:40:12 +0000 Greg Chicares <address@hidden> wrote:

GC> BTW, the documentation says that calling wxFrame::SetStatusText() causes
GC> the statusbar to be redrawn:
GC> 
GC>   
http://docs.wxwidgets.org/3.1/classwx_frame.html#a0026c883df35e1d1f8818e229c41249f
GC> | Sets the status bar text and redraws the status bar.
GC> 
GC> whereas the documentation for wxStatusBar::SetStatusText
GC>   
http://docs.wxwidgets.org/3.1/classwx_status_bar.html#a1f0fd75cce7f3f8c89c0b2f8b9b88dd1
GC> makes no such claim about redrawing the status bar.

 I think I'll fix the documentation because always calling Update() from
SetStatusText() doesn't look like a good idea. Thanks for pointing this
out!

GC> I really wanted to write
GC>   if(f && wxStatusBar* b = f->GetStatusBar())
GC> but the language doesn't allow that

 It does, since C++17, see https://en.cppreference.com/w/cpp/language/if
But in this case I'd just write

        if(wxStatusBar* b = f ? f->GetStatusBar() : nullptr)

without using the new language construct. At least pointers do have the
advantage of being allowed to be null.
 
GC> There really ought to be a clear way of expressing that, so that we
GC> could evaluate a dereference chain like
GC>   p0->p1->p2->p3
GC> and return p3 if valid, else null_ptr if any of the pointers is null.

 Yes, it's not a coincidence that all languages, from C# to Java to Rust
have or recently added something allowing to do just this. In C++ you can
emulate this with helper functions, but it's not very elegant...

 Regards,
VZ


reply via email to

[Prev in Thread] Current Thread [Next in Thread]