hrev50317 adds 2 changesets to branch 'master'
old head: 49448867f5b7339f24b4f17208e4cc1a88d1b6f3
new head: 9c7d0c3157ce4bbe86211cbae1864bbd6eeab21e
overview:
http://cgit.haiku-os.org/haiku/log/?qt=range&q=9c7d0c3157ce+%5E49448867f5b7
----------------------------------------------------------------------------
213ddbf656ca: ResourceFile: Handle version info in resource in other endianness
than host.
Fixes #12779.
Signed-off-by: Augustin Cavalier <waddlesplash@xxxxxxxxx>
Includes some minor whitespace fixes by me.
[ Mark Hellegers <mark@xxxxxxxxxxxx> ]
9c7d0c3157ce: FileTypes: Remove hardcoded message what from generic class.
As noted on the commits list.
[ Augustin Cavalier <waddlesplash@xxxxxxxxx> ]
----------------------------------------------------------------------------
2 files changed, 41 insertions(+), 8 deletions(-)
src/kits/storage/ResourceFile.cpp | 23 ++++++++++++++---
.../filetypes/ApplicationTypeWindow.cpp | 26 ++++++++++++++++----
############################################################################
Commit: 213ddbf656ca1594a7298b50c344e5ef02d1bb6d
URL: http://cgit.haiku-os.org/haiku/commit/?id=213ddbf656ca
Author: Mark Hellegers <mark@xxxxxxxxxxxx>
Date: Sat May 14 14:33:38 2016 UTC
Committer: Augustin Cavalier <waddlesplash@xxxxxxxxx>
Commit-Date: Sat May 14 18:52:47 2016 UTC
Ticket: https://dev.haiku-os.org/ticket/12779
ResourceFile: Handle version info in resource in other endianness than host.
Fixes #12779.
Signed-off-by: Augustin Cavalier <waddlesplash@xxxxxxxxx>
Includes some minor whitespace fixes by me.
----------------------------------------------------------------------------
diff --git a/src/kits/storage/ResourceFile.cpp
b/src/kits/storage/ResourceFile.cpp
index 907ee87..fc79456 100644
--- a/src/kits/storage/ResourceFile.cpp
+++ b/src/kits/storage/ResourceFile.cpp
@@ -67,6 +67,9 @@ const char* kFileTypeNames[] = {
#define DBG(x)
#define OUT printf
+#define B_VERSION_INFO_TYPE 'APPV'
+
+static const uint32 kVersionInfoIntCount = 5;
// #pragma mark - helper functions/classes
@@ -323,8 +326,15 @@ ResourceFile::ReadResource(ResourceItem& resource, bool
force)
}
if (error == B_OK) {
// convert the data, if necessary
- if (!fHostEndianess)
- swap_data(resource.Type(), data, size,
B_SWAP_ALWAYS);
+ if (!fHostEndianess) {
+ if (resource.Type() == B_VERSION_INFO_TYPE) {
+ // Version info contains integers that
need to be swapped
+ swap_data(B_UINT32_TYPE, data,
+ kVersionInfoIntCount *
sizeof(uint32),
+ B_SWAP_ALWAYS);
+ } else
+ swap_data(resource.Type(), data, size,
B_SWAP_ALWAYS);
+ }
resource.SetLoaded(true);
resource.SetModified(false);
}
@@ -1200,7 +1210,14 @@ ResourceFile::_WriteResources(ResourcesContainer&
container)
// swap data, if necessary
if (!fHostEndianess) {
memcpy(data, itemData, itemSize);
- swap_data(item->Type(), data, itemSize,
B_SWAP_ALWAYS);
+ if (item->Type() ==
B_VERSION_INFO_TYPE) {
+ // Version info contains
integers
+ // that need to be swapped
+ swap_data(B_UINT32_TYPE, data,
+ kVersionInfoIntCount *
sizeof(uint32),
+ B_SWAP_ALWAYS);
+ } else
+ swap_data(item->Type(), data,
itemSize, B_SWAP_ALWAYS);
itemData = data;
}
write_exactly(fFile, itemOffset, itemData,
itemSize,
############################################################################
Revision: hrev50317
Commit: 9c7d0c3157ce4bbe86211cbae1864bbd6eeab21e
URL: http://cgit.haiku-os.org/haiku/commit/?id=9c7d0c3157ce
Author: Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date: Sat May 14 19:53:13 2016 UTC
FileTypes: Remove hardcoded message what from generic class.
As noted on the commits list.
----------------------------------------------------------------------------
diff --git a/src/preferences/filetypes/ApplicationTypeWindow.cpp
b/src/preferences/filetypes/ApplicationTypeWindow.cpp
index 7d9725b..865ea5e 100644
--- a/src/preferences/filetypes/ApplicationTypeWindow.cpp
+++ b/src/preferences/filetypes/ApplicationTypeWindow.cpp
@@ -66,17 +66,20 @@ const uint32 kMsgTypeRemoved = 'tprm';
//! TextView that filters the tab key to be able to tab-navigate while editing
class TabFilteringTextView : public BTextView {
public:
-
TabFilteringTextView(const char* name);
+
TabFilteringTextView(const char* name,
+ uint32
changedMessageWhat = 0);
virtual ~TabFilteringTextView();
virtual void InsertText(const char* text,
int32 length,
int32
offset, const text_run_array* runs);
+ virtual void DeleteText(int32 fromOffset,
int32 toOffset);
virtual void KeyDown(const char* bytes,
int32 count);
virtual void
TargetedByScrollView(BScrollView* scroller);
virtual void MakeFocus(bool focused = true);
private:
BScrollView* fScrollView;
+ uint32 fChangedMessageWhat;
};
@@ -116,10 +119,12 @@ public:
// #pragma mark -
-TabFilteringTextView::TabFilteringTextView(const char* name)
+TabFilteringTextView::TabFilteringTextView(const char* name,
+ uint32 changedMessageWhat)
:
BTextView(name, B_WILL_DRAW | B_PULSE_NEEDED | B_NAVIGABLE),
- fScrollView(NULL)
+ fScrollView(NULL),
+ fChangedMessageWhat(changedMessageWhat)
{
}
@@ -134,7 +139,17 @@ TabFilteringTextView::InsertText(const char* text, int32
length, int32 offset,
const text_run_array* runs)
{
BTextView::InsertText(text, length, offset, runs);
- Window()->PostMessage(kMsgVersionInfoChanged);
+ if (fChangedMessageWhat != 0)
+ Window()->PostMessage(fChangedMessageWhat);
+}
+
+
+void
+TabFilteringTextView::DeleteText(int32 fromOffset, int32 toOffset)
+{
+ BTextView::DeleteText(fromOffset, toOffset);
+ if (fChangedMessageWhat != 0)
+ Window()->PostMessage(fChangedMessageWhat);
}
@@ -452,7 +467,8 @@ ApplicationTypeWindow::ApplicationTypeWindow(BPoint
position,
BStringView* longLabel = new BStringView(NULL,
B_TRANSLATE("Long description:"));
longLabel->SetExplicitAlignment(labelAlignment);
- fLongDescriptionView = new TabFilteringTextView("long desc");
+ fLongDescriptionView = new TabFilteringTextView("long desc",
+ kMsgVersionInfoChanged);
fLongDescriptionView->SetMaxBytes(sizeof(versionInfo.long_info));
scrollView = new BScrollView("desc scrollview", fLongDescriptionView,