[haiku-bugs] Re: [Haiku] #8872: Add ability to drag drive to terminal

  • From: "stippi" <trac@xxxxxxxxxxxx>
  • Date: Thu, 23 Aug 2012 12:23:25 -0000

#8872: Add ability to drag drive to terminal
---------------------------------------+----------------------------
   Reporter:  X512                     |      Owner:  stippi
       Type:  enhancement              |     Status:  new
   Priority:  normal                   |  Milestone:  R1
  Component:  Applications/DriveSetup  |    Version:  R1/Development
 Resolution:                           |   Keywords:
 Blocked By:                           |   Blocking:
Has a Patch:  1                        |   Platform:  All
---------------------------------------+----------------------------

Comment (by stippi):

 Thanks for the update. Sorry, I've got more improvements to suggest:

 {{{
 const char*
 PartitionListRow::GetPath()
 {
     char* pathString = NULL;

     BBitmapStringField* stringField
         = dynamic_cast<BBitmapStringField*>(GetField(kDeviceColumn));
     if(stringField != NULL) {
         pathString = const_cast<char*>(stringField->String());
     }

     return pathString;
 }
 }}}

 According to Haiku's conventions, the method should be named just
 "Path()". Maybe "DevicePath()" would be clearer. Since it doesn't change
 the object, it should be declared const. When you return "const char*", I
 don't understand why you declare your return variable "char*" and then
 even need the const_cast to make the compiler happy. You can avoid the
 return variable entirely using an early return:

 {{{
 const char*
 PartitionListRow::DevicePath() const
 {
     BBitmapStringField* stringField
         = dynamic_cast<BBitmapStringField*>(GetField(kDeviceColumn));

     if (stringField == NULL)
         return NULL; // or return ""; ?

     return stringField->String();
 }
 }}}

 Can you provide that as a single patch? Again, thanks a lot for your work!

-- 
Ticket URL: <http://dev.haiku-os.org/ticket/8872#comment:7>
Haiku <http://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: