Commit Graph

530 Commits

Author SHA1 Message Date
Mark Rowe 57ee591809 Merge pull request #78 from realm/mar/weakrealmnotifier-leak
Fix a potential leak within WeakRealmNotifier
2016-06-01 13:07:56 -07:00
Mark Rowe 8685390345 Merge pull request #77 from realm/mar/results-leak
Fix move-assigning to a Results that has a notifier to not leak the Realm
2016-06-01 13:07:45 -07:00
Mark Rowe e2112f8ca5 Merge pull request #81 from realm/mar/core-always-static
Always use core as a static library
2016-06-01 13:07:25 -07:00
Mark Rowe 332813f7f3 Avoid dumping all environment variables when building core without ASan enabled. 2016-06-01 12:20:17 -07:00
Mark Rowe bef0a6ea6e Build core as a static library when building it as a dependency. 2016-06-01 12:19:07 -07:00
Thomas Goyne 6d22d28fea Merge pull request #72 from realm/tg/core-1.0.0
Upgrade to core 1.0.0 and update the file exception translation to match
2016-06-01 12:02:27 -07:00
Mark Rowe 08404d7098 Express `Results`' asignment operators in terms of their equivalent
constructors.

This avoids having to repeat the move constructor's logic in the move
assignment operator, and allows the copy assignment operator to compile
despite `TableViewBase`'s missing copy assignment implementation. the
copy assignment implementation can be defaulted once `TableViewBase` is
fixed.
2016-06-01 11:50:25 -07:00
Mark Rowe 3e952269da Have `Results` default its copy constructor.
The custom implementation was an attempt to ensure that
`m_has_used_table_view` and `m_wants_background_updates` had appropriate
intial values. Thomas pointed out that we can remove the reliance on the
initial values by ensure that `prepare_async` sets
`m_wants_background_updates`, removing the need for a custom copy
constructor.
2016-06-01 11:48:35 -07:00
Mark Rowe fc63c4f67b Merge pull request #76 from realm/mar/fix-building-tests-in-xcode
Fix building tests in Xcode
2016-06-01 11:40:14 -07:00
Mark Rowe 2a75edde8e Move `List`s defaulted constructors and assignment operators out of line. 2016-06-01 11:29:32 -07:00
Scott Kyle 30f1c83197 Merge pull request #75 from realm/sk/android-fixes
Fix for object store build issues on Android
2016-06-01 09:43:25 -07:00
Mark Rowe 702b8a31fb Avoid leaking the runloop and source if WeakRealmNotifier is move-assigned. 2016-05-31 21:54:40 -07:00
Mark Rowe 65a748de0c Fix move-assigning to a `Results` that has a notifier to not leak the
`Realm`, and moving from a `Results` to not result in a use-after-free.

The compiler generated move-assignment operator resulted in `m_notifier`
being assigned to without first calling `CollectionNotifier::unregister`.
This left a retain cycle in place, causing the `Realm` and other objects
to leak.

