[rkward-cvs] SF.net SVN: rkward:[2433] trunk/rkward

tfry at users.sourceforge.net tfry at users.sourceforge.net
Tue Mar 31 16:48:28 UTC 2009


Revision: 2433
          http://rkward.svn.sourceforge.net/rkward/?rev=2433&view=rev
Author:   tfry
Date:     2009-03-31 16:48:27 +0000 (Tue, 31 Mar 2009)

Log Message:
-----------
Fix crash while moving QStrings

Modified Paths:
--------------
    trunk/rkward/ChangeLog
    trunk/rkward/debian/changelog
    trunk/rkward/debian/copyright
    trunk/rkward/rkward/core/rkvariable.cpp
    trunk/rkward/rkward/core/rkvariable.h

Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog	2009-03-31 16:46:52 UTC (rev 2432)
+++ trunk/rkward/ChangeLog	2009-03-31 16:48:27 UTC (rev 2433)
@@ -1,3 +1,5 @@
+- Fix crash while inserting rows in a data.frame with string variables
+
 --- Version 0.5.0c - Mar-30-2009
 - Fix assorted installation problems
 - Updated translations: German, Spanish

Modified: trunk/rkward/debian/changelog
===================================================================
--- trunk/rkward/debian/changelog	2009-03-31 16:46:52 UTC (rev 2432)
+++ trunk/rkward/debian/changelog	2009-03-31 16:48:27 UTC (rev 2433)
@@ -6,7 +6,7 @@
     closes: #501649
 		TODO: what about #489473?
 
- -- Thomas Friedrichsmeier <tfry at users.sourceforge.net>  Sun, 20 Apr 2008 21:30:00 +0200
+ -- Thomas Friedrichsmeier <tfry at users.sourceforge.net>  Xxx, XX Xxx 2009 21:30:00 +0200
 
 rkward (0.5.0c-1) experimental; urgency=low
 

Modified: trunk/rkward/debian/copyright
===================================================================
--- trunk/rkward/debian/copyright	2009-03-31 16:46:52 UTC (rev 2432)
+++ trunk/rkward/debian/copyright	2009-03-31 16:48:27 UTC (rev 2433)
@@ -3,7 +3,7 @@
 
 It was downloaded from http://rkward.sourceforge.net
 
-Copyright Holder: Thomas Friedrichsmeier and the RKWard team
+Copyright: 2002 - 2009 Thomas Friedrichsmeier and the RKWard team
 
 License:
 You are free to distribute this software under the terms of the GNU General Public License.

Modified: trunk/rkward/rkward/core/rkvariable.cpp
===================================================================
--- trunk/rkward/rkward/core/rkvariable.cpp	2009-03-31 16:46:52 UTC (rev 2432)
+++ trunk/rkward/rkward/core/rkvariable.cpp	2009-03-31 16:48:27 UTC (rev 2433)
@@ -420,7 +420,7 @@
 		RK_ASSERT (data->cell_doubles == 0);
 		QString *new_data = new QString[target];
 		if (data->allocated_length) {		// if not yet allocated, don't mem-move
-			memmove (new_data, data->cell_strings, data->allocated_length * sizeof (QString));
+			memMoveQStrings (new_data, data->cell_strings, data->allocated_length);
 		}
 		delete [] (data->cell_strings);
 		data->cell_strings = new_data;
@@ -729,7 +729,7 @@
 
 	if (to_row < (data->allocated_length - 1)) {	// not the last rows
 		if (data->cell_strings) {
-			memmove (&(data->cell_strings[from_row]), &(data->cell_strings[to_row+1]), (data->allocated_length - to_row - 1) * sizeof (QString));
+			memMoveQStrings (&(data->cell_strings[from_row]), &(data->cell_strings[to_row+1]), (data->allocated_length - to_row - 1));
 		} else {
 			memmove (&(data->cell_doubles[from_row]), &(data->cell_doubles[to_row+1]), (data->allocated_length - to_row - 1) * sizeof (double));
 		}
@@ -777,7 +777,9 @@
 		if (data->cell_doubles) data->cell_doubles[row+count] = 0.0;
 		data->cell_states[row+count] = RKVarEditData::NA;
 	} else {
-		if (data->cell_strings) memmove (&(data->cell_strings[row+count]), &(data->cell_strings[row]), (data->allocated_length - (row + count) - 1) * sizeof (QString));
+		if (data->cell_strings) {
+			memMoveQStrings (&(data->cell_strings[row+count]), &(data->cell_strings[row]), (data->allocated_length - (row + count) - 1));
+		}
 		if (data->cell_doubles) memmove (&(data->cell_doubles[row+count]), &(data->cell_doubles[row]), (data->allocated_length - (row + count) - 1) * sizeof (double));
 		memmove (&(data->cell_states[row+count]), &(data->cell_states[row]), (data->allocated_length - (row + count) - 1) * sizeof (int));
 	}

Modified: trunk/rkward/rkward/core/rkvariable.h
===================================================================
--- trunk/rkward/rkward/core/rkvariable.h	2009-03-31 16:46:52 UTC (rev 2432)
+++ trunk/rkward/rkward/core/rkvariable.h	2009-03-31 16:48:27 UTC (rev 2433)
@@ -200,6 +200,19 @@
 	void allocateEditData ();
 /** discard edit data */
 	void discardEditData ();
+
+/** TODO: QStrings can't be memmoved. We should use QVector/QList instead. */
+	void memMoveQStrings (QString *dst, QString *src, int count) {
+		if (dst > src) {
+			for (int i = count - 1; i >= 0; --i) {
+				dst[i] = src[i];
+			}
+		} else {
+			for (int i = 0; i < count; ++i) {
+				dst[i] = src[i];
+			}
+		}
+	};
 /////////////////// END: data-handling //////////////////////
 };
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the rkward-tracker mailing list