hrev47664 adds 94 changesets to branch 'master' old head: 676721d2670c65224c895e196f121dceafc047d2 new head: 3e2653e609fa2f28ce9dfc0a86097fc408d9966e overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=3e2653e+%5E676721d ---------------------------------------------------------------------------- d89f61f: Tracker: unchecked return value, CID 602465 Check that refs is not NULL and that refs->FindData() succeeds. Also, explicit NULL check 5812165: Tracker: Fix 3 copies, CID 609040-CID 609042 strcpy() => strlcpy() ab28908: Tracker: Fix dereference after NULL, CID 601541 _TrackerLaunchDocuments() dereferences refs to copy it, so, we need check that it isn't NULL first. Also a few style fixes. * Name params consistent with TTracker class methods ref, message => appRef, refs * Use NULL instead of 0 for NULL pointer. 10489e8: Tracker: check if widget == NULL, CID 600509 Add a few helpful comments too. 9b9c1e2: Tracker: fix memory leak, CID 600996 We now only create the BString if we're going to put it in the list. 4083dbf: Tracker: fix NULL dereference 50060fc: Tracker: fix unchecked return value, CID 602466 1a25069: Tracker: fix use after free, CID 610577 This seems to happen when BList got converted to a BObjectList. The latter frees items when removing them by default while the former does not. 00ce643: Tracker: fix uninitialized pointer, CID 991718 fTrashContextMenu was never initialized in the constructor (looks like it just got overlooked since all other pointers were.) 655fc1b: Tracker: Check if Submenu() is NULL. CID 601585 a1c48ee: Tracker: tiny style fix d6a5d59: Tracker: fix unchecked return value. CID 602487 854c14f: Tracker: tiny style fix, 80 char limit 628bd16: Tracker: fix unchecked return value. CID 602488 91dee2f: Tracker: fix uninitialized members, CID 991721 68295c9: Tracker: fix uninitialized members, CID 610132 e741289: Tracker: fix uninitialized members, CID 610133 1463a01: Tracker: Initialize pointers, CID 610135-610136 3557a90: Tracker: style fixes, whitespace only 2660268: Tracker: Set default values in case of error ...for BColumn. Fixes CID 602478 and CID 602479 0cf10e9: Tracker: Style fixes to NavMenu.h Pointer style, whitespace. Convert TrackingHookData from a class to a struct (all members public) a98019c: Tracker: init fIteratingDesktop CID 609644, 609833 6073b1d: Interface Kit: fix bad free, CID 611174 d5451cc: Tracker: fix negative buffer size, CID 610926 1aa5e79: Tracker: check return value, CID 610641 ... if failure, set to blank BMessage(). d069f64: Tracker: AttributeStream style fixes Rename cloneThis and attr to other 49d5d59: Tracker: AttributeStream: implement default constructor Set members to dummy values CID 610118 1bea02a: Tracker: init fTime to 0, CID 610125 f68bec6: Tracker: init times to 0, CID 610124 c8c3cf0: Tracker: init default member values, CID 609642 acd00fc: Tracker: init fTime to 0, CID 610125 8bc62a0: Tracker: RegExp style fixes, pointer style 23d59b8: Tracker: RegExp, set initial member values CID 609956 d6c4e7a: Tracker: init default member values, CID 609845 a45f995: Tracker: init member vars, CID 609834 ec23596: Tracker: init member vars, CID 991720 ec3d0a6: Tracker: check dynamic_cast, CID 600336 015559b: Tracker: init member vars, CID 610120 322b28e: Tracker: init member var, CID 610121 4f48aee: Tracker: Check dynamic_cast, CID 600337 d588131: Tracker: reorder includes in FindPanel.cpp 1494888: Tracker: Style fixes to FindPanel cfc444a: Tracker: Unchecked dynamic_cast, CID 300339 bbd3b2d: Tracker: Unchecked dynamic_cast, CID 600340 d6e0dbf: Tracker: Unchecked dynamic_cast, CID 600343 35237fd: Tracker: Unchecked dynamic_cast, CID 500345 bee19b9: Tracker: Unchecked dynamic_cast, CID 600346 d2af6ff: Tracker: Unchecked dynamic_cast, CID 600347 9fc1e7f: Tracker: Unchecked dynamic_cast, CID 600348 6ef1768: Tracker: Unchecked dynamic_cast, CID 600349 1cdaa16: Tracker: Unchecked dynamic_cast, CID 600353 ... and possibly others. ee090c5: Tracker: Unchecked return value, CID 602471 404b6d4: Tracker: Unchecked dynamic_cast, CID 603123 f0eb64b: Tracker: Unchecked dynamic_cast, CID 603125 1371d18: Tracker: Unchecked dynamic_cast, CID 603126 1995f1a: Tracker: Check for negative size, CID 610924 1e09ea5: Tracker: Check return values, CID 991051 & CID 991052 The CIDs are about mkdir, we want to check that either the command succeeded or failed because the directory already exists. However, we also want to check the return value of find_directory() and Append() to make sure they succeeded as well. 08b7dda: Tracker: Unchecked dynamic_cast, CID 1032263 861d997: Tracker: Unchecked dynamic_cast, CID 1032264 Also some minor refactoring, rename string to textEntryString, check before dereferencing potentially NULL pointers. ce04484: Tracker: Dereference NULL pointer, CID 1032279 Also a bit of a refactor of GetDefaultAttrName(), check for NULL explicitly, rename result to attrName e85fa8f: Tracker: Unchecked dynamic_cast, CID 1210856 350af1c: Tracker: Unchecked dynamic_cast, CID 1210857 a2b0a3c: Tracker: refactor FindPanel::SetUpAddRemoveButtons() Instead of passing the box in we can just use FindView to get it, that's what other methods do. Also, check if removeButton exists in AddAttrRow() first instead of doing it in this method. 73de7ce: Tracker: check that textControl->TextView() isn't NULL dddea1f: Tracker: Prefer textControl->Text() over textControl->TextView()->Text(), also SetText() dc28a57: Refactor FindPanel::Draw() Check if pointers are NULL before dereferencing them. a2400cc: Tracker: some style fixes to FindPanel fbf6179: Tracker: Check dynamic_cast ASSERT that it is not NULL as it shouldn't be. 8fbb387: Tracker: check dynamic_cast f0b515e: Tracker: Check dereference NULL pointers field->Menu() could return NULL, field->Menu()->FindMarked() could return NULL. 38f3b29: Tracker: Check dynamic_cast e5355e2: Tracker: Unchecked return values Check that find_directory() and path.Append() succeeded. a76808e: Tracker: Unchecked dynamic_cast in FilePanelPriv.cpp, CID 300327 e2ee7b0: Tracker: Move B_TRANSLATION_CONTEXT to top of FilePanelPriv.cpp 6b51d90: Tracker: style fixes to FilePanelPriv.cpp 86c2b95: Tracker: Unchecked dynamic_cast, CID 600506 a35bd7b: Tracker: Unchecked dynamic_cast, CID 600452 95ef540: Tracker: Unchecked dynamic_cast, CID 611229 a8216d9: Tracker: Style fixes to WidgeAttributeText.cpp cf2902f: Tracker: Potential, but unlikly NULL dereference 9ead583: Tracker: Set default values, CID 609893 b7735c4: Tracker: Set initial value, CID 609894 3748c16: Tracker: Set initial value, CID 609895 e6877f1: Tracker: Unintentional integer overflow, CID 701977 a0db774: Tracker: Style fixes to WidgetAttributeText * rename result to outString * rename str to inString 85a2e66: Tracker: Refactor size calc to use a BString By using a BString we can keep track of the string length instead of calculating the length after hoping that sprintf() works or doing a bunch more work to check the return values using either snprintf() or asprintf(). sprintf() was not bounds checked either. As an added bonus we no longer have to use an arbitrary 1024 bytes size buffer. CID 991605 54e2dd7: Tracker: style fixes No functional changes intended. 3c4e269: Tracker: small code simplication Use std::max() to avoid comparison and turn into 1-liner. 82d9f9d: Tracker: Use main screen if window is NULL Here we try to determine the screen frame of screen that the window is on, use the main screen when window is NULL. d48f1c2: Tracker: code simplication, don't check if NULL just pass in NULL, that's what is happening anyway. e47063d: Tracker: Don't need to cast to BWindow here 9cc0318: Tracker: Add NULL checks and ASSERTs To prevent recoverable NULL pointer dereferences. Dereferencing a NULL pointer is undefined behavior and should be avoided. Unrecoverable NULL checks will be dealt with in the next commit. 2f60dea: Tracker: Throw exception on assert failure ... in situations where a NULL pointer dereference was vital to the functioning of the method we use a stronger assert that throws an exception on failure. This is accomplished by a new method in Utilities.cpp, ThrowOnAssert(). None of these conditions should ever be true, if they are it means that the code is written improperly and would have resulted in a NULL dereference and undefined behavior (most likely a crash) before. Most instances of ThrowOnAssert() either replace an ASSERT followed by a dereference or an early return that covered the error. Also remove _ThrowOnErrorWithMessage() which wasn't being used. 3e2653e: Tracker: re-add includes that were lost during merge [ John Scipione <jscipione@xxxxxxxxx> ] ---------------------------------------------------------------------------- 52 files changed, 1698 insertions(+), 1223 deletions(-) headers/private/tracker/NavMenu.h | 132 +++--- src/kits/interface/Picture.cpp | 2 +- src/kits/tracker/AttributeStream.cpp | 44 +- src/kits/tracker/AttributeStream.h | 20 +- src/kits/tracker/BackgroundImage.cpp | 3 +- src/kits/tracker/ContainerWindow.cpp | 33 +- src/kits/tracker/CountView.cpp | 2 + src/kits/tracker/DesktopPoseView.cpp | 5 +- src/kits/tracker/DirMenu.cpp | 9 +- src/kits/tracker/EntryIterator.cpp | 31 +- src/kits/tracker/EntryIterator.h | 4 +- src/kits/tracker/FSClipboard.cpp | 14 +- src/kits/tracker/FSUtils.cpp | 58 +-- src/kits/tracker/FSUtils.h | 14 +- src/kits/tracker/FavoritesMenu.cpp | 13 +- src/kits/tracker/FilePanel.cpp | 9 +- src/kits/tracker/FilePanelPriv.cpp | 219 ++++++---- src/kits/tracker/FindPanel.cpp | 547 +++++++++++++++---------- src/kits/tracker/FindPanel.h | 406 +++++++++--------- src/kits/tracker/InfoWindow.cpp | 10 +- src/kits/tracker/MimeTypeList.cpp | 8 +- src/kits/tracker/MimeTypeList.h | 6 +- src/kits/tracker/Model.cpp | 3 +- src/kits/tracker/NavMenu.cpp | 38 +- src/kits/tracker/NodeWalker.cpp | 3 +- src/kits/tracker/OpenWithWindow.cpp | 36 +- src/kits/tracker/OverrideAlert.cpp | 6 +- src/kits/tracker/Pose.cpp | 11 +- src/kits/tracker/PoseView.cpp | 227 ++++++---- src/kits/tracker/PoseView.h | 2 +- src/kits/tracker/QueryPoseView.cpp | 17 +- src/kits/tracker/QueryPoseView.h | 43 +- src/kits/tracker/RecentItems.cpp | 32 +- src/kits/tracker/RegExp.cpp | 17 +- src/kits/tracker/RegExp.h | 4 +- src/kits/tracker/SettingsViews.cpp | 42 +- src/kits/tracker/SettingsViews.h | 2 - src/kits/tracker/SlowContextPopup.cpp | 19 +- src/kits/tracker/StatusWindow.cpp | 38 +- src/kits/tracker/TaskLoop.cpp | 21 +- src/kits/tracker/TextWidget.cpp | 22 +- src/kits/tracker/TitleView.cpp | 22 +- src/kits/tracker/Tracker.cpp | 40 +- src/kits/tracker/TrackerInitialState.cpp | 19 +- src/kits/tracker/TrackerSettings.cpp | 48 ++- src/kits/tracker/TrackerSettingsWindow.cpp | 12 +- src/kits/tracker/Utilities.cpp | 20 +- src/kits/tracker/Utilities.h | 16 +- src/kits/tracker/ViewState.cpp | 46 ++- src/kits/tracker/ViewState.h | 228 +++++------ src/kits/tracker/WidgetAttributeText.cpp | 296 +++++++------ src/kits/tracker/WidgetAttributeText.h | 2 +- ############################################################################ Commit: d89f61f0e00185ee453ce25a60686bb6a79b59d1 URL: http://cgit.haiku-os.org/haiku/commit/?id=d89f61f Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 18 23:03:18 2014 UTC Tracker: unchecked return value, CID 602465 Check that refs is not NULL and that refs->FindData() succeeds. Also, explicit NULL check ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/FSUtils.cpp b/src/kits/tracker/FSUtils.cpp index 5bde0fb..2340559 100644 --- a/src/kits/tracker/FSUtils.cpp +++ b/src/kits/tracker/FSUtils.cpp @@ -3344,15 +3344,16 @@ _TrackerLaunchAppWithDocuments(const entry_ref* appRef, const BMessage* refs, // close possible parent window, if specified const node_ref* nodeToClose = 0; ssize_t numBytes; - refs->FindData("nodeRefsToClose", B_RAW_TYPE, - (const void**)&nodeToClose, &numBytes); - if (nodeToClose) + if (refs != NULL && refs->FindData("nodeRefsToClose", B_RAW_TYPE, + (const void**)&nodeToClose, &numBytes) == B_OK + && nodeToClose != NULL) { dynamic_cast<TTracker*>(be_app)->CloseParent(*nodeToClose); + } } else { alertString.SetTo(B_TRANSLATE("Could not open \"%name\" (%error). ")); alertString.ReplaceFirst("%name", appRef->name); alertString.ReplaceFirst("%error", strerror(error)); - if (refs && openWithOK && error != B_SHUTTING_DOWN) { + if (refs != NULL && openWithOK && error != B_SHUTTING_DOWN) { alertString << B_TRANSLATE_NOCOLLECT(kFindAlternativeStr); BAlert* alert = new BAlert("", alertString.String(), B_TRANSLATE("Cancel"), B_TRANSLATE("Find"), 0, ############################################################################ Commit: 58121655edc0d59762bcb51493219c4e18d17c2e URL: http://cgit.haiku-os.org/haiku/commit/?id=5812165 Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 18 23:04:21 2014 UTC Tracker: Fix 3 copies, CID 609040-CID 609042 strcpy() => strlcpy() ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/FSUtils.cpp b/src/kits/tracker/FSUtils.cpp index 2340559..8e23f0a 100644 --- a/src/kits/tracker/FSUtils.cpp +++ b/src/kits/tracker/FSUtils.cpp @@ -1453,7 +1453,7 @@ CopyFolder(BEntry* srcEntry, BDirectory* destDir, srcEntry->GetRef(&ref); char destName[B_FILE_NAME_LENGTH]; - strcpy(destName, ref.name); + strlcpy(destName, ref.name, sizeof(destName)); loopControl->UpdateStatus(ref.name, ref, 1024, true); @@ -1621,7 +1621,7 @@ MoveItem(BEntry* entry, BDirectory* destDir, BPoint* loc, uint32 moveMode, if (moveMode == kCreateLink || moveMode == kCreateRelativeLink) { PoseInfo poseInfo; char name[B_FILE_NAME_LENGTH]; - strcpy(name, ref.name); + strlcpy(name, ref.name, sizeof(name)); BSymLink link; BString suffix(" "); @@ -1955,7 +1955,7 @@ MoveEntryToTrash(BEntry* entry, BPoint* loc, Undo &undo) // make sure name doesn't conflict with anything in trash already char name[B_FILE_NAME_LENGTH]; - strcpy(name, ref.name); + strlcpy(name, ref.name, sizeof(name)); if (trash_dir.Contains(name)) { BString suffix(" "); suffix << B_TRANSLATE_COMMENT("copy", "filename copy"), ############################################################################ Commit: ab28908d2d454e184e3489136f039b1611067dcb URL: http://cgit.haiku-os.org/haiku/commit/?id=ab28908 Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 18 23:12:29 2014 UTC Tracker: Fix dereference after NULL, CID 601541 _TrackerLaunchDocuments() dereferences refs to copy it, so, we need check that it isn't NULL first. Also a few style fixes. * Name params consistent with TTracker class methods ref, message => appRef, refs * Use NULL instead of 0 for NULL pointer. ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/FSUtils.cpp b/src/kits/tracker/FSUtils.cpp index 8e23f0a..b5c0687 100644 --- a/src/kits/tracker/FSUtils.cpp +++ b/src/kits/tracker/FSUtils.cpp @@ -3474,9 +3474,12 @@ LoaderErrorDetails(const entry_ref* app, BString &details) static void -_TrackerLaunchDocuments(const entry_ref* /*doNotUse*/, const BMessage* refs, +_TrackerLaunchDocuments(const entry_ref*, const BMessage* refs, bool openWithOK) { + if (refs == NULL) + return; + BMessage copyOfRefs(*refs); entry_ref documentRef; @@ -3700,7 +3703,7 @@ status_t TrackerLaunch(const entry_ref* appRef, bool async) { if (!async) - _TrackerLaunchAppWithDocuments(appRef, 0, false); + _TrackerLaunchAppWithDocuments(appRef, NULL, false); else AsynchLaunchBinder(&_TrackerLaunchAppWithDocuments, appRef, 0, false); @@ -3711,9 +3714,9 @@ status_t TrackerLaunch(const BMessage* refs, bool async, bool openWithOK) { if (!async) - _TrackerLaunchDocuments(0, refs, openWithOK); + _TrackerLaunchDocuments(NULL, refs, openWithOK); else - AsynchLaunchBinder(&_TrackerLaunchDocuments, 0, refs, openWithOK); + AsynchLaunchBinder(&_TrackerLaunchDocuments, NULL, refs, openWithOK); return B_OK; } @@ -3787,22 +3790,22 @@ FSLaunchUsing(const entry_ref* ref, BMessage* listOfRefs) status_t -FSLaunchItem(const entry_ref* ref, BMessage* message, int32, bool async) +FSLaunchItem(const entry_ref* appRef, BMessage* refs, int32, bool async) { - if (message != NULL) - message->what = B_REFS_RECEIVED; + if (refs != NULL) + refs->what = B_REFS_RECEIVED; - status_t result = TrackerLaunch(ref, message, async, true); - delete message; + status_t result = TrackerLaunch(appRef, refs, async, true); + delete refs; return result; } void -FSLaunchItem(const entry_ref* ref, BMessage* message, int32 workspace) +FSLaunchItem(const entry_ref* appRef, BMessage* refs, int32 workspace) { - FSLaunchItem(ref, message, workspace, true); + FSLaunchItem(appRef, refs, workspace, true); } diff --git a/src/kits/tracker/FSUtils.h b/src/kits/tracker/FSUtils.h index 5504a8e..23c91e6 100644 --- a/src/kits/tracker/FSUtils.h +++ b/src/kits/tracker/FSUtils.h @@ -244,11 +244,11 @@ status_t FSGetParentVirtualDirectoryAware(const BEntry& entry, entry_ref& _ref); status_t FSGetParentVirtualDirectoryAware(const BEntry& entry, BEntry& _entry); status_t FSGetParentVirtualDirectoryAware(const BEntry& entry, BNode& _node); -status_t TrackerLaunch(const entry_ref* app, bool async); +status_t TrackerLaunch(const entry_ref* appRef, bool async); status_t TrackerLaunch(const BMessage* refs, bool async, bool okToRunOpenWith = true); -status_t TrackerLaunch(const entry_ref* app, const BMessage* refs, bool async, - bool okToRunOpenWith = true); +status_t TrackerLaunch(const entry_ref* appRef, const BMessage* refs, + bool async, bool okToRunOpenWith = true); status_t LaunchBrokenLink(const char*, const BMessage*); status_t FSFindTrackerSettingsDir(BPath*, bool autoCreate = true); @@ -266,10 +266,10 @@ bool ConfirmChangeIfWellKnownDirectory(const BEntry* entry, bool CheckDevicesEqual(const entry_ref* entry, const Model* targetModel); // Deprecated calls use newer calls above instead -_IMPEXP_TRACKER void FSLaunchItem(const entry_ref*, BMessage* = NULL, - int32 workspace = -1); -_IMPEXP_TRACKER status_t FSLaunchItem(const entry_ref*, BMessage*, - int32 workspace, bool asynch); +_IMPEXP_TRACKER void FSLaunchItem(const entry_ref* appRef, + BMessage* refs = NULL, int32 workspace = -1); +_IMPEXP_TRACKER status_t FSLaunchItem(const entry_ref* appRef, + BMessage* refs, int32 workspace, bool asynch); _IMPEXP_TRACKER void FSOpenWithDocuments(const entry_ref* executableToLaunch, BMessage* documentEntryRefs); _IMPEXP_TRACKER status_t FSLaunchUsing(const entry_ref* ref, ############################################################################ Commit: 10489e89dd921a1764bda5d79c7706edfdaf3b0e URL: http://cgit.haiku-os.org/haiku/commit/?id=10489e8 Author: John Scipione <jscipione@xxxxxxxxx> Date: Tue Jul 22 22:41:18 2014 UTC Tracker: check if widget == NULL, CID 600509 Add a few helpful comments too. ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/Pose.cpp b/src/kits/tracker/Pose.cpp index b754756..149b685 100644 --- a/src/kits/tracker/Pose.cpp +++ b/src/kits/tracker/Pose.cpp @@ -427,11 +427,18 @@ BPose::EditPreviousNextWidgetCommon(BPoseView* poseView, bool next) for (int32 index = next ? 0 : poseView->CountColumns() - 1; ; index += delta) { BColumn* column = poseView->ColumnAt(index); - if (column == NULL) + if (column == NULL) { + // out of columns break; + } BTextWidget* widget = WidgetFor(column->AttrHash()); - if (widget != NULL && widget->IsActive()) { + if (widget == NULL) { + // no widget for this column, next + continue; + } + + if (widget->IsActive()) { poseView->CommitActivePose(); found = true; continue; ############################################################################ Commit: 9b9c1e2779e99e92a0028c5236f0e40620461690 URL: http://cgit.haiku-os.org/haiku/commit/?id=9b9c1e2 Author: John Scipione <jscipione@xxxxxxxxx> Date: Tue Jul 22 23:11:51 2014 UTC Tracker: fix memory leak, CID 600996 We now only create the BString if we're going to put it in the list. ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/ContainerWindow.cpp b/src/kits/tracker/ContainerWindow.cpp index ec6b5f4..b686586 100644 --- a/src/kits/tracker/ContainerWindow.cpp +++ b/src/kits/tracker/ContainerWindow.cpp @@ -291,21 +291,19 @@ OffsetFrameOne(const char* DEBUG_ONLY(name), uint32, off_t, void* castToRect, static void -AddMimeTypeString(BObjectList<BString> &list, Model* model) +AddMimeTypeString(BObjectList<BString>& list, Model* model) { - BString* mimeType = new BString(model->MimeType()); - - if (mimeType->Length()) { + const char* modelMimeType = model->MimeType(); + if (modelMimeType != NULL && *modelMimeType != '\0') { // only add the type if it's not already there + // ToDo: replace list with a hashmap for (int32 i = list.CountItems(); i-- > 0;) { BString* string = list.ItemAt(i); - if (string != NULL && !string->ICompare(*mimeType)) { - delete mimeType; + if (string != NULL && string->ICompare(modelMimeType) == 0) return; - } } - list.AddItem(mimeType); + list.AddItem(new BString(modelMimeType)); } } ############################################################################ Commit: 4083dbf1ab8eee9de96365125d257574b24dfef9 URL: http://cgit.haiku-os.org/haiku/commit/?id=4083dbf Author: John Scipione <jscipione@xxxxxxxxx> Date: Tue Jul 22 23:27:36 2014 UTC Tracker: fix NULL dereference ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/ContainerWindow.cpp b/src/kits/tracker/ContainerWindow.cpp index b686586..a4bb2f6 100644 --- a/src/kits/tracker/ContainerWindow.cpp +++ b/src/kits/tracker/ContainerWindow.cpp @@ -296,7 +296,6 @@ AddMimeTypeString(BObjectList<BString>& list, Model* model) const char* modelMimeType = model->MimeType(); if (modelMimeType != NULL && *modelMimeType != '\0') { // only add the type if it's not already there - // ToDo: replace list with a hashmap for (int32 i = list.CountItems(); i-- > 0;) { BString* string = list.ItemAt(i); if (string != NULL && string->ICompare(modelMimeType) == 0) @@ -1249,11 +1248,14 @@ BContainerWindow::StateNeedsSaving() const status_t BContainerWindow::GetLayoutState(BNode* node, BMessage* message) { - // ToDo: get rid of this, use AttrStream instead + if (node == NULL || message == NULL) + return B_BAD_VALUE; + status_t result = node->InitCheck(); if (result != B_OK) return result; + // ToDo: get rid of this, use AttrStream instead node->RewindAttrs(); char attrName[256]; while (node->GetNextAttrName(attrName) == B_OK) { ############################################################################ Commit: 50060fccaae21806912660a7beefdebd518b94a9 URL: http://cgit.haiku-os.org/haiku/commit/?id=50060fc Author: John Scipione <jscipione@xxxxxxxxx> Date: Tue Jul 22 23:29:53 2014 UTC Tracker: fix unchecked return value, CID 602466 ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/ContainerWindow.cpp b/src/kits/tracker/ContainerWindow.cpp index a4bb2f6..ba05767 100644 --- a/src/kits/tracker/ContainerWindow.cpp +++ b/src/kits/tracker/ContainerWindow.cpp @@ -1260,7 +1260,8 @@ BContainerWindow::GetLayoutState(BNode* node, BMessage* message) char attrName[256]; while (node->GetNextAttrName(attrName) == B_OK) { attr_info info; - node->GetAttrInfo(attrName, &info); + if (node->GetAttrInfo(attrName, &info) != B_OK) + continue; // filter out attributes that are not related to window position // and column resizing ############################################################################ Commit: 1a250696ed3f07aa8c0b89c0e79dc3b3a6309a94 URL: http://cgit.haiku-os.org/haiku/commit/?id=1a25069 Author: John Scipione <jscipione@xxxxxxxxx> Date: Tue Jul 22 23:31:03 2014 UTC Tracker: fix use after free, CID 610577 This seems to happen when BList got converted to a BObjectList. The latter frees items when removing them by default while the former does not. ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/ContainerWindow.cpp b/src/kits/tracker/ContainerWindow.cpp index ba05767..0d5a4aa 100644 --- a/src/kits/tracker/ContainerWindow.cpp +++ b/src/kits/tracker/ContainerWindow.cpp @@ -711,7 +711,7 @@ BContainerWindow::Quit() if (fWindowList != NULL) { AutoLock<LockingList<BWindow> > lock(fWindowList); if (lock.IsLocked()) { - fWindowList->RemoveItem(this); + fWindowList->RemoveItem(this, false); windowCount = fWindowList->CountItems(); } } ############################################################################ Commit: 00ce643768261402f1ee26c8f9471db2d1cc339e URL: http://cgit.haiku-os.org/haiku/commit/?id=00ce643 Author: John Scipione <jscipione@xxxxxxxxx> Date: Tue Jul 22 23:34:01 2014 UTC Tracker: fix uninitialized pointer, CID 991718 fTrashContextMenu was never initialized in the constructor (looks like it just got overlooked since all other pointers were.) ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/ContainerWindow.cpp b/src/kits/tracker/ContainerWindow.cpp index 0d5a4aa..6e1472c 100644 --- a/src/kits/tracker/ContainerWindow.cpp +++ b/src/kits/tracker/ContainerWindow.cpp @@ -528,6 +528,7 @@ BContainerWindow::BContainerWindow(LockingList<BWindow>* list, fWindowContextMenu(NULL), fDropContextMenu(NULL), fVolumeContextMenu(NULL), + fTrashContextMenu(NULL), fDragContextMenu(NULL), fMoveToItem(NULL), fCopyToItem(NULL), ############################################################################ Commit: 655fc1b4709282eb61ed3d5d8564ab1fc53cb18e URL: http://cgit.haiku-os.org/haiku/commit/?id=655fc1b Author: John Scipione <jscipione@xxxxxxxxx> Date: Wed Jul 23 01:15:05 2014 UTC Tracker: Check if Submenu() is NULL. CID 601585 ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/FilePanelPriv.cpp b/src/kits/tracker/FilePanelPriv.cpp index 98afd88..c4479c1 100644 --- a/src/kits/tracker/FilePanelPriv.cpp +++ b/src/kits/tracker/FilePanelPriv.cpp @@ -448,16 +448,26 @@ TFilePanel::SetMessage(BMessage* message) void TFilePanel::SetRefFilter(BRefFilter* filter) { - if (!filter) + if (filter == NULL) return; fPoseView->SetRefFilter(filter); fPoseView->CommitActivePose(); fPoseView->Refresh(); - FavoritesMenu* menu = dynamic_cast<FavoritesMenu*> - (fMenuBar->FindItem(B_TRANSLATE("Favorites"))->Submenu()); - if (menu) - menu->SetRefFilter(filter); + + if (fMenuBar == NULL) + return; + + BMenuItem* favoritesItem = fMenuBar->FindItem(B_TRANSLATE("Favorites")); + if (favoritesItem == NULL) + return; + + FavoritesMenu* favoritesSubMenu + = dynamic_cast<FavoritesMenu*>(favoritesItem->Submenu()); + if (favoritesSubMenu == NULL) + return; + + favoritesSubMenu->SetRefFilter(filter); } ############################################################################ Commit: a1c48ee597579a95d465e3468f59cdba00370d27 URL: http://cgit.haiku-os.org/haiku/commit/?id=a1c48ee Author: John Scipione <jscipione@xxxxxxxxx> Date: Wed Jul 23 01:23:11 2014 UTC Tracker: tiny style fix ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/FilePanelPriv.cpp b/src/kits/tracker/FilePanelPriv.cpp index c4479c1..b50a3dc 100644 --- a/src/kits/tracker/FilePanelPriv.cpp +++ b/src/kits/tracker/FilePanelPriv.cpp @@ -474,7 +474,7 @@ TFilePanel::SetRefFilter(BRefFilter* filter) void TFilePanel::SetTo(const entry_ref* ref) { - if (!ref) + if (ref == NULL) return; entry_ref setToRef(*ref); ############################################################################ Commit: d6a5d5962ed7bce9bdec89c38ba93af0e730dc22 URL: http://cgit.haiku-os.org/haiku/commit/?id=d6a5d59 Author: John Scipione <jscipione@xxxxxxxxx> Date: Wed Jul 23 01:27:08 2014 UTC Tracker: fix unchecked return value. CID 602487 ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/Tracker.cpp b/src/kits/tracker/Tracker.cpp index f125178..b389bbf 100644 --- a/src/kits/tracker/Tracker.cpp +++ b/src/kits/tracker/Tracker.cpp @@ -485,9 +485,10 @@ TTracker::MessageReceived(BMessage* message) { const node_ref* itemNode; ssize_t bytes; - message->FindData("node_ref", B_RAW_TYPE, - (const void**)&itemNode, &bytes); - CloseWindowAndChildren(itemNode); + if (message->FindData("node_ref", B_RAW_TYPE, + (const void**)&itemNode, &bytes) == B_OK) { + CloseWindowAndChildren(itemNode); + } break; } ############################################################################ Commit: 854c14fb6fbb6344173791187b32089022c2ad7a URL: http://cgit.haiku-os.org/haiku/commit/?id=854c14f Author: John Scipione <jscipione@xxxxxxxxx> Date: Wed Jul 23 01:27:49 2014 UTC Tracker: tiny style fix, 80 char limit ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/Tracker.cpp b/src/kits/tracker/Tracker.cpp index b389bbf..270a2dd 100644 --- a/src/kits/tracker/Tracker.cpp +++ b/src/kits/tracker/Tracker.cpp @@ -557,7 +557,8 @@ TTracker::MessageReceived(BMessage* message) case kRunAutomounterSettings: ShowSettingsWindow(); - fSettingsWindow->ShowPage(TrackerSettingsWindow::kAutomountSettings); + fSettingsWindow->ShowPage( + TrackerSettingsWindow::kAutomountSettings); break; case kShowSettingsWindow: ############################################################################ Commit: 628bd168bd151351d31e28ad80cca8ef6bab509e URL: http://cgit.haiku-os.org/haiku/commit/?id=628bd16 Author: John Scipione <jscipione@xxxxxxxxx> Date: Wed Jul 23 01:28:44 2014 UTC Tracker: fix unchecked return value. CID 602488 ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/Tracker.cpp b/src/kits/tracker/Tracker.cpp index 270a2dd..762f38e 100644 --- a/src/kits/tracker/Tracker.cpp +++ b/src/kits/tracker/Tracker.cpp @@ -581,9 +581,10 @@ TTracker::MessageReceived(BMessage* message) case kStopWatchClipboardRefs: { BMessenger messenger; - message->FindMessenger("target", &messenger); - if (messenger.IsValid()) + if (message->FindMessenger("target", &messenger) == B_OK + && messenger.IsValid()) { fClipboardRefsWatcher->RemoveFromNotifyList(messenger); + } break; } ############################################################################ Commit: 91dee2fc6803a2737941aa07af1056bde28e0c52 URL: http://cgit.haiku-os.org/haiku/commit/?id=91dee2f Author: John Scipione <jscipione@xxxxxxxxx> Date: Wed Jul 23 01:33:11 2014 UTC Tracker: fix uninitialized members, CID 991721 ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/Tracker.cpp b/src/kits/tracker/Tracker.cpp index 762f38e..93ed959 100644 --- a/src/kits/tracker/Tracker.cpp +++ b/src/kits/tracker/Tracker.cpp @@ -241,6 +241,11 @@ public: TTracker::TTracker() : BApplication(kTrackerSignature), + fMimeTypeList(NULL), + fClipboardRefsWatcher(NULL), + fTrashWatcher(NULL), + fTaskLoop(NULL), + fNodeMonitorCount(-1), fWatchingInterface(new WatchingInterface), fSettingsWindow(NULL) { ############################################################################ Commit: 68295c9255c0dd3eb37d711795af762616aedbec URL: http://cgit.haiku-os.org/haiku/commit/?id=68295c9 Author: John Scipione <jscipione@xxxxxxxxx> Date: Wed Jul 23 01:38:06 2014 UTC Tracker: fix uninitialized members, CID 610132 ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/SettingsViews.cpp b/src/kits/tracker/SettingsViews.cpp index 453fefd..0bfa2ff 100644 --- a/src/kits/tracker/SettingsViews.cpp +++ b/src/kits/tracker/SettingsViews.cpp @@ -175,7 +175,15 @@ SettingsView::IsRevertable() const DesktopSettingsView::DesktopSettingsView() : - SettingsView("DesktopSettingsView") + SettingsView("DesktopSettingsView"), + fShowDisksIconRadioButton(NULL), + fMountVolumesOntoDesktopRadioButton(NULL), + fMountSharedVolumesOntoDesktopCheckBox(NULL), + fShowDisksIcon(false), + fMountVolumesOntoDesktop(false), + fMountSharedVolumesOntoDesktop(false), + fIntegrateNonBootBeOSDesktops(false), + fEjectWhenUnmounting(false) { fShowDisksIconRadioButton = new BRadioButton("", B_TRANSLATE("Show Disks icon"), diff --git a/src/kits/tracker/SettingsViews.h b/src/kits/tracker/SettingsViews.h index be10b85..b201f5f 100644 --- a/src/kits/tracker/SettingsViews.h +++ b/src/kits/tracker/SettingsViews.h @@ -90,7 +90,6 @@ private: BRadioButton* fShowDisksIconRadioButton; BRadioButton* fMountVolumesOntoDesktopRadioButton; BCheckBox* fMountSharedVolumesOntoDesktopCheckBox; - BCheckBox* fIntegrateNonBootBeOSDesktopsCheckBox; bool fShowDisksIcon; bool fMountVolumesOntoDesktop; ############################################################################ Commit: e741289a95b63afa2252f3dbe949426e24df5bc7 URL: http://cgit.haiku-os.org/haiku/commit/?id=e741289 Author: John Scipione <jscipione@xxxxxxxxx> Date: Wed Jul 23 01:43:14 2014 UTC Tracker: fix uninitialized members, CID 610133 ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/SettingsViews.cpp b/src/kits/tracker/SettingsViews.cpp index 0bfa2ff..4357784 100644 --- a/src/kits/tracker/SettingsViews.cpp +++ b/src/kits/tracker/SettingsViews.cpp @@ -412,7 +412,19 @@ DesktopSettingsView::IsRevertable() const WindowsSettingsView::WindowsSettingsView() : - SettingsView("WindowsSettingsView") + SettingsView("WindowsSettingsView"), + fShowFullPathInTitleBarCheckBox(NULL), + fSingleWindowBrowseCheckBox(NULL), + fShowNavigatorCheckBox(NULL), + fOutlineSelectionCheckBox(NULL), + fSortFolderNamesFirstCheckBox(NULL), + fTypeAheadFilteringCheckBox(NULL), + fShowFullPathInTitleBar(false), + fSingleWindowBrowse(false), + fShowNavigator(false), + fTransparentSelection(false), + fSortFolderNamesFirst(false), + fTypeAheadFiltering(false) { fShowFullPathInTitleBarCheckBox = new BCheckBox("", B_TRANSLATE("Show folder location in title tab"), diff --git a/src/kits/tracker/SettingsViews.h b/src/kits/tracker/SettingsViews.h index b201f5f..c193963 100644 --- a/src/kits/tracker/SettingsViews.h +++ b/src/kits/tracker/SettingsViews.h @@ -119,7 +119,6 @@ private: BCheckBox* fShowFullPathInTitleBarCheckBox; BCheckBox* fSingleWindowBrowseCheckBox; BCheckBox* fShowNavigatorCheckBox; - BCheckBox* fShowSelectionWhenInactiveCheckBox; BCheckBox* fOutlineSelectionCheckBox; BCheckBox* fSortFolderNamesFirstCheckBox; BCheckBox* fTypeAheadFilteringCheckBox; ############################################################################ Commit: 1463a012636e0c45e5788ad69bfd9fc6fabc6e96 URL: http://cgit.haiku-os.org/haiku/commit/?id=1463a01 Author: John Scipione <jscipione@xxxxxxxxx> Date: Wed Jul 23 01:54:58 2014 UTC Tracker: Initialize pointers, CID 610135-610136 ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/TrackerSettings.cpp b/src/kits/tracker/TrackerSettings.cpp index c6cac37..e956df7 100644 --- a/src/kits/tracker/TrackerSettings.cpp +++ b/src/kits/tracker/TrackerSettings.cpp @@ -123,6 +123,28 @@ int32 ColorToValue(rgb_color color) TTrackerState::TTrackerState() : Settings("TrackerSettings", "Tracker"), + fShowDisksIcon(NULL), + fMountVolumesOntoDesktop(NULL), + fDesktopFilePanelRoot(NULL), + fMountSharedVolumesOntoDesktop(NULL), + fEjectWhenUnmounting(NULL), + fShowFullPathInTitleBar(NULL), + fSingleWindowBrowse(NULL), + fShowNavigator(NULL), + fShowSelectionWhenInactive(NULL), + fTransparentSelection(NULL), + fSortFolderNamesFirst(NULL), + fHideDotFiles(NULL), + fTypeAheadFiltering(NULL), + fRecentApplicationsCount(NULL), + fRecentDocumentsCount(NULL), + fRecentFoldersCount(NULL), + fShowVolumeSpaceBar(NULL), + fUsedSpaceColor(NULL), + fFreeSpaceColor(NULL), + fWarningSpaceColor(NULL), + fDontMoveFilesToTrash(NULL), + fAskBeforeDeleteFile(NULL), fInited(false), fSettingsLoaded(false) { @@ -131,7 +153,31 @@ TTrackerState::TTrackerState() TTrackerState::TTrackerState(const TTrackerState&) : - Settings("", "") + Settings("", ""), + fShowDisksIcon(NULL), + fMountVolumesOntoDesktop(NULL), + fDesktopFilePanelRoot(NULL), + fMountSharedVolumesOntoDesktop(NULL), + fEjectWhenUnmounting(NULL), + fShowFullPathInTitleBar(NULL), + fSingleWindowBrowse(NULL), + fShowNavigator(NULL), + fShowSelectionWhenInactive(NULL), + fTransparentSelection(NULL), + fSortFolderNamesFirst(NULL), + fHideDotFiles(NULL), + fTypeAheadFiltering(NULL), + fRecentApplicationsCount(NULL), + fRecentDocumentsCount(NULL), + fRecentFoldersCount(NULL), + fShowVolumeSpaceBar(NULL), + fUsedSpaceColor(NULL), + fFreeSpaceColor(NULL), + fWarningSpaceColor(NULL), + fDontMoveFilesToTrash(NULL), + fAskBeforeDeleteFile(NULL), + fInited(false), + fSettingsLoaded(false) { // Placeholder copy constructor to prevent others from accidentally using // the default copy constructor. Note, the DEBUGGER call is for the off ############################################################################ Commit: 3557a902709efed6b7dcd7337fb9768130ac7d49 URL: http://cgit.haiku-os.org/haiku/commit/?id=3557a90 Author: John Scipione <jscipione@xxxxxxxxx> Date: Wed Jul 23 02:11:24 2014 UTC Tracker: style fixes, whitespace only ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/ViewState.h b/src/kits/tracker/ViewState.h index 1403d1a..43ce32c 100644 --- a/src/kits/tracker/ViewState.h +++ b/src/kits/tracker/ViewState.h @@ -45,54 +45,54 @@ const int32 kColumnStateArchiveVersion = 22; // bump version when layout or size changes class BColumn { - public: - BColumn(const char* title, float offset, float width, - alignment align, const char* attributeName, uint32 attrType, - const char* displayAs, bool statField, bool editable); - BColumn(const char* title, float offset, float width, - alignment align, const char* attributeName, uint32 attrType, - bool statField, bool editable); - ~BColumn(); - - BColumn(BMallocIO* stream, int32 version, bool endianSwap = false); - BColumn(const BMessage &, int32 index = 0); - static BColumn* InstantiateFromStream(BMallocIO* stream, - bool endianSwap = false); - static BColumn* InstantiateFromMessage(const BMessage &archive, - int32 index = 0); - void ArchiveToStream(BMallocIO* stream) const; - void ArchiveToMessage(BMessage &) const; - - const char* Title() const; - float Offset() const; - float Width() const; - alignment Alignment() const; - const char* AttrName() const; - uint32 AttrType() const; - const char* DisplayAs() const; - uint32 AttrHash() const; - bool StatField() const; - bool Editable() const; - - void SetOffset(float); - void SetWidth(float); - - private: - void _Init(const char* title, float offset, float width, - alignment align, const char* attributeName, uint32 attrType, - const char* displayAs, bool statField, bool editable); - static BColumn* _Sanitize(BColumn* column); - - BString fTitle; - float fOffset; - float fWidth; - alignment fAlignment; - BString fAttrName; - BString fDisplayAs; - uint32 fAttrHash; - uint32 fAttrType; - bool fStatField; - bool fEditable; +public: + BColumn(const char* title, float offset, float width, + alignment align, const char* attributeName, uint32 attrType, + const char* displayAs, bool statField, bool editable); + BColumn(const char* title, float offset, float width, + alignment align, const char* attributeName, uint32 attrType, + bool statField, bool editable); + ~BColumn(); + + BColumn(BMallocIO* stream, int32 version, bool endianSwap = false); + BColumn(const BMessage &, int32 index = 0); + static BColumn* InstantiateFromStream(BMallocIO* stream, + bool endianSwap = false); + static BColumn* InstantiateFromMessage(const BMessage &archive, + int32 index = 0); + void ArchiveToStream(BMallocIO* stream) const; + void ArchiveToMessage(BMessage &) const; + + const char* Title() const; + float Offset() const; + float Width() const; + alignment Alignment() const; + const char* AttrName() const; + uint32 AttrType() const; + const char* DisplayAs() const; + uint32 AttrHash() const; + bool StatField() const; + bool Editable() const; + + void SetOffset(float); + void SetWidth(float); + +private: + void _Init(const char* title, float offset, float width, + alignment align, const char* attributeName, uint32 attrType, + const char* displayAs, bool statField, bool editable); + static BColumn* _Sanitize(BColumn* column); + + BString fTitle; + float fOffset; + float fWidth; + alignment fAlignment; + BString fAttrName; + BString fDisplayAs; + uint32 fAttrHash; + uint32 fAttrType; + bool fStatField; + bool fEditable; }; @@ -100,72 +100,72 @@ const int32 kViewStateArchiveVersion = 11; // bump version when layout or size changes class BViewState { - public: - BViewState(); - - BViewState(BMallocIO* stream, bool endianSwap = false); - BViewState(const BMessage &message); - static BViewState* InstantiateFromStream(BMallocIO* stream, - bool endianSwap = false); - static BViewState* InstantiateFromMessage(const BMessage &message); - void ArchiveToStream(BMallocIO* stream) const; - void ArchiveToMessage(BMessage &message) const; - - uint32 ViewMode() const; - uint32 LastIconMode() const; - uint32 IconSize() const; - uint32 LastIconSize() const; - BPoint ListOrigin() const; - BPoint IconOrigin() const; - uint32 PrimarySort() const; - uint32 SecondarySort() const; - uint32 PrimarySortType() const; - uint32 SecondarySortType() const; - bool ReverseSort() const; - - void SetViewMode(uint32); - void SetLastIconMode(uint32); - void SetIconSize(uint32); - void SetLastIconSize(uint32); - void SetListOrigin(BPoint); - void SetIconOrigin(BPoint); - void SetPrimarySort(uint32); - void SetSecondarySort(uint32); - void SetPrimarySortType(uint32); - void SetSecondarySortType(uint32); - void SetReverseSort(bool); - - bool StateNeedsSaving(); - - private: - static BViewState* _Sanitize(BViewState* state, bool fixOnly = false); - - uint32 fViewMode; - uint32 fLastIconMode; - uint32 fIconSize; - uint32 fLastIconSize; - BPoint fListOrigin; - BPoint fIconOrigin; - uint32 fPrimarySortAttr; - uint32 fSecondarySortAttr; - uint32 fPrimarySortType; - uint32 fSecondarySortType; - bool fReverseSort; - - void _Init(); - void _StorePreviousState(); - - uint32 fPreviousViewMode; - uint32 fPreviousLastIconMode; - uint32 fPreviousIconSize; - uint32 fPreviousLastIconSize; - BPoint fPreviousListOrigin; - BPoint fPreviousIconOrigin; - uint32 fPreviousPrimarySortAttr; - uint32 fPreviousSecondarySortAttr; - uint32 fPreviousPrimarySortType; - uint32 fPreviousSecondarySortType; - bool fPreviousReverseSort; +public: + BViewState(); + + BViewState(BMallocIO* stream, bool endianSwap = false); + BViewState(const BMessage &message); + static BViewState* InstantiateFromStream(BMallocIO* stream, + bool endianSwap = false); + static BViewState* InstantiateFromMessage(const BMessage &message); + void ArchiveToStream(BMallocIO* stream) const; + void ArchiveToMessage(BMessage &message) const; + + uint32 ViewMode() const; + uint32 LastIconMode() const; + uint32 IconSize() const; + uint32 LastIconSize() const; + BPoint ListOrigin() const; + BPoint IconOrigin() const; + uint32 PrimarySort() const; + uint32 SecondarySort() const; + uint32 PrimarySortType() const; + uint32 SecondarySortType() const; + bool ReverseSort() const; + + void SetViewMode(uint32); + void SetLastIconMode(uint32); + void SetIconSize(uint32); + void SetLastIconSize(uint32); + void SetListOrigin(BPoint); + void SetIconOrigin(BPoint); + void SetPrimarySort(uint32); + void SetSecondarySort(uint32); + void SetPrimarySortType(uint32); + void SetSecondarySortType(uint32); + void SetReverseSort(bool); + + bool StateNeedsSaving(); + +private: + static BViewState* _Sanitize(BViewState* state, bool fixOnly = false); + + uint32 fViewMode; + uint32 fLastIconMode; + uint32 fIconSize; + uint32 fLastIconSize; + BPoint fListOrigin; + BPoint fIconOrigin; + uint32 fPrimarySortAttr; + uint32 fSecondarySortAttr; + uint32 fPrimarySortType; + uint32 fSecondarySortType; + bool fReverseSort; + + void _Init(); + void _StorePreviousState(); + + uint32 fPreviousViewMode; + uint32 fPreviousLastIconMode; + uint32 fPreviousIconSize; + uint32 fPreviousLastIconSize; + BPoint fPreviousListOrigin; + BPoint fPreviousIconOrigin; + uint32 fPreviousPrimarySortAttr; + uint32 fPreviousSecondarySortAttr; + uint32 fPreviousPrimarySortType; + uint32 fPreviousSecondarySortType; + bool fPreviousReverseSort; }; ############################################################################ Commit: 2660268936cf5334c8d16b36e8c68a1469312369 URL: http://cgit.haiku-os.org/haiku/commit/?id=2660268 Author: John Scipione <jscipione@xxxxxxxxx> Date: Wed Jul 23 02:11:41 2014 UTC Tracker: Set default values in case of error ...for BColumn. Fixes CID 602478 and CID 602479 ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/ViewState.cpp b/src/kits/tracker/ViewState.cpp index db8a085..dfedb2a 100644 --- a/src/kits/tracker/ViewState.cpp +++ b/src/kits/tracker/ViewState.cpp @@ -132,16 +132,42 @@ BColumn::BColumn(BMallocIO* stream, int32 version, bool endianSwap) BColumn::BColumn(const BMessage &message, int32 index) { - message.FindString(kColumnTitleName, index, &fTitle); - message.FindFloat(kColumnOffsetName, index, &fOffset); - message.FindFloat(kColumnWidthName, index, &fWidth); - message.FindInt32(kColumnAlignmentName, index, (int32*)&fAlignment); - message.FindString(kColumnAttrName, index, &fAttrName); - message.FindInt32(kColumnAttrHashName, index, (int32*)&fAttrHash); - message.FindInt32(kColumnAttrTypeName, index, (int32*)&fAttrType); - message.FindString(kColumnDisplayAsName, index, &fDisplayAs); - message.FindBool(kColumnStatFieldName, index, &fStatField); - message.FindBool(kColumnEditableName, index, &fEditable); + if (message.FindString(kColumnTitleName, index, &fTitle) != B_OK) + fTitle.SetTo(B_EMPTY_STRING); + + if (message.FindFloat(kColumnOffsetName, index, &fOffset) != B_OK) + fOffset = -1.0f; + + if (message.FindFloat(kColumnWidthName, index, &fWidth) != B_OK) + fWidth = -1.0f; + + if (message.FindInt32(kColumnAlignmentName, index, (int32*)&fAlignment) + != B_OK) { + fAlignment = B_ALIGN_LEFT; + } + + if (message.FindString(kColumnAttrName, index, &fAttrName) != B_OK) + fAttrName = BString(B_EMPTY_STRING); + + if (message.FindInt32(kColumnAttrHashName, index, (int32*)&fAttrHash) + != B_OK) { + fAttrHash = 0; + } + + if (message.FindInt32(kColumnAttrTypeName, index, (int32*)&fAttrType) + != B_OK) { + fAttrType = 0; + } + + if (message.FindString(kColumnDisplayAsName, index, &fDisplayAs) != B_OK) + fDisplayAs.SetTo(B_EMPTY_STRING); + + if (message.FindBool(kColumnStatFieldName, index, &fStatField) != B_OK) + fStatField = false; + + if (message.FindBool(kColumnEditableName, index, &fEditable) != B_OK) + fEditable = false; + } ############################################################################ Commit: 0cf10e9dce2d49fa1e6bb9700c3d2325d98e316f URL: http://cgit.haiku-os.org/haiku/commit/?id=0cf10e9 Author: John Scipione <jscipione@xxxxxxxxx> Date: Wed Jul 23 02:23:02 2014 UTC Tracker: Style fixes to NavMenu.h Pointer style, whitespace. Convert TrackingHookData from a class to a struct (all members public) ---------------------------------------------------------------------------- diff --git a/headers/private/tracker/NavMenu.h b/headers/private/tracker/NavMenu.h index 0726c36..e1c45d1 100644 --- a/headers/private/tracker/NavMenu.h +++ b/headers/private/tracker/NavMenu.h @@ -49,6 +49,7 @@ All rights reserved. template<class T> class BObjectList; class BMenuItem; + namespace BPrivate { class Model; @@ -57,94 +58,94 @@ class ModelMenuItem; class EntryListBase; -class TrackingHookData { - public: - TrackingHookData() - : - fTrackingHook(NULL), - fDragMessage(NULL) - { - } +struct TrackingHookData { + TrackingHookData() + : + fTrackingHook(NULL), + fDragMessage(NULL) + { + } - bool (*fTrackingHook)(BMenu *, void *); - BMessenger fTarget; - const BMessage *fDragMessage; + bool (*fTrackingHook)(BMenu*, void*); + BMessenger fTarget; + const BMessage* fDragMessage; }; class BNavMenu : public BSlowMenu { - public: - BNavMenu(const char* title, uint32 message, const BHandler *, - BWindow *parentWindow = NULL, const BObjectList<BString> *list = NULL); - BNavMenu(const char* title, uint32 message, const BMessenger &, - BWindow *parentWindow = NULL, const BObjectList<BString> *list = NULL); - // parentWindow, if specified, will be closed if nav menu item invoked - // with option held down +public: + BNavMenu(const char* title, uint32 message, const BHandler*, + BWindow* parentWindow = NULL, const BObjectList<BString>* list = NULL); + BNavMenu(const char* title, uint32 message, const BMessenger&, + BWindow* parentWindow = NULL, const BObjectList<BString>* list = NULL); + // parentWindow, if specified, will be closed if nav menu item invoked + // with option held down - virtual ~BNavMenu(); + virtual ~BNavMenu(); - virtual void AttachedToWindow(); - virtual void DetachedFromWindow(); + virtual void AttachedToWindow(); + virtual void DetachedFromWindow(); - void SetNavDir(const entry_ref *); - void ForceRebuild(); - bool NeedsToRebuild() const; - // will cause menu to get rebuilt next time it is shown + void SetNavDir(const entry_ref*); + void ForceRebuild(); + bool NeedsToRebuild() const; + // will cause menu to get rebuilt next time it is shown - virtual void ResetTargets(); - void SetTarget(const BMessenger &); - BMessenger Target(); + virtual void ResetTargets(); + void SetTarget(const BMessenger&); + BMessenger Target(); - void SetTypesList(const BObjectList<BString> *list); - const BObjectList<BString> *TypesList() const; + void SetTypesList(const BObjectList<BString>* list); + const BObjectList<BString>* TypesList() const; - void AddNavDir(const Model *model, uint32 what, BHandler *target, - bool populateSubmenu); + void AddNavDir(const Model* model, uint32 what, BHandler* target, + bool populateSubmenu); - void AddNavParentDir(const char *name, const Model *model, uint32 what, BHandler *target); - void AddNavParentDir(const Model *model, uint32 what, BHandler *target); - void SetShowParent(bool show); + void AddNavParentDir(const char* name, const Model* model, uint32 what, + BHandler* target); + void AddNavParentDir(const Model* model, uint32 what, BHandler* target); + void SetShowParent(bool show); - static int32 GetMaxMenuWidth(); + static int32 GetMaxMenuWidth(); - static int CompareFolderNamesFirstOne(const BMenuItem *, const BMenuItem *); - static int CompareOne(const BMenuItem *, const BMenuItem *); + static int CompareFolderNamesFirstOne(const BMenuItem*, const BMenuItem*); + static int CompareOne(const BMenuItem*, const BMenuItem*); - static ModelMenuItem *NewModelItem(Model *, const BMessage *, const BMessenger &, - bool suppressFolderHierarchy=false, BContainerWindow * = NULL, - const BObjectList<BString> *typeslist = NULL, - TrackingHookData *hook = NULL); + static ModelMenuItem* NewModelItem(Model*, const BMessage*, + const BMessenger&, bool suppressFolderHierarchy = false, + BContainerWindow* = NULL, const BObjectList<BString>* typeslist = NULL, + TrackingHookData* hook = NULL); - TrackingHookData *InitTrackingHook(bool (*hookfunction)(BMenu *, void *), - const BMessenger *target, const BMessage *dragMessage); + TrackingHookData* InitTrackingHook(bool (*hookfunction)(BMenu*, void*), + const BMessenger* target, const BMessage* dragMessage); - protected: - virtual bool StartBuildingItemList(); - virtual bool AddNextItem(); - virtual void DoneBuildingItemList(); - virtual void ClearMenuBuildingState(); +protected: + virtual bool StartBuildingItemList(); + virtual bool AddNextItem(); + virtual void DoneBuildingItemList(); + virtual void ClearMenuBuildingState(); - void BuildVolumeMenu(); + void BuildVolumeMenu(); - void AddOneItem(Model *); - void AddRootItemsIfNeeded(); - void AddTrashItem(); - static void SetTrackingHookDeep(BMenu *, bool (*)(BMenu *, void *), void *); + void AddOneItem(Model*); + void AddRootItemsIfNeeded(); + void AddTrashItem(); + static void SetTrackingHookDeep(BMenu*, bool (*)(BMenu*, void*), void*); - entry_ref fNavDir; - BMessage fMessage; - BMessenger fMessenger; - BWindow *fParentWindow; + entry_ref fNavDir; + BMessage fMessage; + BMessenger fMessenger; + BWindow* fParentWindow; - // menu building state - uint8 fFlags; - BObjectList<BMenuItem> *fItemList; - EntryListBase *fContainer; - bool fIteratingDesktop; + // menu building state + uint8 fFlags; + BObjectList<BMenuItem>* fItemList; + EntryListBase* fContainer; + bool fIteratingDesktop; - BObjectList<BString> *fTypesList; + BObjectList<BString>* fTypesList; - TrackingHookData fTrackingHook; + TrackingHookData fTrackingHook; }; // Spring Loaded Folder convenience routines @@ -165,4 +166,5 @@ _IMPEXP_TRACKER void SpringLoadedFolderCacheDragData(const BMessage *incoming, using namespace BPrivate; + #endif // NAV_MENU_H ############################################################################ Commit: a98019cd3f0f0a47c9f4b9449963d9a3df9509de URL: http://cgit.haiku-os.org/haiku/commit/?id=a98019c Author: John Scipione <jscipione@xxxxxxxxx> Date: Wed Jul 23 02:25:14 2014 UTC Tracker: init fIteratingDesktop CID 609644, 609833 ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/NavMenu.cpp b/src/kits/tracker/NavMenu.cpp index 70d4ab7..e333dde 100644 --- a/src/kits/tracker/NavMenu.cpp +++ b/src/kits/tracker/NavMenu.cpp @@ -267,6 +267,7 @@ BNavMenu::BNavMenu(const char* title, uint32 message, const BHandler* target, fFlags(0), fItemList(NULL), fContainer(NULL), + fIteratingDesktop(false), fTypesList(new BObjectList<BString>(10, true)) { if (list != NULL) @@ -301,6 +302,7 @@ BNavMenu::BNavMenu(const char* title, uint32 message, fFlags(0), fItemList(NULL), fContainer(NULL), + fIteratingDesktop(false), fTypesList(new BObjectList<BString>(10, true)) { if (list != NULL) ############################################################################ Commit: 6073b1d56d1695d3e4703437d7748166bbb05f18 URL: http://cgit.haiku-os.org/haiku/commit/?id=6073b1d Author: John Scipione <jscipione@xxxxxxxxx> Date: Wed Jul 23 02:33:00 2014 UTC Interface Kit: fix bad free, CID 611174 ---------------------------------------------------------------------------- diff --git a/src/kits/interface/Picture.cpp b/src/kits/interface/Picture.cpp index fee1fce..064a51a 100644 --- a/src/kits/interface/Picture.cpp +++ b/src/kits/interface/Picture.cpp @@ -226,7 +226,7 @@ BPicture::_InitData() BPicture::~BPicture() { BAutolock _(sPictureListLock); - sPictureList.RemoveItem(this); + sPictureList.RemoveItem(this, false); _DisposeData(); } ############################################################################ Commit: d5451cc8fcdb5bec3c68cb86bc69b5cda331a5c2 URL: http://cgit.haiku-os.org/haiku/commit/?id=d5451cc Author: John Scipione <jscipione@xxxxxxxxx> Date: Wed Jul 23 02:42:01 2014 UTC Tracker: fix negative buffer size, CID 610926 ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/TrackerInitialState.cpp b/src/kits/tracker/TrackerInitialState.cpp index 78a7326..73a44b1 100644 --- a/src/kits/tracker/TrackerInitialState.cpp +++ b/src/kits/tracker/TrackerInitialState.cpp @@ -329,10 +329,10 @@ ExtraAttributeLazyInstaller::AddExtraAttribute(const char* publicName, static void InstallTemporaryBackgroundImages(BNode* node, BMessage* message) { - int32 size = message->FlattenedSize(); - + ssize_t size = message->FlattenedSize(); try { - char* buffer = new char[size]; + ThrowIfNotSize(size); + char* buffer = new char[(size_t)size]; message->Flatten(buffer, size); node->WriteAttr(kBackgroundImageInfo, B_MESSAGE_TYPE, 0, buffer, (size_t)size); ############################################################################ Commit: 1aa5e7976e46396125a78d3407c3b1d6f233a98d URL: http://cgit.haiku-os.org/haiku/commit/?id=1aa5e79 Author: John Scipione <jscipione@xxxxxxxxx> Date: Wed Jul 23 02:51:29 2014 UTC Tracker: check return value, CID 610641 ... if failure, set to blank BMessage(). ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/TrackerInitialState.cpp b/src/kits/tracker/TrackerInitialState.cpp index 73a44b1..a7c0065 100644 --- a/src/kits/tracker/TrackerInitialState.cpp +++ b/src/kits/tracker/TrackerInitialState.cpp @@ -263,6 +263,7 @@ public: int32 alignment, bool extra); status_t InitCheck() const; + public: BMimeType fMimeType; BMessage fExtraAttrs; @@ -280,15 +281,19 @@ ExtraAttributeLazyInstaller::ExtraAttributeLazyInstaller(const char* type) fMimeType(type), fDirty(false) { - if (fMimeType.InitCheck() == B_OK) - fMimeType.GetAttrInfo(&fExtraAttrs); + if (fMimeType.InitCheck() != B_OK + || fMimeType.GetAttrInfo(&fExtraAttrs) != B_OK) { + fExtraAttrs = BMessage(); + } } ExtraAttributeLazyInstaller::~ExtraAttributeLazyInstaller() { - if (fMimeType.InitCheck() == B_OK && fDirty) - fMimeType.SetAttrInfo(&fExtraAttrs); + if (fMimeType.InitCheck() == B_OK && fDirty + && fMimeType.SetAttrInfo(&fExtraAttrs) != B_OK) { + fExtraAttrs = BMessage(); + } } ############################################################################ Commit: d069f646f17c657b46eed0eeb5650dcc439fd47e URL: http://cgit.haiku-os.org/haiku/commit/?id=d069f64 Author: John Scipione <jscipione@xxxxxxxxx> Date: Wed Jul 23 03:29:06 2014 UTC Tracker: AttributeStream style fixes Rename cloneThis and attr to other ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/AttributeStream.cpp b/src/kits/tracker/AttributeStream.cpp index f07213a..c27b0f4 100644 --- a/src/kits/tracker/AttributeStream.cpp +++ b/src/kits/tracker/AttributeStream.cpp @@ -48,10 +48,11 @@ All rights reserved. // #pragma mark - AttributeInfo -AttributeInfo::AttributeInfo(const AttributeInfo &cloneThis) : - fName(cloneThis.fName), - fInfo(cloneThis.fInfo) +AttributeInfo::AttributeInfo(const AttributeInfo& other) + : + fName(other.fName), + fInfo(other.fInfo) { } @@ -96,10 +97,10 @@ AttributeInfo::Size() const void -AttributeInfo::SetTo(const AttributeInfo &attr) +AttributeInfo::SetTo(const AttributeInfo& other) { - fName = attr.fName; - fInfo = attr.fInfo; + fName = other.fName; + fInfo = other.fInfo; } diff --git a/src/kits/tracker/AttributeStream.h b/src/kits/tracker/AttributeStream.h index fd749d8..8ed76ff 100644 --- a/src/kits/tracker/AttributeStream.h +++ b/src/kits/tracker/AttributeStream.h @@ -75,13 +75,13 @@ class AttributeInfo { public: AttributeInfo() {} - AttributeInfo(const AttributeInfo &); - AttributeInfo(const char*, attr_info); - AttributeInfo(const char*, uint32, off_t); + AttributeInfo(const AttributeInfo& other); + AttributeInfo(const char* name, attr_info info); + AttributeInfo(const char* name, uint32 type, off_t size); - void SetTo(const AttributeInfo &); - void SetTo(const char*, attr_info); - void SetTo(const char*, uint32, off_t); + void SetTo(const AttributeInfo& other); + void SetTo(const char* name, attr_info info); + void SetTo(const char* name, uint32 type, off_t size); const char* Name() const; uint32 Type() const; off_t Size() const; ############################################################################ Commit: 49d5d59cab39e03705287a2705b6839d110a1a59 URL: http://cgit.haiku-os.org/haiku/commit/?id=49d5d59 Author: John Scipione <jscipione@xxxxxxxxx> Date: Wed Jul 23 03:30:41 2014 UTC Tracker: AttributeStream: implement default constructor Set members to dummy values CID 610118 ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/AttributeStream.cpp b/src/kits/tracker/AttributeStream.cpp index c27b0f4..51e4ee7 100644 --- a/src/kits/tracker/AttributeStream.cpp +++ b/src/kits/tracker/AttributeStream.cpp @@ -48,7 +48,15 @@ All rights reserved. // #pragma mark - AttributeInfo +AttributeInfo::AttributeInfo() : + fName("") +{ + fInfo.type = B_RAW_TYPE; + fInfo.size = 0; +} + + AttributeInfo::AttributeInfo(const AttributeInfo& other) : fName(other.fName), @@ -70,8 +78,8 @@ AttributeInfo::AttributeInfo(const char* name, uint32 type, off_t size) : fName(name) { - fInfo.size = size; fInfo.type = type; + fInfo.size = size; } diff --git a/src/kits/tracker/AttributeStream.h b/src/kits/tracker/AttributeStream.h index 8ed76ff..7738ee2 100644 --- a/src/kits/tracker/AttributeStream.h +++ b/src/kits/tracker/AttributeStream.h @@ -73,8 +73,7 @@ struct AttributeTemplate { class AttributeInfo { // utility class for internal attribute description public: - AttributeInfo() - {} + AttributeInfo(); AttributeInfo(const AttributeInfo& other); AttributeInfo(const char* name, attr_info info); AttributeInfo(const char* name, uint32 type, off_t size); ############################################################################ Commit: 1bea02aca1f17ccc01064bb502a1a40d793eb100 URL: http://cgit.haiku-os.org/haiku/commit/?id=1bea02a Author: John Scipione <jscipione@xxxxxxxxx> Date: Wed Jul 23 03:36:24 2014 UTC Tracker: init fTime to 0, CID 610125 ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/NodeWalker.cpp b/src/kits/tracker/NodeWalker.cpp index 836164e..33f0cf9 100644 --- a/src/kits/tracker/NodeWalker.cpp +++ b/src/kits/tracker/NodeWalker.cpp @@ -632,7 +632,8 @@ TVolWalker::Rewind() TQueryWalker::TQueryWalker(const char* predicate) : - TWalker(), fQuery(), fVolRoster(), fVol() + TWalker(), + fTime(0), { fPredicate = strdup(predicate); NextVolume(); ############################################################################ Commit: f68bec60cf1da48065efa5e412539b88a3406159 URL: http://cgit.haiku-os.org/haiku/commit/?id=f68bec6 Author: John Scipione <jscipione@xxxxxxxxx> Date: Wed Jul 23 03:40:01 2014 UTC Tracker: init times to 0, CID 610124 ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/TaskLoop.cpp b/src/kits/tracker/TaskLoop.cpp index 1027faf..8c4a974 100644 --- a/src/kits/tracker/TaskLoop.cpp +++ b/src/kits/tracker/TaskLoop.cpp @@ -216,19 +216,22 @@ PeriodicDelayedTaskWithTimeout::RunIfNeeded(bigtime_t currentTime) } +// #pragma mark - RunWhenIdleTask + + RunWhenIdleTask::RunWhenIdleTask(FunctionObjectWithResult<bool>* functor, bigtime_t initialDelay, bigtime_t idleFor, bigtime_t heartBeat) : PeriodicDelayedTask(functor, initialDelay, heartBeat), fIdleFor(idleFor), - fState(kInitialDelay) + fState(kInitialDelay), + fActivityLevelStart(0), + fActivityLevel(0), + fLastCPUTooBusyTime(0) { } -// #pragma mark - RunWhenIdleTask - - RunWhenIdleTask::~RunWhenIdleTask() { } ############################################################################ Commit: c8c3cf03e7814a163346479dad3232f5d1103a77 URL: http://cgit.haiku-os.org/haiku/commit/?id=c8c3cf0 Author: John Scipione <jscipione@xxxxxxxxx> Date: Wed Jul 23 04:04:31 2014 UTC Tracker: init default member values, CID 609642 ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/FavoritesMenu.cpp b/src/kits/tracker/FavoritesMenu.cpp index 22de874..f6ffd3a 100644 --- a/src/kits/tracker/FavoritesMenu.cpp +++ b/src/kits/tracker/FavoritesMenu.cpp @@ -74,7 +74,12 @@ FavoritesMenu::FavoritesMenu(const char* title, BMessage* openFolderMessage, fOpenFolderMessage(openFolderMessage), fOpenFileMessage(openFileMessage), fTarget(target), + fState(kStart), + fIndex(-1), + fSectionItemCount(-1), + fAddedSeparatorForSection(false), fContainer(NULL), + fItemList(NULL), fInitialItemCount(0), fIsSavePanel(isSavePanel), fRefFilter(filter) ############################################################################ Commit: acd00fc5d4b13b2243f1fba1ca67019309392997 URL: http://cgit.haiku-os.org/haiku/commit/?id=acd00fc Author: John Scipione <jscipione@xxxxxxxxx> Date: Wed Jul 23 04:05:05 2014 UTC Tracker: init fTime to 0, CID 610125 ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/NodeWalker.cpp b/src/kits/tracker/NodeWalker.cpp index 33f0cf9..949d142 100644 --- a/src/kits/tracker/NodeWalker.cpp +++ b/src/kits/tracker/NodeWalker.cpp @@ -633,7 +633,7 @@ TVolWalker::Rewind() TQueryWalker::TQueryWalker(const char* predicate) : TWalker(), - fTime(0), + fTime(0) { fPredicate = strdup(predicate); NextVolume(); ############################################################################ Commit: 8bc62a0a1247f4697b3be07d51a2670ad23af21b URL: http://cgit.haiku-os.org/haiku/commit/?id=8bc62a0 Author: John Scipione <jscipione@xxxxxxxxx> Date: Wed Jul 23 04:23:17 2014 UTC Tracker: RegExp style fixes, pointer style ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/RegExp.cpp b/src/kits/tracker/RegExp.cpp index 3338d28..7d42330 100644 --- a/src/kits/tracker/RegExp.cpp +++ b/src/kits/tracker/RegExp.cpp @@ -222,7 +222,7 @@ RegExp::RegExp(const char* pattern) } -RegExp::RegExp(const BString &pattern) +RegExp::RegExp(const BString& pattern) : fError(B_OK), fRegExp(NULL) @@ -255,7 +255,7 @@ RegExp::SetTo(const char* pattern) status_t -RegExp::SetTo(const BString &pattern) +RegExp::SetTo(const BString& pattern) { fError = B_OK; free(fRegExp); @@ -275,7 +275,7 @@ RegExp::Matches(const char* string) const bool -RegExp::Matches(const BString &string) const +RegExp::Matches(const BString& string) const { if (fRegExp == NULL) return false; diff --git a/src/kits/tracker/RegExp.h b/src/kits/tracker/RegExp.h index 7142028..eb425ed 100644 --- a/src/kits/tracker/RegExp.h +++ b/src/kits/tracker/RegExp.h @@ -114,10 +114,10 @@ public: status_t InitCheck() const; status_t SetTo(const char*); - status_t SetTo(const BString &); + status_t SetTo(const BString&); bool Matches(const char* string) const; - bool Matches(const BString &) const; + bool Matches(const BString&) const; int32 RunMatcher(regexp*, const char*) const; regexp* Compile(const char*); ############################################################################ Commit: 23d59b8742be4992a5d1acc152a76b93eed24184 URL: http://cgit.haiku-os.org/haiku/commit/?id=23d59b8 Author: John Scipione <jscipione@xxxxxxxxx> Date: Wed Jul 23 04:23:53 2014 UTC Tracker: RegExp, set initial member values CID 609956 ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/RegExp.cpp b/src/kits/tracker/RegExp.cpp index 7d42330..7e98f40 100644 --- a/src/kits/tracker/RegExp.cpp +++ b/src/kits/tracker/RegExp.cpp @@ -208,7 +208,16 @@ int32 regnarrate = 0; RegExp::RegExp() : fError(B_OK), - fRegExp(NULL) + fRegExp(NULL), + fInputScanPointer(NULL), + fParenthesisCount(0), + fDummy('\0'), + fCodeEmitPointer(NULL), + fCodeSize(0), + fStringInputPointer(NULL), + fRegBol(NULL), + fStartPArrayPointer(NULL), + fEndPArrayPointer(NULL) { } ############################################################################ Commit: d6c4e7a6beff2569b0ab8335f70d71d8d5213487 URL: http://cgit.haiku-os.org/haiku/commit/?id=d6c4e7a Author: John Scipione <jscipione@xxxxxxxxx> Date: Wed Jul 23 04:29:04 2014 UTC Tracker: init default member values, CID 609845 ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/RecentItems.cpp b/src/kits/tracker/RecentItems.cpp index ee35003..18c18b1 100644 --- a/src/kits/tracker/RecentItems.cpp +++ b/src/kits/tracker/RecentItems.cpp @@ -50,14 +50,7 @@ All rights reserved. class RecentItemsMenu : public BSlowMenu { public: RecentItemsMenu(const char* title, BMessage* openMessage, - BHandler* itemTarget, int32 maxItems) - : - BSlowMenu(title), - fTargetMesage(openMessage), - fItemTarget(itemTarget), - fMaxCount(maxItems) - { - } + BHandler* itemTarget, int32 maxItems); virtual ~RecentItemsMenu(); virtual bool StartBuildingItemList(); @@ -67,9 +60,14 @@ public: protected: virtual const BMessage* FileMessage() - { return fTargetMesage; } + { + return fTargetMesage; + } + virtual const BMessage* ContainerMessage() - { return fTargetMesage; } + { + return fTargetMesage; + } BRecentItemsList* fIterator; BMessage* fTargetMesage; @@ -121,6 +119,20 @@ public: // #pragma mark - RecentItemsMenu +RecentItemsMenu::RecentItemsMenu(const char* title, BMessage* openMessage, + BHandler* itemTarget, int32 maxItems) + : + BSlowMenu(title), + fIterator(NULL), + fTargetMesage(openMessage), + fItemTarget(itemTarget), + fCount(-1), + fSanityCount(-1), + fMaxCount(maxItems) +{ +} + + RecentItemsMenu::~RecentItemsMenu() { delete fIterator; ############################################################################ Commit: a45f995d3ccb168052aa8fd7189b36505c6752ed URL: http://cgit.haiku-os.org/haiku/commit/?id=a45f995 Author: John Scipione <jscipione@xxxxxxxxx> Date: Wed Jul 23 04:34:52 2014 UTC Tracker: init member vars, CID 609834 ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/QueryPoseView.h b/src/kits/tracker/QueryPoseView.h index 533654e..48b7989 100644 --- a/src/kits/tracker/QueryPoseView.h +++ b/src/kits/tracker/QueryPoseView.h @@ -46,6 +46,7 @@ namespace BPrivate { class BQueryContainerWindow; class QueryEntryListCollection; + class BQueryPoseView : public BPoseView { public: BQueryPoseView(Model*, BRect, uint32 resizeMask = B_FOLLOW_ALL); @@ -103,24 +104,30 @@ class QueryEntryListCollection : public EntryListBase { class QueryListRep { public: QueryListRep(BObjectList<BQuery>* queryList) - : fQueryList(queryList), - fRefCount(0), - fShowResultsFromTrash(0), - fOldPoseList(NULL) - {} + : + fQueryList(queryList), + fRefCount(0), + fShowResultsFromTrash(false), + fQueryListIndex(-1), + fDynamicDateQuery(false), + fRefreshEveryHour(false), + fRefreshEveryMinute(false), + fOldPoseList(NULL) + { + } ~QueryListRep() - { - ASSERT(fRefCount <= 0); - delete fQueryList; - delete fOldPoseList; - } + { + ASSERT(fRefCount <= 0); + delete fQueryList; + delete fOldPoseList; + } BObjectList<BQuery>* OpenQueryList() - { - fRefCount++; - return fQueryList; - } + { + fRefCount++; + return fQueryList; + } bool CloseQueryList() { @@ -149,10 +156,14 @@ public: QueryEntryListCollection* Clone(); BObjectList<BQuery>* QueryList() const - { return fQueryListRep->fQueryList; } + { + return fQueryListRep->fQueryList; + } PoseList* OldPoseList() const - { return fQueryListRep->fOldPoseList; } + { + return fQueryListRep->fOldPoseList; + } void ClearOldPoseList(); virtual status_t GetNextEntry(BEntry* entry, bool traverse = false); ############################################################################ Commit: ec23596a730255f4ba8aa2e7777b339d6c2fb1fe URL: http://cgit.haiku-os.org/haiku/commit/?id=ec23596 Author: John Scipione <jscipione@xxxxxxxxx> Date: Wed Jul 23 04:51:27 2014 UTC Tracker: init member vars, CID 991720 ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/StatusWindow.cpp b/src/kits/tracker/StatusWindow.cpp index 9b770dc..02c8d12 100644 --- a/src/kits/tracker/StatusWindow.cpp +++ b/src/kits/tracker/StatusWindow.cpp @@ -432,8 +432,11 @@ BStatusWindow::WindowActivated(bool state) BStatusView::BStatusView(BRect bounds, thread_id thread, StatusWindowState type) : BView(bounds, "StatusView", B_FOLLOW_NONE, B_WILL_DRAW), + fStatusBar(NULL), fType(type), fBitmap(NULL), + fStopButton(NULL), + fPauseButton(NULL), fThread(thread) { Init(); @@ -549,23 +552,20 @@ BStatusView::~BStatusView() void BStatusView::Init() { - fDestDir = ""; + fTotalSize = fItemSize = fSizeProcessed = fLastSpeedReferenceSize + = fEstimatedFinishReferenceSize = 0; fCurItem = 0; - fPendingStatusString[0] = '\0'; - fWasCanceled = false; - fIsPaused = false; - fLastUpdateTime = 0; - fBytesPerSecond = 0.0; + fLastUpdateTime = fLastSpeedReferenceTime = fProcessStartTime + = fLastSpeedUpdateTime = fEstimatedFinishReferenceTime + = system_time(); + fCurrentBytesPerSecondSlot = 0; for (size_t i = 0; i < kBytesPerSecondSlots; i++) fBytesPerSecondSlot[i] = 0.0; - fCurrentBytesPerSecondSlot = 0; - fItemSize = 0; - fSizeProcessed = 0; - fLastSpeedReferenceSize = 0; - fEstimatedFinishReferenceSize = 0; - fProcessStartTime = fLastSpeedReferenceTime - = fEstimatedFinishReferenceTime = system_time(); + fBytesPerSecond = 0.0; + fShowCount = fWasCanceled = fIsPaused = false; + fDestDir.SetTo(""); + fPendingStatusString[0] = '\0'; } @@ -579,9 +579,9 @@ BStatusView::InitStatus(int32 totalItems, off_t totalSize, BEntry entry; char name[B_FILE_NAME_LENGTH]; - if (destDir && (entry.SetTo(destDir) == B_OK)) { + if (destDir != NULL && entry.SetTo(destDir) == B_OK) { entry.GetName(name); - fDestDir = name; + fDestDir.SetTo(name); } BString buffer; @@ -630,7 +630,7 @@ BStatusView::InitStatus(int32 totalItems, off_t totalSize, void BStatusView::Draw(BRect updateRect) { - if (fBitmap) { + if (fBitmap != NULL) { BPoint location; location.x = (fStatusBar->Frame().left - fBitmap->Bounds().Width()) / 2; ############################################################################ Commit: ec3d0a698d35f2c7e57d0e2a7612f3be8f7aa9a9 URL: http://cgit.haiku-os.org/haiku/commit/?id=ec3d0a6 Author: John Scipione <jscipione@xxxxxxxxx> Date: Wed Jul 23 05:03:35 2014 UTC Tracker: check dynamic_cast, CID 600336 ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/CountView.cpp b/src/kits/tracker/CountView.cpp index ca21609..ef839ff 100644 --- a/src/kits/tracker/CountView.cpp +++ b/src/kits/tracker/CountView.cpp @@ -311,6 +311,9 @@ void BCountView::MouseDown(BPoint) { BContainerWindow* window = dynamic_cast<BContainerWindow*>(Window()); + if (window == NULL) + return; + window->Activate(); window->UpdateIfNeeded(); ############################################################################ Commit: 015559bfa8ea847574c7e2726be65c0e6d182934 URL: http://cgit.haiku-os.org/haiku/commit/?id=015559b Author: John Scipione <jscipione@xxxxxxxxx> Date: Wed Jul 23 05:06:15 2014 UTC Tracker: init member vars, CID 610120 ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/SlowContextPopup.cpp b/src/kits/tracker/SlowContextPopup.cpp index 3600fe7..03359c0 100644 --- a/src/kits/tracker/SlowContextPopup.cpp +++ b/src/kits/tracker/SlowContextPopup.cpp @@ -76,8 +76,10 @@ BSlowContextMenu::BSlowContextMenu(const char* title) fMenuBuilt(false), fMessage(B_REFS_RECEIVED), fParentWindow(NULL), + fVolsOnly(false), fItemList(NULL), fContainer(NULL), + fIteratingDesktop(false), fTypesList(NULL), fIsShowing(false) { ############################################################################ Commit: 322b28e01bf5fbdfd76645a9c6c70460dc013378 URL: http://cgit.haiku-os.org/haiku/commit/?id=322b28e Author: John Scipione <jscipione@xxxxxxxxx> Date: Wed Jul 23 05:16:14 2014 UTC Tracker: init member var, CID 610121 ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/MimeTypeList.cpp b/src/kits/tracker/MimeTypeList.cpp index c8c2808..77c9ce6 100644 --- a/src/kits/tracker/MimeTypeList.cpp +++ b/src/kits/tracker/MimeTypeList.cpp @@ -41,7 +41,7 @@ All rights reserved. #include "Thread.h" -ShortMimeInfo::ShortMimeInfo(const BMimeType &mimeType) +ShortMimeInfo::ShortMimeInfo(const BMimeType& mimeType) : fCommonMimeType(true) { @@ -51,8 +51,9 @@ ShortMimeInfo::ShortMimeInfo(const BMimeType &mimeType) // weed out apps - their preferred handler is themselves if (mimeType.GetPreferredApp(buffer) == B_OK - && fPrivateName.ICompare(buffer) == 0) + && fPrivateName.ICompare(buffer) == 0) { fCommonMimeType = false; + } // weed out metamimes without a short description if (mimeType.GetShortDescription(buffer) != B_OK || buffer[0] == 0) @@ -64,7 +65,8 @@ ShortMimeInfo::ShortMimeInfo(const BMimeType &mimeType) ShortMimeInfo::ShortMimeInfo(const char* shortDescription) : - fShortDescription(shortDescription) + fShortDescription(shortDescription), + fCommonMimeType(true) { } diff --git a/src/kits/tracker/MimeTypeList.h b/src/kits/tracker/MimeTypeList.h index 30d4b19..eec2857 100644 --- a/src/kits/tracker/MimeTypeList.h +++ b/src/kits/tracker/MimeTypeList.h @@ -47,13 +47,13 @@ class MimeTypeList; class ShortMimeInfo { public: - ShortMimeInfo(const BMimeType &); + ShortMimeInfo(const BMimeType& mimeType); const char* InternalName() const; const char* ShortDescription() const; bool IsCommonMimeType() const; - static int CompareShortDescription(const ShortMimeInfo*, - const ShortMimeInfo*); + static int CompareShortDescription(const ShortMimeInfo* a, + const ShortMimeInfo* b); private: ShortMimeInfo(const char* shortDescription); ############################################################################ Commit: 4f48aeed3ed78ed8b9b44f92b287c6e4fc041055 URL: http://cgit.haiku-os.org/haiku/commit/?id=4f48aee Author: John Scipione <jscipione@xxxxxxxxx> Date: Thu Jul 24 21:51:03 2014 UTC Tracker: Check dynamic_cast, CID 600337 ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/FindPanel.cpp b/src/kits/tracker/FindPanel.cpp index 42728f7..0fd5325 100644 --- a/src/kits/tracker/FindPanel.cpp +++ b/src/kits/tracker/FindPanel.cpp @@ -3038,12 +3038,17 @@ DeleteTransientQueriesTask::StartUpTransientQueryCleaner() // killing off old transient queries DeleteTransientQueriesFunctor* worker = new DeleteTransientQueriesFunctor(new DeleteTransientQueriesTask()); + TTracker* tracker = dynamic_cast<TTracker*>(be_app); - ASSERT(tracker); - tracker->MainTaskLoop()->RunWhenIdle(worker, - 30 * 60 * 1000000, // half an hour initial delay - 5 * 60 * 1000000, // idle for five minutes - 10 * 1000000); + + ASSERT(tracker != NULL); + + if (tracker != NULL) { + tracker->MainTaskLoop()->RunWhenIdle(worker, + 30 * 60 * 1000000, // half an hour initial delay + 5 * 60 * 1000000, // idle for five minutes + 10 * 1000000); + } } ############################################################################ Commit: d5881312d33ed4f471a652fa65f4ebaaa2ae6264 URL: http://cgit.haiku-os.org/haiku/commit/?id=d588131 Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 01:43:27 2014 UTC Tracker: reorder includes in FindPanel.cpp ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/FindPanel.cpp b/src/kits/tracker/FindPanel.cpp index 0fd5325..e7dcb30 100644 --- a/src/kits/tracker/FindPanel.cpp +++ b/src/kits/tracker/FindPanel.cpp @@ -35,6 +35,13 @@ All rights reserved. #include "FindPanel.h" +#include <utility> + +#include <fs_attr.h> +#include <parsedate.h> +#include <stdlib.h> +#include <string.h> + #include <Application.h> #include <Box.h> #include <Button.h> @@ -46,7 +53,7 @@ All rights reserved. #include <FindDirectory.h> #include <File.h> #include <FilePanel.h> -#include <GridLayoutBuilder.h> +#include <GroupLayout.h> #include <InterfaceDefs.h> #include <LayoutBuilder.h> #include <Locale.h> @@ -66,12 +73,6 @@ All rights reserved. #include <Volume.h> #include <VolumeRoster.h> -#include <fs_attr.h> -#include <parsedate.h> -#include <stdlib.h> -#include <strings.h> -#include <utility> - #include "Attributes.h" #include "AutoLock.h" #include "Commands.h" ############################################################################ Commit: 14948881dcefe27a25d4d8d6d40ccd94843a78b5 URL: http://cgit.haiku-os.org/haiku/commit/?id=1494888 Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 01:50:36 2014 UTC Tracker: Style fixes to FindPanel ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/FindPanel.cpp b/src/kits/tracker/FindPanel.cpp index e7dcb30..c9e8814 100644 --- a/src/kits/tracker/FindPanel.cpp +++ b/src/kits/tracker/FindPanel.cpp @@ -354,9 +354,10 @@ MakeValidFilename(BString &string) // replace slashes int32 length = string.Length(); char* buf = string.LockBuffer(length); - for (int32 index = length; index-- > 0;) + for (int32 index = length; index-- > 0;) { if (buf[index] == '/' /*|| buf[index] == ':'*/) buf[index] = '_'; + } string.UnlockBuffer(length); return string.String(); @@ -364,7 +365,7 @@ MakeValidFilename(BString &string) void -FindWindow::GetPredicateString(BString &predicate, bool &dynamicDate) +FindWindow::GetPredicateString(BString& predicate, bool& dynamicDate) { BQuery query; BTextControl* textControl @@ -388,9 +389,9 @@ FindWindow::GetPredicateString(BString &predicate, bool &dynamicDate) void -FindWindow::GetDefaultName(BString &result) +FindWindow::GetDefaultName(BString& name) { - fBackground->GetDefaultName(result); + fBackground->GetDefaultName(name); time_t timeValue = time(0); char namebuf[B_FILE_NAME_LENGTH]; @@ -399,9 +400,9 @@ FindWindow::GetDefaultName(BString &result) localtime_r(&timeValue, &timeData); strftime(namebuf, 32, " - %b %d, %I:%M:%S %p", &timeData); - result << namebuf; + name << namebuf; - MakeValidFilename(result); + MakeValidFilename(name); } @@ -595,7 +596,7 @@ FindWindow::FindSaveCommon(bool find) // remove the current entry - need to do this to quit the // running query and to close the corresponding window - if (userSpecifiedName && !fEditTemplateOnly) { + if (userSpecifiedName != NULL && !fEditTemplateOnly) { // change the name of the old query per users request fRef.set_name(userSpecifiedName); entry.SetTo(&fRef); @@ -1544,12 +1545,13 @@ FindPanel::GetByNamePredicate(BQuery* query) const ASSERT(Mode() == (int32)kByNameItem); BTextControl* textControl = dynamic_cast<BTextControl*>(FindView("TextControl")); - ASSERT(textControl); + + ASSERT(textControl != NULL); query->PushAttr("name"); query->PushString(textControl->TextView()->Text(), true); - if (strstr(textControl->TextView()->Text(), "*")) { + if (strstr(textControl->TextView()->Text(), "*") != NULL) { // assume pattern is a regular expression, try doing an exact match query->PushOp(B_EQ); } else @@ -1582,7 +1584,8 @@ FindPanel::SwitchMode(uint32 mode) query.GetPredicate(&buffer); } - } // fall thru + } + // fall-through case kByNameItem: { fMode = mode; @@ -1605,7 +1608,7 @@ FindPanel::SwitchMode(uint32 mode) fMode = mode; BTextControl* textControl = dynamic_cast<BTextControl*>(FindView("TextControl")); - if (textControl) { + if (textControl != NULL) { textControl->RemoveSelf(); delete textControl; } @@ -2023,7 +2026,8 @@ FindPanel::SetUpAddRemoveButtons(BBox* box) .AddGlue() .Add(removeButton) .Add(addButton) - .End(); + .End() + .End(); } @@ -2232,9 +2236,11 @@ FindPanel::SaveWindowState(BNode* node, bool editTemplate) { BTextControl* textControl = dynamic_cast<BTextControl*> (FindView("TextControl")); - ASSERT(textControl); BString formula(textControl->TextView()->Text()); node->WriteAttrString(kAttrQueryInitialString, &formula); + + ASSERT(textControl != NULL); + break; } } @@ -2667,7 +2673,9 @@ FindPanel::SaveAttrState(BMessage* message, int32 index) string << index; BTextControl* textControl = dynamic_cast<BTextControl*>(FindAttrView(string.String(), index)); - ASSERT(textControl); + + ASSERT(textControl != NULL); + message->AddString("attrViewText", textControl->TextView()->Text()); BMenuField* field = dynamic_cast<BMenuField*>(FindAttrView("Logic", index)); @@ -2883,8 +2891,9 @@ FindPanel::GetDefaultAttrName(BString &result, int32 row) const DeleteTransientQueriesTask::DeleteTransientQueriesTask() - : state(kInitial), - fWalker(NULL) + : + state(kInitial), + fWalker(NULL) { } @@ -3006,6 +3015,7 @@ DeleteTransientQueriesTask::ProcessOneRef(Model* model) PRINT(("query %s, old, temporary, not shownig - deleting\n", model->Name())); + BEntry entry(model->EntryRef()); entry.Remove(); @@ -3109,13 +3119,14 @@ DraggableQueryIcon::DragStarted(BMessage* dragMessage) dragMessage->RemoveData("be:clip_name"); FindWindow* window = dynamic_cast<FindWindow*>(Window()); - ASSERT(window); dragMessage->AddString("be:clip_name", window->BackgroundView()->UserSpecifiedName() ? window->BackgroundView()->UserSpecifiedName() : B_TRANSLATE("New Query")); return true; + ASSERT(window != NULL); + } diff --git a/src/kits/tracker/FindPanel.h b/src/kits/tracker/FindPanel.h index 322fd40..72a551a 100644 --- a/src/kits/tracker/FindPanel.h +++ b/src/kits/tracker/FindPanel.h @@ -95,20 +95,22 @@ struct MoreOptionsStruct { // saved MoreOptionsStruct() - : showMoreOptions(false), - searchTrash(false), - reserved1(0), - temporary(true), - reserved9(false), - reserved10(false), - reserved11(false), - reserved3(0), - reserved4(0), - reserved5(0), - reserved6(0), - reserved7(0), - reserved8(0) - {} + : + showMoreOptions(false), + searchTrash(false), + reserved1(0), + temporary(true), + reserved9(false), + reserved10(false), + reserved11(false), + reserved3(0), + reserved4(0), + reserved5(0), + reserved6(0), + reserved7(0), + reserved8(0) + { + } static void EndianSwap(void* castToThis); @@ -118,234 +120,234 @@ struct MoreOptionsStruct { class FindWindow : public BWindow { - public: - FindWindow(const entry_ref* ref = NULL, - bool editIfTemplateOnly = false); - virtual ~FindWindow(); +public: + FindWindow(const entry_ref* ref = NULL, + bool editIfTemplateOnly = false); + virtual ~FindWindow(); - FindPanel* BackgroundView() const - { return fBackground; } + FindPanel* BackgroundView() const + { return fBackground; } - BNode* QueryNode() const - { return fFile; } + BNode* QueryNode() const + { return fFile; } - const char* QueryName() const; - // reads in the query name from either a saved name in a template - // or form a saved query name + const char* QueryName() const; + // reads in the query name from either a saved name in a template + // or form a saved query name - static bool IsQueryTemplate(BNode* file); + static bool IsQueryTemplate(BNode* file); - protected: - virtual void MessageReceived(BMessage* message); +protected: + virtual void MessageReceived(BMessage* message); - private: - static BFile* TryOpening(const entry_ref* ref); - static void GetDefaultQuery(BEntry &entry); - // when opening an empty panel, use the default query to set the - // panel up - void SaveQueryAttributes(BNode* file, bool templateQuery); +private: + static BFile* TryOpening(const entry_ref* ref); + static void GetDefaultQuery(BEntry &entry); + // when opening an empty panel, use the default query to set the + // panel up + void SaveQueryAttributes(BNode* file, bool templateQuery); - void Find(); - // retrieve the results - void Save(); - // save the contents of the find window into the query file + void Find(); + // retrieve the results + void Save(); + // save the contents of the find window into the query file - void SwitchToTemplate(const entry_ref*); - bool FindSaveCommon(bool find); + void SwitchToTemplate(const entry_ref*); + bool FindSaveCommon(bool find); - status_t SaveQueryAsAttributes(BNode*, BEntry*, bool queryTemplate, - const BMessage* oldAttributes = 0, const BPoint* oldLocation = 0); + status_t SaveQueryAsAttributes(BNode*, BEntry*, bool queryTemplate, + const BMessage* oldAttributes = 0, const BPoint* oldLocation = 0); - void GetDefaultName(BString &); - void GetPredicateString(BString &, bool &dynamicDate); - // dynamic date is a date such as 'today' + void GetDefaultName(BString &); + void GetPredicateString(BString &, bool &dynamicDate); + // dynamic date is a date such as 'today' - BFile* fFile; - entry_ref fRef; - bool fFromTemplate; - bool fEditTemplateOnly; - FindPanel* fBackground; - mutable BString fQueryNameFromTemplate; - BFilePanel* fSaveAsTemplatePanel; + BFile* fFile; + entry_ref fRef; + bool fFromTemplate; + bool fEditTemplateOnly; + FindPanel* fBackground; + mutable BString fQueryNameFromTemplate; + BFilePanel* fSaveAsTemplatePanel; - typedef BWindow _inherited; + typedef BWindow _inherited; }; class FindPanel : public BView { - public: - FindPanel(BFile*, FindWindow* parent, bool fromTemplate, - bool editTemplateOnly); - virtual ~FindPanel(); - - virtual void AttachedToWindow(); - virtual void Draw(BRect updateRect); - virtual void MessageReceived(BMessage*); - - void BuildAttrQuery(BQuery*, bool &dynamicDate) const; - BPopUpMenu* MimeTypeMenu() const - { return fMimeTypeMenu; } - BMenuItem* CurrentMimeType(const char** type = NULL) const; - status_t SetCurrentMimeType(BMenuItem* item); - status_t SetCurrentMimeType(const char* label); - - BPopUpMenu* VolMenu() const - { return fVolMenu; } - uint32 Mode() const - { return fMode; } - - static uint32 InitialMode(const BNode* entry); - void SaveWindowState(BNode*, bool editTemplate); - - void SwitchToTemplate(const BNode*); - - void GetByAttrPredicate(BQuery*, bool &dynamicDate) const; - // build up a query from by-attribute items - void GetByNamePredicate(BQuery *) const; - // build up a simple query from the name we are searching for - - void GetDefaultName(BString &) const; - void GetDefaultAttrName(BString &, int32) const; - const char* UserSpecifiedName() const; - // name filled out in the query name text field - - static void AddRecentQueries(BMenu*, bool addSaveAsItem, - const BMessenger* target, uint32 what); - // populate the recent query menu with query templates and recent - // queries - - private: - void AddMimeTypesToMenu(); - // populates the type menu - static bool AddOneMimeTypeToMenu(const ShortMimeInfo*, void* castToMenu); - - void AddVolumes(BMenu*); - // populates the volume menu - void ShowVolumeMenuLabel(); - - void AddAttrRow(); - // add one more attribute item to the attr view - void RemoveAttrRow(); - // remove the last attribute item - void AddFirstAttr(); - - // panel building/restoring calls - void RestoreWindowState(const BNode*); - void RestoreMimeTypeMenuSelection(const BNode*); - void AddByAttributeItems(const BNode*); - void RemoveByAttributeItems(); - void RemoveAttrViewItems(bool removeGrid = true); - void ShowOrHideMimeTypeMenu(); - // MimeTypeWindow is only shown in kByNameItem and - // kByAttributeItem modes - - void AddAttributeControls(int32); - - void ShowOrHideMoreOptions(bool show); - // fMode gets set by this and the call relies on it being - // up-to-date - static int32 InitialAttrCount(const BNode*); - void FillCurrentQueryName(BTextControl*, FindWindow*); - void AddByNameOrFormulaItems(); void SetUpAddRemoveButtons(BBox* box); - - void SwitchMode(uint32); - // go from search by name to search by attribute, etc. - - void PushMimeType(BQuery* query) const; - - void SaveAsQueryOrTemplate(const entry_ref*, const char*, bool queryTemplate); - - BView* FindAttrView(const char*, int row) const; - - void AddAttributes(BMenu* menu, const BMimeType &type); - void AddMimeTypeAttrs(BMenu* menu); - void RestoreAttrState(const BMessage &, int32); - void SaveAttrState(BMessage*, int32); - void AddLogicMenu(int32, bool selectAnd = true); - void RemoveLogicMenu(int32); - - void ResizeMenuField(BMenuField*); - - uint32 fMode; - BGridLayout* fAttrGrid; - BPopUpMenu* fMimeTypeMenu; - BMenuField* fMimeTypeField; - BPopUpMenu* fVolMenu; - BPopUpMenu* fSearchModeMenu; - BPopUpMenu* fRecentQueries; - BBox* fMoreOptions; - BTextControl* fQueryName; - BString fInitialQueryName; - - BCheckBox* fTemporaryCheck; - BCheckBox* fSearchTrashCheck; - - PaneSwitch* fLatch; - DraggableIcon* fDraggableIcon; - - typedef BView _inherited; - - friend class RecentQueriesPopUp; +public: + FindPanel(BFile*, FindWindow* parent, bool fromTemplate, + bool editTemplateOnly); + virtual ~FindPanel(); + + virtual void AttachedToWindow(); + virtual void Draw(BRect updateRect); + virtual void MessageReceived(BMessage*); + + void BuildAttrQuery(BQuery*, bool& dynamicDate) const; + BPopUpMenu* MimeTypeMenu() const + { return fMimeTypeMenu; } + BMenuItem* CurrentMimeType(const char** type = NULL) const; + status_t SetCurrentMimeType(BMenuItem* item); + status_t SetCurrentMimeType(const char* label); + + BPopUpMenu* VolMenu() const + { return fVolMenu; } + uint32 Mode() const + { return fMode; } + + static uint32 InitialMode(const BNode* entry); + void SaveWindowState(BNode*, bool editTemplate); + + void SwitchToTemplate(const BNode*); + + void GetByAttrPredicate(BQuery*, bool &dynamicDate) const; + // build up a query from by-attribute items + void GetByNamePredicate(BQuery*) const; + // build up a simple query from the name we are searching for + + void GetDefaultName(BString&) const; + void GetDefaultAttrName(BString&, int32) const; + const char* UserSpecifiedName() const; + // name filled out in the query name text field + + static void AddRecentQueries(BMenu*, bool addSaveAsItem, + const BMessenger* target, uint32 what); + // populate the recent query menu with query templates and recent + // queries + +private: + void AddMimeTypesToMenu(); + // populates the type menu + static bool AddOneMimeTypeToMenu(const ShortMimeInfo*, void* castToMenu); + + void AddVolumes(BMenu*); + // populates the volume menu + void ShowVolumeMenuLabel(); + + void AddAttrRow(); + // add one more attribute item to the attr view + void RemoveAttrRow(); + // remove the last attribute item + void AddFirstAttr(); + + // panel building/restoring calls + void RestoreWindowState(const BNode*); + void RestoreMimeTypeMenuSelection(const BNode*); + void AddByAttributeItems(const BNode*); + void RemoveByAttributeItems(); + void RemoveAttrViewItems(bool removeGrid = true); + void ShowOrHideMimeTypeMenu(); + // MimeTypeWindow is only shown in kByNameItem and + // kByAttributeItem modes + + void AddAttributeControls(int32); + + void ShowOrHideMoreOptions(bool show); + // fMode gets set by this and the call relies on it being + // up-to-date + static int32 InitialAttrCount(const BNode*); + void FillCurrentQueryName(BTextControl*, FindWindow*); + void AddByNameOrFormulaItems(); + + void SwitchMode(uint32); + // go from search by name to search by attribute, etc. + + void PushMimeType(BQuery* query) const; + + void SaveAsQueryOrTemplate(const entry_ref*, const char*, bool queryTemplate); + + BView* FindAttrView(const char*, int row) const; + + void AddAttributes(BMenu* menu, const BMimeType &type); + void AddMimeTypeAttrs(BMenu* menu); + void RestoreAttrState(const BMessage &, int32); + void SaveAttrState(BMessage*, int32); + void AddLogicMenu(int32, bool selectAnd = true); + void RemoveLogicMenu(int32); + + void ResizeMenuField(BMenuField*); + + uint32 fMode; + BGridLayout* fAttrGrid; + BPopUpMenu* fMimeTypeMenu; + BMenuField* fMimeTypeField; + BPopUpMenu* fVolMenu; + BPopUpMenu* fSearchModeMenu; + BPopUpMenu* fRecentQueries; + BBox* fMoreOptions; + BTextControl* fQueryName; + BString fInitialQueryName; + + BCheckBox* fTemporaryCheck; + BCheckBox* fSearchTrashCheck; + + PaneSwitch* fLatch; + DraggableIcon* fDraggableIcon; + + typedef BView _inherited; + + friend class RecentQueriesPopUp; }; class DeleteTransientQueriesTask { // transient queries get deleted if they didn't get used in a while; // this is the task that takes care of it - public: - static void StartUpTransientQueryCleaner(); +public: + static void StartUpTransientQueryCleaner(); - bool DoSomeWork(); - virtual ~DeleteTransientQueriesTask(); + bool DoSomeWork(); + virtual ~DeleteTransientQueriesTask(); - protected: - DeleteTransientQueriesTask(); - // returns true when done +protected: + DeleteTransientQueriesTask(); + // returns true when done - enum State { - kInitial, - kAllocatedWalker, - kTraversing, - kError - }; + enum State { + kInitial, + kAllocatedWalker, + kTraversing, + kError + }; - State state; + State state; - void Initialize(); - bool GetSome(); + void Initialize(); + bool GetSome(); - bool ProcessOneRef(Model*); + bool ProcessOneRef(Model*); - private: - BTrackerPrivate::TNodeWalker* fWalker; +private: + BTrackerPrivate::TNodeWalker* fWalker; }; class RecentFindItemsMenu : public BMenu { - public: - RecentFindItemsMenu(const char* title, const BMessenger* target, - uint32 what); +public: + RecentFindItemsMenu(const char* title, const BMessenger* target, + uint32 what); - protected: - virtual void AttachedToWindow(); +protected: + virtual void AttachedToWindow(); - private: - BMessenger fTarget; - uint32 fWhat; +private: + BMessenger fTarget; + uint32 fWhat; }; class DraggableQueryIcon : public DraggableIcon { // query/query template drag&drop helper - public: - DraggableQueryIcon(BRect frame, const char* name, - const BMessage* message, BMessenger target, - uint32 resizeFlags = B_FOLLOW_LEFT | B_FOLLOW_TOP, - uint32 flags = B_WILL_DRAW); - - protected: - virtual bool DragStarted(BMessage*); +public: + DraggableQueryIcon(BRect frame, const char* name, + const BMessage* message, BMessenger target, + uint32 resizeFlags = B_FOLLOW_LEFT | B_FOLLOW_TOP, + uint32 flags = B_WILL_DRAW); + +protected: + virtual bool DragStarted(BMessage*); }; } // namespace BPrivate ############################################################################ Commit: cfc444a631efa76d5b1ce10e3d1c1d8423a2057f URL: http://cgit.haiku-os.org/haiku/commit/?id=cfc444a Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 01:52:58 2014 UTC Tracker: Unchecked dynamic_cast, CID 300339 ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/FindPanel.cpp b/src/kits/tracker/FindPanel.cpp index c9e8814..0f5c427 100644 --- a/src/kits/tracker/FindPanel.cpp +++ b/src/kits/tracker/FindPanel.cpp @@ -2492,6 +2492,9 @@ FindPanel::ShowOrHideMimeTypeMenu() BView* menuFieldSpacer = FindView("MimeTypeMenuSpacer"); BMenuField* menuField = dynamic_cast<BMenuField*>(FindView("MimeTypeMenu")); + if (menuFieldSpacer == NULL || menuField == NULL) + return; + if (Mode() == (int32)kByFormulaItem && !menuField->IsHidden(this)) { BSize size = menuField->ExplicitMinSize(); menuField->Hide(); ############################################################################ Commit: bbd3b2d9141bfcdacd4f3ac69f3054825390adc3 URL: http://cgit.haiku-os.org/haiku/commit/?id=bbd3b2d Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 01:54:04 2014 UTC Tracker: Unchecked dynamic_cast, CID 600340 ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/FindPanel.cpp b/src/kits/tracker/FindPanel.cpp index 0f5c427..ff9331f 100644 --- a/src/kits/tracker/FindPanel.cpp +++ b/src/kits/tracker/FindPanel.cpp @@ -2429,6 +2429,12 @@ void FindPanel::AddByNameOrFormulaItems() { BBox* box = dynamic_cast<BBox*>(FindView("Box")); + + ASSERT(box != NULL); + + if (box == NULL) + return; + // reset layout BLayoutBuilder::Group<>(box, B_VERTICAL); ############################################################################ Commit: d6e0dbfe30533cce84fd1f058a17ad459c877849 URL: http://cgit.haiku-os.org/haiku/commit/?id=d6e0dbf Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 01:56:32 2014 UTC Tracker: Unchecked dynamic_cast, CID 600343 ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/FindPanel.cpp b/src/kits/tracker/FindPanel.cpp index ff9331f..fdee482 100644 --- a/src/kits/tracker/FindPanel.cpp +++ b/src/kits/tracker/FindPanel.cpp @@ -2382,11 +2382,13 @@ FindPanel::RestoreWindowState(const BNode* node) BString buffer; if (node->ReadAttrString(kAttrQueryInitialString, &buffer) == B_OK) { - BTextControl* textControl = dynamic_cast<BTextControl*> - (FindView("TextControl")); - ASSERT(textControl); + BTextControl* textControl = dynamic_cast<BTextControl*>( + FindView("TextControl")); - textControl->TextView()->SetText(buffer.String()); + ASSERT(textControl != NULL); + + if (textControl != NULL) + textControl->TextView()->SetText(buffer.String()); } break; } ############################################################################ Commit: 35237fd8f3ff9c25f3dcb607f3d04c164fba18ea URL: http://cgit.haiku-os.org/haiku/commit/?id=35237fd Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 01:57:50 2014 UTC Tracker: Unchecked dynamic_cast, CID 500345 ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/FindPanel.cpp b/src/kits/tracker/FindPanel.cpp index fdee482..0ae8963 100644 --- a/src/kits/tracker/FindPanel.cpp +++ b/src/kits/tracker/FindPanel.cpp @@ -3130,14 +3130,13 @@ DraggableQueryIcon::DragStarted(BMessage* dragMessage) dragMessage->RemoveData("be:clip_name"); FindWindow* window = dynamic_cast<FindWindow*>(Window()); - dragMessage->AddString("be:clip_name", - window->BackgroundView()->UserSpecifiedName() ? - window->BackgroundView()->UserSpecifiedName() - : B_TRANSLATE("New Query")); - return true; ASSERT(window != NULL); + return window != NULL && dragMessage->AddString("be:clip_name", + window->BackgroundView()->UserSpecifiedName() != NULL + ? window->BackgroundView()->UserSpecifiedName() + : B_TRANSLATE("New Query")) == B_OK; } ############################################################################ Commit: bee19b9428c8a7ed7b049f231fb1274b90f83b97 URL: http://cgit.haiku-os.org/haiku/commit/?id=bee19b9 Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 01:59:04 2014 UTC Tracker: Unchecked dynamic_cast, CID 600346 ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/FindPanel.cpp b/src/kits/tracker/FindPanel.cpp index 0ae8963..ade25b7 100644 --- a/src/kits/tracker/FindPanel.cpp +++ b/src/kits/tracker/FindPanel.cpp @@ -2236,11 +2236,13 @@ FindPanel::SaveWindowState(BNode* node, bool editTemplate) { BTextControl* textControl = dynamic_cast<BTextControl*> (FindView("TextControl")); - BString formula(textControl->TextView()->Text()); - node->WriteAttrString(kAttrQueryInitialString, &formula); ASSERT(textControl != NULL); + if (textControl != NULL) { + BString formula(textControl->TextView()->Text()); + node->WriteAttrString(kAttrQueryInitialString, &formula); + } break; } } ############################################################################ Commit: d2af6ff10453e28a4999583c05a677cf75934b39 URL: http://cgit.haiku-os.org/haiku/commit/?id=d2af6ff Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 02:00:29 2014 UTC Tracker: Unchecked dynamic_cast, CID 600347 ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/FindPanel.cpp b/src/kits/tracker/FindPanel.cpp index ade25b7..a4d8e78 100644 --- a/src/kits/tracker/FindPanel.cpp +++ b/src/kits/tracker/FindPanel.cpp @@ -1548,6 +1548,9 @@ FindPanel::GetByNamePredicate(BQuery* query) const ASSERT(textControl != NULL); + if (textControl == NULL) + return; + query->PushAttr("name"); query->PushString(textControl->TextView()->Text(), true); ############################################################################ Commit: 9fc1e7ffaeb04b8098caabc6add4adbc91265b3f URL: http://cgit.haiku-os.org/haiku/commit/?id=9fc1e7f Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 02:01:59 2014 UTC Tracker: Unchecked dynamic_cast, CID 600348 ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/FindPanel.cpp b/src/kits/tracker/FindPanel.cpp index a4d8e78..38f9a18 100644 --- a/src/kits/tracker/FindPanel.cpp +++ b/src/kits/tracker/FindPanel.cpp @@ -342,7 +342,7 @@ FindWindow::QueryName() const static const char* -MakeValidFilename(BString &string) +MakeValidFilename(BString& string) { // make a file name that is legal under bfs and hfs - possibly could // add code here to accomodate FAT32 etc. too @@ -368,8 +368,6 @@ void FindWindow::GetPredicateString(BString& predicate, bool& dynamicDate) { BQuery query; - BTextControl* textControl - = dynamic_cast<BTextControl*>(FindView("TextControl")); switch (fBackground->Mode()) { case kByNameItem: fBackground->GetByNamePredicate(&query); @@ -377,8 +375,13 @@ FindWindow::GetPredicateString(BString& predicate, bool& dynamicDate) break; case kByFormulaItem: - predicate.SetTo(textControl->TextView()->Text(), 1023); + { + BTextControl* textControl + = dynamic_cast<BTextControl*>(FindView("TextControl")); + if (textControl != NULL) + predicate.SetTo(textControl->TextView()->Text(), 1023); break; + } case kByAttributeItem: fBackground->GetByAttrPredicate(&query, dynamicDate); ############################################################################ Commit: 6ef1768d768fcea164a4ad940d05002ad9b2d8ac URL: http://cgit.haiku-os.org/haiku/commit/?id=6ef1768 Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 02:03:32 2014 UTC Tracker: Unchecked dynamic_cast, CID 600349 ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/FindPanel.cpp b/src/kits/tracker/FindPanel.cpp index 38f9a18..47b5630 100644 --- a/src/kits/tracker/FindPanel.cpp +++ b/src/kits/tracker/FindPanel.cpp @@ -1599,12 +1599,13 @@ FindPanel::SwitchMode(uint32 mode) ShowOrHideMimeTypeMenu(); AddByNameOrFormulaItems(); - if (buffer.Length()) { + if (buffer.Length() > 0) { ASSERT(mode == kByFormulaItem || oldMode == kByAttributeItem); BTextControl* textControl = dynamic_cast<BTextControl*>(FindView("TextControl")); - textControl->SetText(buffer.String()); + if (textControl != NULL) + textControl->SetText(buffer.String()); } break; } ############################################################################ Commit: 1cdaa16d1243d7327386bcb81f6145595812707d URL: http://cgit.haiku-os.org/haiku/commit/?id=1cdaa16 Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 02:05:07 2014 UTC Tracker: Unchecked dynamic_cast, CID 600353 ... and possibly others. ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/FindPanel.cpp b/src/kits/tracker/FindPanel.cpp index 47b5630..e975b16 100644 --- a/src/kits/tracker/FindPanel.cpp +++ b/src/kits/tracker/FindPanel.cpp @@ -1499,32 +1499,38 @@ FindPanel::GetByAttrPredicate(BQuery* query, bool &dynamicDate) const [ *** diff truncated: 47 lines dropped *** ] ############################################################################ Commit: ee090c5313cdddf4f900aa9f6cf2e3ec1e4a6b6f URL: http://cgit.haiku-os.org/haiku/commit/?id=ee090c5 Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 02:06:01 2014 UTC Tracker: Unchecked return value, CID 602471 ---------------------------------------------------------------------------- ############################################################################ Commit: 404b6d40d3b301251d6ff9ab3d633282cbfea81e URL: http://cgit.haiku-os.org/haiku/commit/?id=404b6d4 Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 02:08:02 2014 UTC Tracker: Unchecked dynamic_cast, CID 603123 ---------------------------------------------------------------------------- ############################################################################ Commit: f0eb64b40d2f7de71d0c2e265d4961fb0c07c9a7 URL: http://cgit.haiku-os.org/haiku/commit/?id=f0eb64b Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 02:09:12 2014 UTC Tracker: Unchecked dynamic_cast, CID 603125 ---------------------------------------------------------------------------- ############################################################################ Commit: 1371d18c36b3f7743a37b0664a4308cfb785130c URL: http://cgit.haiku-os.org/haiku/commit/?id=1371d18 Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 02:10:39 2014 UTC Tracker: Unchecked dynamic_cast, CID 603126 ---------------------------------------------------------------------------- ############################################################################ Commit: 1995f1a63d3d700f01ae89d00480576552eff9d0 URL: http://cgit.haiku-os.org/haiku/commit/?id=1995f1a Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 02:11:28 2014 UTC Tracker: Check for negative size, CID 610924 ---------------------------------------------------------------------------- ############################################################################ Commit: 1e09ea53e327f3cd5bf2dce843bf72df74172906 URL: http://cgit.haiku-os.org/haiku/commit/?id=1e09ea5 Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 02:14:32 2014 UTC Tracker: Check return values, CID 991051 & CID 991052 The CIDs are about mkdir, we want to check that either the command succeeded or failed because the directory already exists. However, we also want to check the return value of find_directory() and Append() to make sure they succeeded as well. ---------------------------------------------------------------------------- ############################################################################ Commit: 08b7ddae7626eb7d42ead8b976983d5d0821d67f URL: http://cgit.haiku-os.org/haiku/commit/?id=08b7dda Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 02:17:51 2014 UTC Tracker: Unchecked dynamic_cast, CID 1032263 ---------------------------------------------------------------------------- ############################################################################ Commit: 861d997e49d0cc25d99c7e06c5c70a878863f68f URL: http://cgit.haiku-os.org/haiku/commit/?id=861d997 Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 02:22:53 2014 UTC Tracker: Unchecked dynamic_cast, CID 1032264 Also some minor refactoring, rename string to textEntryString, check before dereferencing potentially NULL pointers. ---------------------------------------------------------------------------- ############################################################################ Commit: ce04484e6b54de6a33d9663ac67721f0fcc7bde4 URL: http://cgit.haiku-os.org/haiku/commit/?id=ce04484 Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 02:28:17 2014 UTC Tracker: Dereference NULL pointer, CID 1032279 Also a bit of a refactor of GetDefaultAttrName(), check for NULL explicitly, rename result to attrName ---------------------------------------------------------------------------- ############################################################################ Commit: e85fa8f7871e5e97f81867c634777bd8e1a75d9a URL: http://cgit.haiku-os.org/haiku/commit/?id=e85fa8f Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 02:30:01 2014 UTC Tracker: Unchecked dynamic_cast, CID 1210856 ---------------------------------------------------------------------------- ############################################################################ Commit: 350af1ce3fe35142568173e8804db3440f9af638 URL: http://cgit.haiku-os.org/haiku/commit/?id=350af1c Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 02:42:50 2014 UTC Tracker: Unchecked dynamic_cast, CID 1210857 ---------------------------------------------------------------------------- ############################################################################ Commit: a2b0a3c08abc734193d1925fc434c929d2fa3a9d URL: http://cgit.haiku-os.org/haiku/commit/?id=a2b0a3c Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 02:46:15 2014 UTC Tracker: refactor FindPanel::SetUpAddRemoveButtons() Instead of passing the box in we can just use FindView to get it, that's what other methods do. Also, check if removeButton exists in AddAttrRow() first instead of doing it in this method. ---------------------------------------------------------------------------- ############################################################################ Commit: 73de7ce4ecc794375bf092e3b0a293bf1385f506 URL: http://cgit.haiku-os.org/haiku/commit/?id=73de7ce Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 02:47:22 2014 UTC Tracker: check that textControl->TextView() isn't NULL ---------------------------------------------------------------------------- ############################################################################ Commit: dddea1f72fb62662e971ce4d48c8c2742b3e2c26 URL: http://cgit.haiku-os.org/haiku/commit/?id=dddea1f Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 02:50:02 2014 UTC Tracker: Prefer textControl->Text() over textControl->TextView()->Text(), also SetText() ---------------------------------------------------------------------------- ############################################################################ Commit: dc28a571c6ec2912362a52bbff9689b9738272cb URL: http://cgit.haiku-os.org/haiku/commit/?id=dc28a57 Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 02:50:55 2014 UTC Refactor FindPanel::Draw() Check if pointers are NULL before dereferencing them. ---------------------------------------------------------------------------- ############################################################################ Commit: a2400cc5ca4d37742cb6a3fd7feba8b906871418 URL: http://cgit.haiku-os.org/haiku/commit/?id=a2400cc Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 02:51:50 2014 UTC Tracker: some style fixes to FindPanel ---------------------------------------------------------------------------- ############################################################################ Commit: fbf61796ca22f543e8d97abdc8ee51859d7102c9 URL: http://cgit.haiku-os.org/haiku/commit/?id=fbf6179 Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 02:53:39 2014 UTC Tracker: Check dynamic_cast ASSERT that it is not NULL as it shouldn't be. ---------------------------------------------------------------------------- ############################################################################ Commit: 8fbb387b1b8cac73d39bcbcb8b455e54e9275bea URL: http://cgit.haiku-os.org/haiku/commit/?id=8fbb387 Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 02:54:28 2014 UTC Tracker: check dynamic_cast ---------------------------------------------------------------------------- ############################################################################ Commit: f0b515eca1dc9def7e2f12c9fd4fcc8acef89019 URL: http://cgit.haiku-os.org/haiku/commit/?id=f0b515e Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 02:55:37 2014 UTC Tracker: Check dereference NULL pointers field->Menu() could return NULL, field->Menu()->FindMarked() could return NULL. ---------------------------------------------------------------------------- ############################################################################ Commit: 38f3b29c7012d24d0b35befb4fddf80abf02c8e1 URL: http://cgit.haiku-os.org/haiku/commit/?id=38f3b29 Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 02:56:06 2014 UTC Tracker: Check dynamic_cast ---------------------------------------------------------------------------- ############################################################################ Commit: e5355e28145421ee93001735715d1d95fab150b6 URL: http://cgit.haiku-os.org/haiku/commit/?id=e5355e2 Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 02:56:45 2014 UTC Tracker: Unchecked return values Check that find_directory() and path.Append() succeeded. ---------------------------------------------------------------------------- ############################################################################ Commit: a76808e72ec709ed292990b35e3428dcf4188517 URL: http://cgit.haiku-os.org/haiku/commit/?id=a76808e Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 04:18:27 2014 UTC Tracker: Unchecked dynamic_cast in FilePanelPriv.cpp, CID 300327 ---------------------------------------------------------------------------- ############################################################################ Commit: e2ee7b04424cd15c454a8a21a33d9c03c5989660 URL: http://cgit.haiku-os.org/haiku/commit/?id=e2ee7b0 Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 04:40:36 2014 UTC Tracker: Move B_TRANSLATION_CONTEXT to top of FilePanelPriv.cpp ---------------------------------------------------------------------------- ############################################################################ Commit: 6b51d90211e4dd3658af1387537af6f5954a4320 URL: http://cgit.haiku-os.org/haiku/commit/?id=6b51d90 Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 04:42:28 2014 UTC Tracker: style fixes to FilePanelPriv.cpp ---------------------------------------------------------------------------- ############################################################################ Commit: 86c2b955b71debb2fefed6b2c37bac0a960435ed URL: http://cgit.haiku-os.org/haiku/commit/?id=86c2b95 Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 04:43:01 2014 UTC Tracker: Unchecked dynamic_cast, CID 600506 ---------------------------------------------------------------------------- ############################################################################ Commit: a35bd7b065fa9e15b6ca93f5a0cc59a9cf172afa URL: http://cgit.haiku-os.org/haiku/commit/?id=a35bd7b Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 22:44:06 2014 UTC Tracker: Unchecked dynamic_cast, CID 600452 ---------------------------------------------------------------------------- ############################################################################ Commit: 95ef54053563d2f672086aaa32b0131f7b580677 URL: http://cgit.haiku-os.org/haiku/commit/?id=95ef540 Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 22:47:20 2014 UTC Tracker: Unchecked dynamic_cast, CID 611229 ---------------------------------------------------------------------------- ############################################################################ Commit: a8216d9fefbd842a82f9b511cc698dfbf26806ce URL: http://cgit.haiku-os.org/haiku/commit/?id=a8216d9 Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 23:06:59 2014 UTC Tracker: Style fixes to WidgeAttributeText.cpp ---------------------------------------------------------------------------- ############################################################################ Commit: cf2902f4d4e7d857c82cce5451785a2df9e4219c URL: http://cgit.haiku-os.org/haiku/commit/?id=cf2902f Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 23:09:26 2014 UTC Tracker: Potential, but unlikly NULL dereference ---------------------------------------------------------------------------- ############################################################################ Commit: 9ead583fb3a6aa75fa7c961528eb03c1160f61a0 URL: http://cgit.haiku-os.org/haiku/commit/?id=9ead583 Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 23:11:05 2014 UTC Tracker: Set default values, CID 609893 ---------------------------------------------------------------------------- ############################################################################ Commit: b7735c4c026ecbce84ae7ee1fde16659002fd5c3 URL: http://cgit.haiku-os.org/haiku/commit/?id=b7735c4 Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 23:13:01 2014 UTC Tracker: Set initial value, CID 609894 ---------------------------------------------------------------------------- ############################################################################ Commit: 3748c166bece0b3e710c50c699b7ad9e08d5e994 URL: http://cgit.haiku-os.org/haiku/commit/?id=3748c16 Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 23:17:24 2014 UTC Tracker: Set initial value, CID 609895 ---------------------------------------------------------------------------- ############################################################################ Commit: e6877f10e0d94431987727c239994e26c6194765 URL: http://cgit.haiku-os.org/haiku/commit/?id=e6877f1 Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Jul 25 23:27:41 2014 UTC Tracker: Unintentional integer overflow, CID 701977 ---------------------------------------------------------------------------- ############################################################################ Commit: a0db77483360d89b94be87ca7a5bda48cadb2186 URL: http://cgit.haiku-os.org/haiku/commit/?id=a0db774 Author: John Scipione <jscipione@xxxxxxxxx> Date: Sun Jul 27 19:55:10 2014 UTC Tracker: Style fixes to WidgetAttributeText * rename result to outString * rename str to inString ---------------------------------------------------------------------------- ############################################################################ Commit: 85a2e66cc1a26c5f48990546925185b0567797f7 URL: http://cgit.haiku-os.org/haiku/commit/?id=85a2e66 Author: John Scipione <jscipione@xxxxxxxxx> Date: Sun Jul 27 20:03:11 2014 UTC Tracker: Refactor size calc to use a BString By using a BString we can keep track of the string length instead of calculating the length after hoping that sprintf() works or doing a bunch more work to check the return values using either snprintf() or asprintf(). sprintf() was not bounds checked either. As an added bonus we no longer have to use an arbitrary 1024 bytes size buffer. CID 991605 ---------------------------------------------------------------------------- ############################################################################ Commit: 54e2dd7272db551cab02cc678bd45bc4131dd867 URL: http://cgit.haiku-os.org/haiku/commit/?id=54e2dd7 Author: John Scipione <jscipione@xxxxxxxxx> Date: Mon Jul 28 13:49:39 2014 UTC Tracker: style fixes No functional changes intended. ---------------------------------------------------------------------------- ############################################################################ Commit: 3c4e26995c33223ee4d6bc630c6bebd504c348c5 URL: http://cgit.haiku-os.org/haiku/commit/?id=3c4e269 Author: John Scipione <jscipione@xxxxxxxxx> Date: Mon Jul 28 14:53:58 2014 UTC Tracker: small code simplication Use std::max() to avoid comparison and turn into 1-liner. ---------------------------------------------------------------------------- ############################################################################ Commit: 82d9f9d11909830346c6bf4f07d3ddc8b20434ad URL: http://cgit.haiku-os.org/haiku/commit/?id=82d9f9d Author: John Scipione <jscipione@xxxxxxxxx> Date: Mon Jul 28 14:16:05 2014 UTC Tracker: Use main screen if window is NULL Here we try to determine the screen frame of screen that the window is on, use the main screen when window is NULL. ---------------------------------------------------------------------------- ############################################################################ Commit: d48f1c2e3c1c461cf33eb9ae24d9c7250ccc02e1 URL: http://cgit.haiku-os.org/haiku/commit/?id=d48f1c2 Author: John Scipione <jscipione@xxxxxxxxx> Date: Mon Jul 28 15:14:21 2014 UTC Tracker: code simplication, don't check if NULL just pass in NULL, that's what is happening anyway. ---------------------------------------------------------------------------- ############################################################################ Commit: e47063d2dea74c916393abb1b6df54f578df24cf URL: http://cgit.haiku-os.org/haiku/commit/?id=e47063d Author: John Scipione <jscipione@xxxxxxxxx> Date: Mon Jul 28 15:01:31 2014 UTC Tracker: Don't need to cast to BWindow here ---------------------------------------------------------------------------- ############################################################################ Commit: 9cc03189faa3cb4923d63a897435f56ec98c62b0 URL: http://cgit.haiku-os.org/haiku/commit/?id=9cc0318 Author: John Scipione <jscipione@xxxxxxxxx> Date: Mon Jul 28 15:07:10 2014 UTC Tracker: Add NULL checks and ASSERTs To prevent recoverable NULL pointer dereferences. Dereferencing a NULL pointer is undefined behavior and should be avoided. Unrecoverable NULL checks will be dealt with in the next commit. ---------------------------------------------------------------------------- ############################################################################ Commit: 2f60dea53ae5e08baeae2c4e41c89a8d2e74aaa6 URL: http://cgit.haiku-os.org/haiku/commit/?id=2f60dea Author: John Scipione <jscipione@xxxxxxxxx> Date: Tue Jul 29 21:11:21 2014 UTC Tracker: Throw exception on assert failure ... in situations where a NULL pointer dereference was vital to the functioning of the method we use a stronger assert that throws an exception on failure. This is accomplished by a new method in Utilities.cpp, ThrowOnAssert(). None of these conditions should ever be true, if they are it means that the code is written improperly and would have resulted in a NULL dereference and undefined behavior (most likely a crash) before. Most instances of ThrowOnAssert() either replace an ASSERT followed by a dereference or an early return that covered the error. Also remove _ThrowOnErrorWithMessage() which wasn't being used. ---------------------------------------------------------------------------- ############################################################################ Revision: hrev47664 Commit: 3e2653e609fa2f28ce9dfc0a86097fc408d9966e URL: http://cgit.haiku-os.org/haiku/commit/?id=3e2653e Author: John Scipione <jscipione@xxxxxxxxx> Date: Sun Aug 10 20:16:54 2014 UTC Tracker: re-add includes that were lost during merge ----------------------------------------------------------------------------