`ResultsNotifier` keeps track of which `Results` it should update when a
new `TableView` becomes available. When `Results` move-assignment
operator and move-constructor transfer ownership of the
`ResultsNotifier` to a new instance they also need to update its target
so it won't attempt to update the moved-from `Results`.
2016-05-31 19:03:29 -07:00
Mark Rowe 7e99634567 Fix building tests in Xcode.
The Xcode project generated by CMake doesn't create the dylib when built
as the dylib target does not contain any source files. Adding an empty
placeholder .cpp file to the target is sufficient to convince Xcode to
produce the dylib.
2016-05-31 17:16:52 -07:00
Scott Kyle 385fe97861 Make Realm::is_closed() work on read-only instances 2016-05-31 11:27:39 -07:00
Scott Kyle 7bb8a04359 Fix for object store build issues on Android 2016-05-31 11:11:39 -07:00
Yavor Georgiev 91c87e4de6 Implement commit helper and realm notifier for Android (#69)
* Implement commit helper and realm notifier for Android

* Remove non-existent include

* Shut down the current instance when move-assigning

* Only use Android logging when on Android

* Cleanup realm_ptr when it hasn't been sent over the pipe

* Assed that WeakRealmNotifier is closed on the thread it was created on

* Typo

* Fix syntax error

* changes after code review

* Use the proper preprocessor definition for Android

* Pass the correct address to write(2)

* Explicitly handle looper events

* changes after code review

* Do not return after handling ALOOPER_EVENT_HANGUP

* Handle HANGUP after INPUT
2016-05-31 17:15:32 +02:00
Mark Rowe 78c4f30ee9 Merge pull request #57 from realm/nh/update_doc
update doc (install procedure)
2016-05-26 16:09:30 -07:00
Mark Rowe 0976d1839f Merge pull request #49 from realm/mar/static-library
Build both dynamic and static libraries of the object store
2016-05-26 13:57:01 -07:00
Mark Rowe f19bab76bd Build both dynamic and static libraries.
The dynamic library makes it easy to verify that there are no linker
errors when building the object store, while the static library is
easier for a binding to consume.

This also tweaks how the library targets are defined to ensure that
other CMake projects that pull in the libraries automatically get the
right include paths and link to the appropriate libraries.
2016-05-26 13:41:52 -07:00
Thomas Goyne d4feb7e06a Actually bump the core version 2016-05-24 10:46:44 -07:00
Thomas Goyne 840c46f8f3 Upgrade to core 1.0.0 and update the file exception translation to match
File::AccessError is now thrown for all file-related exceptions which don't
have more specific types (rather than std::runtime_error), which requires some
changes to how exception messages are built when translating them to get nice
results.

Also add `Realm::write_copy()` which just wraps `Group::write()` with error
translation.
2016-05-23 10:28:04 -07:00
Thomas Goyne 1d34e785e7 Merge pull request #61 from realm/tg/notifications
Add fine-grained notification stuff
2016-05-20 10:58:34 -07:00
Thomas Goyne db55770bfa Move the notifications fuzzer to the tests directory 2016-05-11 16:08:30 -07:00
Thomas Goyne e6d09b513e Fix an assertion failure in IndexSet::do_add() following a table clear
We don't track insertions and deletions for tables that are merely linked to by
tables actually being observed (for performance reasons, since we don't need
that information), but the check for that was missing in one place. This would
be merely a slowdown rather than a crash, but deletions.add_shifted() can
overflow size_t if the passed-in index represents a newly inserted row and the
check for that didn't work due to not tracking insertions for the table.

The only remotely realistic way to actually have size_t overflow is to have
previously cleared the table (the table clear instruction does not include the
old size of the table, so it just marks {0, SIZE_T_MAX} as deleted).

Fixes #3537.
2016-05-11 16:08:30 -07:00
Thomas Goyne 2bcf42904a Fix some typos in comments 2016-05-11 16:08:30 -07:00
Thomas Goyne b42bf25c99 Fix compilation with latest core 2016-05-11 16:08:30 -07:00
Thomas Goyne 8d9e5db092 Give a variable a less terrible name and add a comment 2016-05-11 16:08:30 -07:00
Mark Rowe ef1c6ddc63 Add support for fine-grained notifications from backlink TVs 2016-05-11 16:08:30 -07:00
Thomas Goyne 03108713ee Make PropertyType an enum class 2016-05-11 16:08:30 -07:00
Thomas Goyne 4cf5d5db4c Report modification paths as pre-delete/inserts as required for UITableView 2016-05-11 16:08:30 -07:00
Thomas Goyne d8a69b87dc Improve change calculation performance for nontrivial object graphs
Skip doing any checking at all if none of the tables reachable from the root
table have been modified (which can happen if the table version was bumped due
to insertions, unrelated backlinks, or unlinked-to rows being deleted in linked
tables).

Add cycle checking rather than relying on the max depth to handle it, as the
worst case was O(N^16) if the cycle involved a LinkList of size N.

Track which rows have been confirmed to have not been modified.

Cache the information about the links for each of the relevant tables as
checking the table schema can get somewhat expensive.
2016-05-11 16:08:30 -07:00
Thomas Goyne f9364b50a4 Return the correct iterator from ChunkedVector::erase()
When a chunk is removed entirely it should return an iterator to the first
element in the next chunk, not the last.
2016-05-11 16:08:30 -07:00
Thomas Goyne 4df552ba2d Clean up old move info even when the row being deleted is the last one 2016-05-11 16:08:30 -07:00
Thomas Goyne 3218740fd9 Fix the check for a deleted LV in ListNotifier::add_required_change_info() 2016-05-11 16:08:30 -07:00
Thomas Goyne 632d757014 Always deliver results to the correct SharedGroup
If there are multiple Realm instances for a single file on a single thread due
to disabling caching we need to actually deliver the results to the appropriate
SharedGroup for each notifier rather than delivering them all to the first one.
2016-05-11 16:08:30 -07:00
Thomas Goyne 8879212111 Fix assertion failure when a notifier is removed before it runs 2016-05-11 16:08:30 -07:00
Thomas Goyne eee6e55eb0 Refactor SortedMoveCalculator and add more of an explanation 2016-05-11 16:08:30 -07:00
Thomas Goyne 95900f5e17 Make more member functions in CollectionNotifier pure virtual 2016-05-11 16:08:30 -07:00
Thomas Goyne 9883944df4 Pull CollectionChangeBuilder into its own file 2016-05-11 16:08:30 -07:00
Thomas Goyne 66666a75b0 Iterate backwards to pick the last valid list in select_link_list 2016-05-11 16:08:30 -07:00
Thomas Goyne 23c16f8e67 Use aggregate initialization for the base class in CollectionChangeBuilder 2016-05-11 16:08:30 -07:00
Thomas Goyne c0350b9001 Rename CollectionChangeIndices to CollectionChangeSet 2016-05-11 16:08:30 -07:00
Thomas Goyne 953e1b15a8 Rename BackgroundCollection to CollectionNotifier 2016-05-11 16:08:30 -07:00
Thomas Goyne fe5564f40e Change all of the mentions of 'query' in NotificationToken to 'notifier' 2016-05-11 16:08:30 -07:00
Thomas Goyne 31c3982bff Fix some typos 2016-05-11 16:08:30 -07:00
Thomas Goyne e75ff49421 Fix check for the target results being invalid in ResultsNotifier::deliver()
m_target_results is no longer actually set to null when the notifier is
unregistered, so check the thing which is (i.e. m_realm).
2016-05-11 16:08:30 -07:00
Thomas Goyne 238e9e3b6b Fix tracking of which tables need change info with multiple source notifier versions 2016-05-11 16:08:30 -07:00
Thomas Goyne ea3a2f4711 Refactor the incremental change tracking for mixed source versions 2016-05-11 16:08:30 -07:00
Thomas Goyne 69cefd052e Deliver the new TableView even if it did not change
Even if the new TV has the same rows as the old one, we need to hand it over to
the destination thread to bump the outside version of the destination thread's
TV to avoid rerunning the query there.
2016-05-11 16:08:30 -07:00