* Made the archive version of BTextControl::_InitData() more resistant against

a broken archive - it will now create a new _BTextInput_ child, if it couldn't
  find one. This fixes #2086.
* Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25123 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2008-04-24 09:52:27 +00:00
parent cfb0e47367
commit 991c062ff3
2 changed files with 33 additions and 33 deletions
+9 -10
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2005, Haiku Inc. * Copyright 2001-2008, Haiku Inc.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -8,7 +8,7 @@
* Ingo Weinhold <[email protected]> * Ingo Weinhold <[email protected]>
*/ */
/** BTextControl displays text that can act like a control. */ /*! BTextControl displays text that can act like a control. */
#include <stdio.h> #include <stdio.h>
@@ -73,8 +73,7 @@ private:
BTextControl::BTextControl(BRect frame, const char* name, const char* label, BTextControl::BTextControl(BRect frame, const char* name, const char* label,
const char *text, BMessage *message, uint32 mask, const char* text, BMessage* message, uint32 mask, uint32 flags)
uint32 flags)
: BControl(frame, name, label, message, mask, flags | B_FRAME_EVENTS) : BControl(frame, name, label, message, mask, flags | B_FRAME_EVENTS)
{ {
_InitData(label, text); _InitData(label, text);
@@ -83,8 +82,7 @@ BTextControl::BTextControl(BRect frame, const char *name, const char *label,
BTextControl::BTextControl(const char* name, const char* label, BTextControl::BTextControl(const char* name, const char* label,
const char *text, BMessage *message, const char* text, BMessage* message, uint32 flags)
uint32 flags)
: BControl(BRect(0, 0, -1, -1), name, label, message, B_FOLLOW_NONE, : BControl(BRect(0, 0, -1, -1), name, label, message, B_FOLLOW_NONE,
flags | B_FRAME_EVENTS | B_SUPPORTS_LAYOUT) flags | B_FRAME_EVENTS | B_SUPPORTS_LAYOUT)
{ {
@@ -93,8 +91,8 @@ BTextControl::BTextControl(const char *name, const char *label,
} }
BTextControl::BTextControl(const char *label, BTextControl::BTextControl(const char* label, const char* text,
const char *text, BMessage *message) BMessage* message)
: BControl(BRect(0, 0, -1, -1), NULL, label, message, B_FOLLOW_NONE, : BControl(BRect(0, 0, -1, -1), NULL, label, message, B_FOLLOW_NONE,
B_WILL_DRAW | B_NAVIGABLE | B_FRAME_EVENTS | B_SUPPORTS_LAYOUT) B_WILL_DRAW | B_NAVIGABLE | B_FRAME_EVENTS | B_SUPPORTS_LAYOUT)
{ {
@@ -141,7 +139,7 @@ BTextControl::Instantiate(BMessage *archive)
{ {
if (validate_instantiation(archive, "BTextControl")) if (validate_instantiation(archive, "BTextControl"))
return new BTextControl(archive); return new BTextControl(archive);
else
return NULL; return NULL;
} }
@@ -731,7 +729,8 @@ BTextControl::_InitData(const char* label, const char* initialText,
if (archive) if (archive)
fText = static_cast<BPrivate::_BTextInput_*>(FindView("_input_")); fText = static_cast<BPrivate::_BTextInput_*>(FindView("_input_"));
else {
if (fText == NULL) {
BRect frame(fDivider, bounds.top, BRect frame(fDivider, bounds.top,
bounds.right, bounds.bottom); bounds.right, bounds.bottom);
// we are stroking the frame around the text view, which // we are stroking the frame around the text view, which
+7 -6
View File
@@ -7,6 +7,9 @@
* Marc Flerackers ([email protected]) * Marc Flerackers ([email protected])
*/ */
#include "TextInput.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -17,24 +20,22 @@
#include <TextView.h> #include <TextView.h>
#include <Window.h> #include <Window.h>
#include "TextInput.h"
namespace BPrivate { namespace BPrivate {
_BTextInput_::_BTextInput_(BRect frame, BRect textRect, uint32 resizeMask, _BTextInput_::_BTextInput_(BRect frame, BRect textRect, uint32 resizeMask,
uint32 flags) uint32 flags)
: BTextView(frame, "_input_", textRect, resizeMask, flags) : BTextView(frame, "_input_", textRect, resizeMask, flags),
, fPreviousText(NULL) fPreviousText(NULL)
{ {
MakeResizable(true); MakeResizable(true);
} }
_BTextInput_::_BTextInput_(BMessage* archive) _BTextInput_::_BTextInput_(BMessage* archive)
: BTextView(archive) : BTextView(archive),
, fPreviousText(NULL) fPreviousText(NULL)
{ {
MakeResizable(true); MakeResizable(true);
} }