changeset 125:1feb02b24d1c

Fix in FileDialog string convertion
author Frank Benoit <benoit@tionex.de>
date Mon, 21 Jan 2008 00:17:23 +0100
parents 11b0a1324732
children 73b4c55700ec
files doc/todo.txt dwt/widgets/FileDialog.d dwtexamples/addressbook/AddressBook.d
diffstat 3 files changed, 16 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/doc/todo.txt	Sun Jan 20 23:09:45 2008 +0100
+++ b/doc/todo.txt	Mon Jan 21 00:17:23 2008 +0100
@@ -19,7 +19,7 @@
         s   checked switches to have a 'default' case
         o   checked all override methods, added 'override' and/or aliases
         r   A second person did a review Java vs D
-
+        a   checked all anon-classes for stack access
 
 
 Next Steps:
@@ -222,7 +222,7 @@
 internal/image/TIFFRandomFileAccess             // OKs
 internal/image/WinBMPFileFormat                 // OKs
 internal/image/WinICOFileFormat                 // OKs
- 
+
 internal/gtk/GdkEventCrossing                   // X
 internal/gtk/XAnyEvent                          // X
 internal/gtk/OS                                 // OKs
--- a/dwt/widgets/FileDialog.d	Sun Jan 20 23:09:45 2008 +0100
+++ b/dwt/widgets/FileDialog.d	Mon Jan 21 00:17:23 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
  * Copyright (c) 2000, 2007 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
@@ -107,13 +107,14 @@
         int writePos = 0;
         for (int i = 0; i < listLength; i++) {
             auto name = cast(char*)OS.g_slist_data (current);
-            auto utf8Ptr = OS.g_filename_to_utf8 (name, -1, null, null, null);
+            uint items_written;
+            char* utf8Ptr = OS.g_filename_to_utf8 (name, -1, null, &items_written, null);
             OS.g_free (name);
             if (utf8Ptr !is null) {
-                fullPath = tango.stdc.stringz.fromUtf8z( utf8Ptr );
+                fullPath = utf8Ptr[ 0 .. items_written ].dup;
                 int start = tango.text.Util.locatePrior( fullPath, SEPARATOR);
-                if( start == fullPath.length ) start = -1;
-                fileNames [writePos++] = fullPath[ start + 1 .. $ ];
+                if( start is fullPath.length ) start = -1;
+                fileNames [writePos++] = fullPath[ start + 1 .. $ ].dup;
                 OS.g_free (utf8Ptr);
             }
             current = OS.g_slist_next (current);
@@ -127,10 +128,11 @@
     } else {
         auto path = OS.gtk_file_chooser_get_filename (handle);
         if (path !is null) {
-            auto utf8Ptr = OS.g_filename_to_utf8 (path, -1, null, null, null);
+            uint items_written;
+            auto utf8Ptr = OS.g_filename_to_utf8 (path, -1, null, &items_written, null);
             OS.g_free (path);
             if (utf8Ptr !is null) {
-                fullPath = tango.stdc.stringz.fromUtf8z( utf8Ptr );
+                fullPath = utf8Ptr[ 0 .. items_written ].dup;
                 fileNames = new char[] [1];
                 int start = tango.text.Util.locatePrior( fullPath, SEPARATOR);
                 if( start == fullPath.length ) start = -1;
@@ -179,8 +181,9 @@
     }
 
     auto fileNamePtr = OS.gtk_file_selection_get_filename (handle);
-    auto utf8Ptr = OS.g_filename_to_utf8 (fileNamePtr, -1, null, null, null);
-    char[] osAnswer = tango.stdc.stringz.fromUtf8z( utf8Ptr ).dup;
+    uint items_written;
+    auto utf8Ptr = OS.g_filename_to_utf8 (fileNamePtr, -1, null, &items_written, null);
+    char[] osAnswer = utf8Ptr[ 0 .. items_written ].dup;
     OS.g_free (utf8Ptr);
 
     if (osAnswer.length is 0) return null;
@@ -204,8 +207,8 @@
         }
         fileNames = new char[][](length_);
         for (int i = 0; i < length_; i++) {
-            utf8Ptr = OS.g_filename_to_utf8 (namesPtr [i], -1, null, null, null);
-            char[] name = tango.stdc.stringz.fromUtf8z(utf8Ptr);
+            utf8Ptr = OS.g_filename_to_utf8 (namesPtr [i], -1, null, &items_written, null);
+            char[] name = utf8Ptr[ 0 .. items_written ].dup;
             int start = tango.text.Util.locatePrior( name, SEPARATOR);
             if( start == name.length ) start = -1;
             fileNames [i] = name[ start + 1 .. $ ].dup;
@@ -412,7 +415,6 @@
                 OS.gtk_file_filter_add_pattern (filter, filterString);
                 start = index + 1;
                 index = tango.text.Util.locate( filterExtensions [i], EXTENSION_SEPARATOR, start);
-                if( index == filterExtensions [i].length) index = -1;
             }
             char[] current = filterExtensions [i][ start .. $ ];
             char* filterString = tango.stdc.stringz.toStringz(current);
--- a/dwtexamples/addressbook/AddressBook.d	Sun Jan 20 23:09:45 2008 +0100
+++ b/dwtexamples/addressbook/AddressBook.d	Mon Jan 21 00:17:23 2008 +0100
@@ -416,7 +416,6 @@
 
     saveDialog.open();
     char[] name = saveDialog.getFileName();
-
     if(!name) return false;
 
     if( TextUtil.locatePatternPrior( name, ".adr" ) !is name.length - 4) {