[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18759] trunk/blender/intern/ghost/intern/ GHOST_SystemX11.cpp: Fix revision: 18690, bug #17850

Diego Borghetti bdiego at gmail.com
Fri Jan 30 22:01:18 CET 2009


Revision: 18759
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18759
Author:   bdiego
Date:     2009-01-30 22:01:18 +0100 (Fri, 30 Jan 2009)

Log Message:
-----------
Fix revision: 18690, bug #17850

The problem was that Qt convert the text to the type
STRING or UTF8, that is why Blender can't get the text,
now should be work fine.

Modified Paths:
--------------
    trunk/blender/intern/ghost/intern/GHOST_SystemX11.cpp

Modified: trunk/blender/intern/ghost/intern/GHOST_SystemX11.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemX11.cpp	2009-01-30 20:35:37 UTC (rev 18758)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemX11.cpp	2009-01-30 21:01:18 UTC (rev 18759)
@@ -981,11 +981,11 @@
 ) const {
 	//Flag 
 	//0 = Regular clipboard 1 = selection
-	static Atom Primary_atom, clip_String, compound_text;
+	static Atom Primary_atom, clip_String, compound_text, a_text, a_string;
 	Atom rtype;
 	Window m_window, owner;
 	unsigned char *data, *tmp_data;
-	int bits;
+	int bits, count;
 	unsigned long len, bytes;
 	XEvent xevent;
 	
@@ -996,6 +996,8 @@
 
 	clip_String = XInternAtom(m_display, "_BLENDER_STRING", False);
 	compound_text = XInternAtom(m_display, "COMPOUND_TEXT", False);
+	a_text= XInternAtom(m_display, "TEXT", False);
+	a_string= XInternAtom(m_display, "STRING", False);
 
 	//lets check the owner and if it is us then return the static buffer
 	if(flag == 0) {
@@ -1029,23 +1031,46 @@
 	XFlush(m_display);
 
 	//This needs to change so we do not wait for ever or check owner first
+	count= 1;
 	while(1) {
 		XNextEvent(m_display, &xevent);
-		if(xevent.type == SelectionNotify) { 
-			if (xevent.xselection.property ) { /* eric4 on linux gives zero Atom xevent.xselection.property value, closes blender instantly */
+		if(xevent.type == SelectionNotify) {
+			if (xevent.xselection.property == None) {
+				/* Ok, the client can't convert the property
+				 * to some that we can handle, try other types..
+				 */
+				if (count == 1) {
+					XConvertSelection(m_display, Primary_atom, a_text, clip_String, m_window, CurrentTime);
+					count++;
+				}
+				else if (count == 2) {
+					XConvertSelection(m_display, Primary_atom, a_string, clip_String, m_window, CurrentTime);
+					count++;
+				}
+				else {
+					/* Ok, the owner of the selection can't 
+					 * convert the data to something that we can
+					 * handle.
+					 */
+					return(NULL);
+				}
+			}
+			else {
 				if(XGetWindowProperty(m_display, m_window, xevent.xselection.property , 0L, 4096L, False, AnyPropertyType, &rtype, &bits, &len, &bytes, &data) == Success) {
 					if (data) {
-						tmp_data = (unsigned char*) malloc(strlen((char*)data)+1);
-						strcpy((char*)tmp_data, (char*)data);
+						if (bits == 8 && (rtype == compound_text || rtype == a_text || rtype == a_string)) {
+							tmp_data = (unsigned char*) malloc(strlen((char*)data)+1);
+							strcpy((char*)tmp_data, (char*)data);
+						}
+						else
+							tmp_data= NULL;
+
 						XFree(data);
 						return (GHOST_TUns8*)tmp_data;
 					}
 				}
+				return(NULL);
 			}
-			else {
-				fprintf(stderr, "error: cut buffer had a zero xevent.xselection.property, FIXME\n"); // XXX fix this problem!
-			}
-			return NULL;
 		}
 	}
 }





More information about the Bf-blender-cvs mailing list