home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 1
MediaPortal 1 Plugins
Popular Plugins
Moving Pictures
GUI Toggle Watched Event
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="popy" data-source="post: 1123472" data-attributes="member: 114134"><p>Update: I have solved it.</p><p></p><p>The issue is in the ByteArray.cs of CornerStone.</p><p>Old Code:</p><p></p><p>[code] public byte[] Data {</p><p> get {</p><p> if (_data.Length == 0)</p><p> return null;</p><p> else</p><p> return _data;</p><p> }</p><p> set { _data = value; }</p><p> }</p><p> private byte[] _data = null;</p><p></p><p> public ByteArray() {</p><p> }</p><p></p><p> public ByteArray(byte[] data) {</p><p> _data = data;</p><p> }[/code]</p><p></p><p>Ill think it happens that when an new ByteArray is instanced with no given "data" and "Data" is accessed, the code access <strong>"_data.Length" (bold above)</strong> and there the exception is thrown!</p><p></p><p>Fixed Code:</p><p></p><p>[code] public byte[] Data {</p><p> get {</p><p> if ((_data == null) || (_data.Length == 0))</p><p> return null;</p><p> else</p><p> return _data;</p><p> }</p><p> set { _data = value; }</p><p> }</p><p> private byte[] _data = null;</p><p></p><p> public ByteArray() {</p><p> }</p><p></p><p> public ByteArray(byte[] data) {</p><p> _data = data;</p><p> }[/code]</p><p></p><p>My workaround in my current code of WatchedSyncronizer:</p><p></p><p>[code] private void OnMovingPicturesDatabaseUpdated(DatabaseTable dbObject, TableUpdateInfo ui)</p><p> {</p><p> WatchedStateEvent curEvent = new WatchedStateEvent();</p><p> byte[] bteTmpResumeData = new byte[] { };</p><p></p><p> // If it is user settings for a movie</p><p> if (dbObject.GetType() != typeof(DBUserMovieSettings))</p><p> {</p><p> Log.Debug("WatchedSynchronizer: OnMovingPicturesDatabaseUpdated: unknown object type: '" + dbObject.GetType().ToString() + "', event dropped!");</p><p> return;</p><p> }</p><p></p><p> //Cast to DBUserMovieSettings object and get movie details</p><p> DBUserMovieSettings userMovieSettings = (DBUserMovieSettings)dbObject;</p><p> DBMovieInfo movie = userMovieSettings.AttachedMovies[0];</p><p></p><p> //check if userMovieSettings.ResumeData is null or empty string</p><p> //if that is the case reinitialize userMovieSettings.ResumeData with an empty byte array to prevent null exception when accessing userMovieSettings.ResumeData.Data</p><p> //this should be fixed in ByteArray.cs of Cornerstone. There is access to _data.length and NO null check before!</p><p> if ((userMovieSettings.ResumeData == null) || (userMovieSettings.ResumeData.ToString() == ""))</p><p> {</p><p> userMovieSettings.ResumeData = new ByteArray(bteTmpResumeData);</p><p> }[/code]</p><p></p><p>pOpY</p></blockquote><p></p>
[QUOTE="popy, post: 1123472, member: 114134"] Update: I have solved it. The issue is in the ByteArray.cs of CornerStone. Old Code: [code] public byte[] Data { get { if (_data.Length == 0) return null; else return _data; } set { _data = value; } } private byte[] _data = null; public ByteArray() { } public ByteArray(byte[] data) { _data = data; }[/code] Ill think it happens that when an new ByteArray is instanced with no given "data" and "Data" is accessed, the code access [B]"_data.Length" (bold above)[/B] and there the exception is thrown! Fixed Code: [code] public byte[] Data { get { if ((_data == null) || (_data.Length == 0)) return null; else return _data; } set { _data = value; } } private byte[] _data = null; public ByteArray() { } public ByteArray(byte[] data) { _data = data; }[/code] My workaround in my current code of WatchedSyncronizer: [code] private void OnMovingPicturesDatabaseUpdated(DatabaseTable dbObject, TableUpdateInfo ui) { WatchedStateEvent curEvent = new WatchedStateEvent(); byte[] bteTmpResumeData = new byte[] { }; // If it is user settings for a movie if (dbObject.GetType() != typeof(DBUserMovieSettings)) { Log.Debug("WatchedSynchronizer: OnMovingPicturesDatabaseUpdated: unknown object type: '" + dbObject.GetType().ToString() + "', event dropped!"); return; } //Cast to DBUserMovieSettings object and get movie details DBUserMovieSettings userMovieSettings = (DBUserMovieSettings)dbObject; DBMovieInfo movie = userMovieSettings.AttachedMovies[0]; //check if userMovieSettings.ResumeData is null or empty string //if that is the case reinitialize userMovieSettings.ResumeData with an empty byte array to prevent null exception when accessing userMovieSettings.ResumeData.Data //this should be fixed in ByteArray.cs of Cornerstone. There is access to _data.length and NO null check before! if ((userMovieSettings.ResumeData == null) || (userMovieSettings.ResumeData.ToString() == "")) { userMovieSettings.ResumeData = new ByteArray(bteTmpResumeData); }[/code] pOpY [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 1
MediaPortal 1 Plugins
Popular Plugins
Moving Pictures
GUI Toggle Watched Event
Contact us
RSS
Top
Bottom