[haiku-commits] r38296 - haiku/trunk/src/kits/interface

  • From: anevilyak@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 21 Aug 2010 17:28:50 +0200 (CEST)

Author: anevilyak
Date: 2010-08-21 17:28:50 +0200 (Sat, 21 Aug 2010)
New Revision: 38296
Changeset: http://dev.haiku-os.org/changeset/38296

Modified:
   haiku/trunk/src/kits/interface/Shelf.cpp
   haiku/trunk/src/kits/interface/ZombieReplicantView.cpp
   haiku/trunk/src/kits/interface/ZombieReplicantView.h
Log:
Fix various problems found while investigating (and fixing) CID 1453. In short, 
handling of zombie replicants was completely broken ; they never actually made 
it to the shelf, and weren't saved/restored either. A problem still remains 
with respect to restoring them (the shelf relies on the dragged message's drop 
point to position them, which isn't preserved when the message is 
flattened/unflattened it seems).



Modified: haiku/trunk/src/kits/interface/Shelf.cpp
===================================================================
--- haiku/trunk/src/kits/interface/Shelf.cpp    2010-08-21 14:47:38 UTC (rev 
38295)
+++ haiku/trunk/src/kits/interface/Shelf.cpp    2010-08-21 15:28:50 UTC (rev 
38296)
@@ -291,20 +291,25 @@
 status_t
 replicant_data::Archive(BMessage* msg)
 {
-       status_t result = B_ERROR;
+       status_t result = B_OK;
        BMessage archive;
-       if (view && (view->Archive(&archive) == B_OK)) {
-               msg->AddInt32("uniqueid", id);
-               BPoint pos (0,0);
-               if (view) {
-                       msg->AddMessage("message", &archive);
-                       pos = view->Frame().LeftTop();
-               } else if (zombie_view)
-                       pos = zombie_view->Frame().LeftTop();
-               msg->AddPoint("position", pos);
-               result = B_OK;
-       }
+       if (view) 
+               result = view->Archive(&archive);
+       else if (zombie_view)
+               result = zombie_view->Archive(&archive);
+               
+       if (result != B_OK)
+               return result;
 
+       msg->AddInt32("uniqueid", id);
+       BPoint pos (0,0);
+       msg->AddMessage("message", &archive);
+       if (view)
+               pos = view->Frame().LeftTop();
+       else if (zombie_view) 
+               pos = zombie_view->Frame().LeftTop();
+       msg->AddPoint("position", pos);
+
        return result;
 }
 
@@ -1295,21 +1300,22 @@
        // Instantiate the object, if this fails we have a zombie
        image_id image = -1;
        BArchivable *archivable = _InstantiateObject(data, &image);
-
-       if (archivable == NULL)
-               return send_reply(data, B_ERROR, uniqueID);
-
-       BView *view = dynamic_cast<BView*>(archivable);
-       if (view == NULL) {
-               printf("Replicant was rejected: it's not a view!");
-               return send_reply(data, B_ERROR, uniqueID);
+       
+       BView *view = NULL;
+       
+       if (archivable) {
+               view = dynamic_cast<BView*>(archivable);
+               
+               if (!view) {
+                       return send_reply(data, B_ERROR, uniqueID);
+               }
        }
-
+       
        BDragger* dragger = NULL;
        BView* replicant = NULL;
        BDragger::relation relation = BDragger::TARGET_UNKNOWN;
        _BZombieReplicantView_* zombie = NULL;
-       if (view != NULL) {
+       if (view) {
                const BPoint point = location ? *location : 
view->Frame().LeftTop();
                replicant = _GetReplicant(data, view, point, dragger, relation);
                if (replicant == NULL)
@@ -1444,7 +1450,7 @@
        if (data->WasDropped()) {
                BPoint offset;
                BPoint dropPoint = data->DropPoint(&offset);
-
+               
                frame.OffsetTo(fContainerView->ConvertFromScreen(dropPoint) - 
offset);
 
                zombie = new _BZombieReplicantView_(frame, B_ERROR);

Modified: haiku/trunk/src/kits/interface/ZombieReplicantView.cpp
===================================================================
--- haiku/trunk/src/kits/interface/ZombieReplicantView.cpp      2010-08-21 
14:47:38 UTC (rev 38295)
+++ haiku/trunk/src/kits/interface/ZombieReplicantView.cpp      2010-08-21 
15:28:50 UTC (rev 38296)
@@ -37,12 +37,12 @@
 
 
 void
-_BZombieReplicantView_::MessageReceived(BMessage *msg)
+_BZombieReplicantView_::MessageReceived(BMessage* msg)
 {
        switch (msg->what) {
                case B_ABOUT_REQUESTED:
                {
-                       const char *addOn = NULL;
+                       const char* addOn = NULL;
                        char error[1024];
                        if (fArchive->FindString("add_on", &addOn) == B_OK) {
                                char description[B_MIME_TYPE_LENGTH] = "";      
                        
@@ -58,7 +58,7 @@
                        }
 
                                                
-                       BAlert *alert = new (std::nothrow) BAlert("Error", 
error, "OK", NULL, NULL,
+                       BAlert* alert = new (std::nothrow) BAlert("Error", 
error, "OK", NULL, NULL,
                                                                
B_WIDTH_AS_USUAL, B_STOP_ALERT);
                        if (alert != NULL)
                                alert->Go();
@@ -92,8 +92,17 @@
 }
 
 
+status_t
+_BZombieReplicantView_::Archive(BMessage* archive, bool) const
+{
+       *archive = *fArchive;
+       
+       return B_OK;
+}
+
+
 void
-_BZombieReplicantView_::SetArchive(BMessage *archive)
+_BZombieReplicantView_::SetArchive(BMessage* archive)
 {
        fArchive = archive;
 }

Modified: haiku/trunk/src/kits/interface/ZombieReplicantView.h
===================================================================
--- haiku/trunk/src/kits/interface/ZombieReplicantView.h        2010-08-21 
14:47:38 UTC (rev 38295)
+++ haiku/trunk/src/kits/interface/ZombieReplicantView.h        2010-08-21 
15:28:50 UTC (rev 38296)
@@ -38,20 +38,24 @@
 class _BZombieReplicantView_ : public BBox {
 
 public:
-                               _BZombieReplicantView_(BRect frame, status_t 
error);
-virtual                        ~_BZombieReplicantView_();
+                                                               
_BZombieReplicantView_(BRect frame, 
+                                                                       
status_t error);
+       virtual                                         
~_BZombieReplicantView_();
 
-virtual        void    MessageReceived(BMessage *msg);
+       virtual void                            MessageReceived(BMessage*msg);
 
-virtual        void    Draw(BRect updateRect);
+       virtual void                            Draw(BRect updateRect);
 
-virtual        void    MouseDown(BPoint);
+       virtual void                            MouseDown(BPoint);
 
-               void    SetArchive(BMessage *);
+       virtual status_t                        Archive(BMessage* archive,
+                                                                       bool 
deep = true) const;
 
+                       void                            SetArchive(BMessage*);
+
 private:
-               status_t        fError;
-               BMessage        *fArchive;
+                       status_t                        fError;
+                       BMessage*                       fArchive;
 };
 
 #endif /* _ZOMBIE_REPLICANT_VIEW_H */


Other related posts:

  • » [haiku-commits] r38296 - haiku/trunk/src/kits/interface - anevilyak