From 1842a11f5629314a037e86de80ebdaf50a9b5884 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Mon, 28 May 2018 13:19:49 -0700 Subject: [PATCH] Fix errors saving PCs that were discovered via mDNS --- Limelight/Database/TemporaryHost.m | 19 ++++++++--- .../Limelight.xcdatamodeld/.xccurrentversion | 2 +- .../Moonlight v1.0-2.xcdatamodel/contents | 14 ++++---- .../Moonlight v1.1.xcdatamodel/contents | 33 +++++++++++++++++++ Moonlight.xcodeproj/project.pbxproj | 4 ++- 5 files changed, 59 insertions(+), 13 deletions(-) create mode 100644 Limelight/Limelight.xcdatamodeld/Moonlight v1.1.xcdatamodel/contents diff --git a/Limelight/Database/TemporaryHost.m b/Limelight/Database/TemporaryHost.m index cac204d..90b884f 100644 --- a/Limelight/Database/TemporaryHost.m +++ b/Limelight/Database/TemporaryHost.m @@ -44,10 +44,21 @@ } - (void) propagateChangesToParent:(Host*)parentHost { - parentHost.address = self.address; - parentHost.externalAddress = self.externalAddress; - parentHost.localAddress = self.localAddress; - parentHost.mac = self.mac; + // Avoid overwriting existing data with nil if + // we don't have everything populated in the temporary + // host. + if (self.address != nil) { + parentHost.address = self.address; + } + if (self.externalAddress != nil) { + parentHost.externalAddress = self.externalAddress; + } + if (self.localAddress != nil) { + parentHost.localAddress = self.localAddress; + } + if (self.mac != nil) { + parentHost.mac = self.mac; + } parentHost.name = self.name; parentHost.uuid = self.uuid; parentHost.pairState = [NSNumber numberWithInt:self.pairState]; diff --git a/Limelight/Limelight.xcdatamodeld/.xccurrentversion b/Limelight/Limelight.xcdatamodeld/.xccurrentversion index 2346a99..d880a37 100644 --- a/Limelight/Limelight.xcdatamodeld/.xccurrentversion +++ b/Limelight/Limelight.xcdatamodeld/.xccurrentversion @@ -3,6 +3,6 @@ _XCCurrentVersionName - Moonlight v1.0-2.xcdatamodel + Moonlight v1.1.xcdatamodel diff --git a/Limelight/Limelight.xcdatamodeld/Moonlight v1.0-2.xcdatamodel/contents b/Limelight/Limelight.xcdatamodeld/Moonlight v1.0-2.xcdatamodel/contents index dcaff78..a9ff5b4 100644 --- a/Limelight/Limelight.xcdatamodeld/Moonlight v1.0-2.xcdatamodel/contents +++ b/Limelight/Limelight.xcdatamodeld/Moonlight v1.0-2.xcdatamodel/contents @@ -1,12 +1,12 @@ - - + + - + @@ -16,7 +16,7 @@ - + @@ -26,8 +26,8 @@ - - - + + + \ No newline at end of file diff --git a/Limelight/Limelight.xcdatamodeld/Moonlight v1.1.xcdatamodel/contents b/Limelight/Limelight.xcdatamodeld/Moonlight v1.1.xcdatamodel/contents new file mode 100644 index 0000000..cf4bf86 --- /dev/null +++ b/Limelight/Limelight.xcdatamodeld/Moonlight v1.1.xcdatamodel/contents @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Moonlight.xcodeproj/project.pbxproj b/Moonlight.xcodeproj/project.pbxproj index 6e04c3d..d1ad2aa 100644 --- a/Moonlight.xcodeproj/project.pbxproj +++ b/Moonlight.xcodeproj/project.pbxproj @@ -100,6 +100,7 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 98132E8C20BC9A62007A053F /* Moonlight v1.1.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "Moonlight v1.1.xcdatamodel"; sourceTree = ""; }; 9832D1341BBCD5C50036EF48 /* TemporaryApp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TemporaryApp.h; path = Database/TemporaryApp.h; sourceTree = ""; }; 9832D1351BBCD5C50036EF48 /* TemporaryApp.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TemporaryApp.m; path = Database/TemporaryApp.m; sourceTree = ""; }; 98878AE0206A226D00586E90 /* OSPortabilityDefs.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OSPortabilityDefs.h; sourceTree = ""; }; @@ -1220,13 +1221,14 @@ FB290D0519B2C406004C83CF /* Limelight.xcdatamodeld */ = { isa = XCVersionGroup; children = ( + 98132E8C20BC9A62007A053F /* Moonlight v1.1.xcdatamodel */, FB53E1441BE5DCBC00CD6ECE /* Moonlight v1.0-2.xcdatamodel */, FBB460391B50ACE400F3099C /* Moonlight v1.0.xcdatamodel */, FB6549621A60B4A9001C8F39 /* Limelight 0.3.1.xcdatamodel */, FB4678F21A51BDCB00377732 /* Limelight 0.3.0.xcdatamodel */, FB290D0619B2C406004C83CF /* Limelight.xcdatamodel */, ); - currentVersion = FB53E1441BE5DCBC00CD6ECE /* Moonlight v1.0-2.xcdatamodel */; + currentVersion = 98132E8C20BC9A62007A053F /* Moonlight v1.1.xcdatamodel */; path = Limelight.xcdatamodeld; sourceTree = ""; versionGroupType = wrapper.xcdatamodel;