Don't free a string that is managed by wxGtkString, that's the whole _point_ of wxGtkString.
While we're at it, lets use it some more. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41597 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -23,7 +23,7 @@
|
|||||||
#include "wx/mstream.h"
|
#include "wx/mstream.h"
|
||||||
#include "wx/uri.h"
|
#include "wx/uri.h"
|
||||||
|
|
||||||
#include <gdk/gdk.h>
|
#include "wx/gtk/private.h"
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// global data
|
// global data
|
||||||
@@ -110,10 +110,8 @@ wxDataFormatId wxDataFormat::GetType() const
|
|||||||
|
|
||||||
wxString wxDataFormat::GetId() const
|
wxString wxDataFormat::GetId() const
|
||||||
{
|
{
|
||||||
gchar* atom_name = gdk_atom_name( m_format );
|
wxGtkString atom_name(gdk_atom_name(m_format));
|
||||||
wxString ret = wxString::FromAscii( atom_name );
|
return wxString::FromAscii(atom_name);
|
||||||
g_free(atom_name);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDataFormat::SetId( NativeFormat format )
|
void wxDataFormat::SetId( NativeFormat format )
|
||||||
|
@@ -29,18 +29,10 @@
|
|||||||
#include "wx/filedlg.h"
|
#include "wx/filedlg.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
|
||||||
#include "wx/gtk/private.h"
|
#include "wx/gtk/private.h"
|
||||||
|
|
||||||
#include <unistd.h> // chdir
|
#include <unistd.h> // chdir
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// idle system
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
extern void wxapp_install_idle_handler();
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// "clicked" for OK-button
|
// "clicked" for OK-button
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -48,13 +40,12 @@ extern void wxapp_install_idle_handler();
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
static void gtk_dirdialog_ok_callback(GtkWidget *widget, wxDirDialog *dialog)
|
static void gtk_dirdialog_ok_callback(GtkWidget *widget, wxDirDialog *dialog)
|
||||||
{
|
{
|
||||||
gchar* filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget));
|
|
||||||
|
|
||||||
// change to the directory where the user went if asked
|
// change to the directory where the user went if asked
|
||||||
if (dialog->HasFlag(wxDD_CHANGE_DIR))
|
if (dialog->HasFlag(wxDD_CHANGE_DIR))
|
||||||
|
{
|
||||||
|
wxGtkString filename(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget)));
|
||||||
chdir(filename);
|
chdir(filename);
|
||||||
|
}
|
||||||
g_free(filename);
|
|
||||||
|
|
||||||
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK);
|
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK);
|
||||||
event.SetEventObject(dialog);
|
event.SetEventObject(dialog);
|
||||||
@@ -213,13 +204,10 @@ wxString wxDirDialog::GetPath() const
|
|||||||
{
|
{
|
||||||
if (!gtk_check_version(2,4,0))
|
if (!gtk_check_version(2,4,0))
|
||||||
{
|
{
|
||||||
gchar *str = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(m_widget) );
|
wxGtkString str(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(m_widget)));
|
||||||
wxString ret = wxConvFileName->cMB2WX(str);
|
return wxConvFileName->cMB2WX(str);
|
||||||
if (str) g_free(str);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
return wxGenericDirDialog::GetPath();
|
return wxGenericDirDialog::GetPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -42,7 +42,7 @@ extern "C" {
|
|||||||
static void gtk_filedialog_ok_callback(GtkWidget *widget, wxFileDialog *dialog)
|
static void gtk_filedialog_ok_callback(GtkWidget *widget, wxFileDialog *dialog)
|
||||||
{
|
{
|
||||||
int style = dialog->GetWindowStyle();
|
int style = dialog->GetWindowStyle();
|
||||||
gchar* filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget));
|
wxGtkString filename(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget)));
|
||||||
|
|
||||||
// gtk version numbers must be identical with the one in ctor (that calls set_do_overwrite_confirmation)
|
// gtk version numbers must be identical with the one in ctor (that calls set_do_overwrite_confirmation)
|
||||||
#if GTK_CHECK_VERSION(2,7,3)
|
#if GTK_CHECK_VERSION(2,7,3)
|
||||||
@@ -69,13 +69,10 @@ static void gtk_filedialog_ok_callback(GtkWidget *widget, wxFileDialog *dialog)
|
|||||||
if (style & wxFD_CHANGE_DIR)
|
if (style & wxFD_CHANGE_DIR)
|
||||||
{
|
{
|
||||||
// Use chdir to not care about filename encodings
|
// Use chdir to not care about filename encodings
|
||||||
gchar* folder = g_path_get_dirname(filename);
|
wxGtkString folder(g_path_get_dirname(filename));
|
||||||
chdir(folder);
|
chdir(folder);
|
||||||
g_free(folder);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free(filename);
|
|
||||||
|
|
||||||
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK);
|
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK);
|
||||||
event.SetEventObject(dialog);
|
event.SetEventObject(dialog);
|
||||||
dialog->GetEventHandler()->ProcessEvent(event);
|
dialog->GetEventHandler()->ProcessEvent(event);
|
||||||
@@ -114,9 +111,7 @@ static void gtk_filedialog_update_preview_callback(GtkFileChooser *chooser,
|
|||||||
#if GTK_CHECK_VERSION(2,4,0)
|
#if GTK_CHECK_VERSION(2,4,0)
|
||||||
GtkWidget *preview = GTK_WIDGET(user_data);
|
GtkWidget *preview = GTK_WIDGET(user_data);
|
||||||
|
|
||||||
gchar *str = gtk_file_chooser_get_preview_filename(chooser);
|
wxGtkString filename(gtk_file_chooser_get_preview_filename(chooser));
|
||||||
wxGtkString filename(str);
|
|
||||||
if (str) g_free(str);
|
|
||||||
|
|
||||||
if ( !filename )
|
if ( !filename )
|
||||||
return;
|
return;
|
||||||
@@ -310,13 +305,10 @@ wxString wxFileDialog::GetPath() const
|
|||||||
{
|
{
|
||||||
if (!gtk_check_version(2,4,0))
|
if (!gtk_check_version(2,4,0))
|
||||||
{
|
{
|
||||||
gchar *str = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(m_widget));
|
wxGtkString str(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(m_widget)));
|
||||||
wxString ret = wxConvFileName->cMB2WX(str);
|
return wxConvFileName->cMB2WX(str);
|
||||||
if (str) g_free(str);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
return wxGenericFileDialog::GetPath();
|
return wxGenericFileDialog::GetPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -401,13 +393,10 @@ wxString wxFileDialog::GetDirectory() const
|
|||||||
{
|
{
|
||||||
if (!gtk_check_version(2,4,0))
|
if (!gtk_check_version(2,4,0))
|
||||||
{
|
{
|
||||||
gchar *str = gtk_file_chooser_get_current_folder( GTK_FILE_CHOOSER(m_widget) );
|
wxGtkString str(gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(m_widget)));
|
||||||
wxString ret = wxConvFileName->cMB2WX(str);
|
return wxConvFileName->cMB2WX(str);
|
||||||
if (str) g_free(str);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
return wxGenericFileDialog::GetDirectory();
|
return wxGenericFileDialog::GetDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -22,9 +22,7 @@
|
|||||||
#include "wx/filepicker.h"
|
#include "wx/filepicker.h"
|
||||||
#include "wx/tooltip.h"
|
#include "wx/tooltip.h"
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include "wx/gtk/private.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// implementation
|
// implementation
|
||||||
@@ -162,7 +160,7 @@ static void gtk_dirbutton_currentfolderchanged_callback(GtkFileChooserButton *wi
|
|||||||
|
|
||||||
// NB: it's important to use gtk_file_chooser_get_filename instead of
|
// NB: it's important to use gtk_file_chooser_get_filename instead of
|
||||||
// gtk_file_chooser_get_current_folder (see GTK docs) !
|
// gtk_file_chooser_get_current_folder (see GTK docs) !
|
||||||
gchar* filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget));
|
wxGtkString filename(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget)));
|
||||||
p->UpdatePath(filename);
|
p->UpdatePath(filename);
|
||||||
|
|
||||||
// since GtkFileChooserButton when used to pick directories also uses a combobox,
|
// since GtkFileChooserButton when used to pick directories also uses a combobox,
|
||||||
@@ -172,7 +170,6 @@ static void gtk_dirbutton_currentfolderchanged_callback(GtkFileChooserButton *wi
|
|||||||
// style was given.
|
// style was given.
|
||||||
if (p->HasFlag(wxDIRP_CHANGE_DIR))
|
if (p->HasFlag(wxDIRP_CHANGE_DIR))
|
||||||
chdir(filename);
|
chdir(filename);
|
||||||
g_free(filename);
|
|
||||||
|
|
||||||
// ...and fire an event
|
// ...and fire an event
|
||||||
wxFileDirPickerEvent event(wxEVT_COMMAND_DIRPICKER_CHANGED, p, p->GetId(), p->GetPath());
|
wxFileDirPickerEvent event(wxEVT_COMMAND_DIRPICKER_CHANGED, p, p->GetId(), p->GetPath());
|
||||||
|
@@ -60,11 +60,9 @@ void gtk_fontdialog_ok_callback( GtkWidget *WXUNUSED(widget), wxFontDialog *dial
|
|||||||
|
|
||||||
GtkFontSelectionDialog *fontdlg = GTK_FONT_SELECTION_DIALOG(dialog->m_widget);
|
GtkFontSelectionDialog *fontdlg = GTK_FONT_SELECTION_DIALOG(dialog->m_widget);
|
||||||
|
|
||||||
gchar *fontname = gtk_font_selection_dialog_get_font_name(fontdlg);
|
wxGtkString fontname(gtk_font_selection_dialog_get_font_name(fontdlg));
|
||||||
dialog->SetChosenFont( fontname);
|
dialog->SetChosenFont( fontname);
|
||||||
|
|
||||||
g_free( fontname );
|
|
||||||
|
|
||||||
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK);
|
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK);
|
||||||
event.SetEventObject( dialog );
|
event.SetEventObject( dialog );
|
||||||
dialog->GetEventHandler()->ProcessEvent( event );
|
dialog->GetEventHandler()->ProcessEvent( event );
|
||||||
|
@@ -392,12 +392,11 @@ static gboolean gtk_listbox_searchequal_callback(GtkTreeModel* model,
|
|||||||
WXLISTBOX_DATACOLUMN_ARG(listbox),
|
WXLISTBOX_DATACOLUMN_ARG(listbox),
|
||||||
&entry, -1);
|
&entry, -1);
|
||||||
wxCHECK_MSG(entry, 0, wxT("Could not get entry"));
|
wxCHECK_MSG(entry, 0, wxT("Could not get entry"));
|
||||||
gchar* keycollatekey = g_utf8_collate_key(key, -1);
|
wxGtkString keycollatekey(g_utf8_collate_key(key, -1));
|
||||||
|
|
||||||
int ret = strcasecmp(keycollatekey,
|
int ret = strcasecmp(keycollatekey,
|
||||||
gtk_tree_entry_get_collate_key(entry));
|
gtk_tree_entry_get_collate_key(entry));
|
||||||
|
|
||||||
g_free(keycollatekey);
|
|
||||||
g_object_unref (entry);
|
g_object_unref (entry);
|
||||||
|
|
||||||
return ret != 0;
|
return ret != 0;
|
||||||
|
@@ -69,10 +69,9 @@ static void wxGtkTextApplyTagsFromAttr(GtkTextBuffer *text_buffer,
|
|||||||
|
|
||||||
if (attr.HasFont())
|
if (attr.HasFont())
|
||||||
{
|
{
|
||||||
char *font_string;
|
|
||||||
PangoFontDescription *font_description = attr.GetFont().GetNativeFontInfo()->description;
|
PangoFontDescription *font_description = attr.GetFont().GetNativeFontInfo()->description;
|
||||||
font_string = pango_font_description_to_string(font_description);
|
wxGtkString font_string(pango_font_description_to_string(font_description));
|
||||||
g_snprintf(buf, sizeof(buf), "WXFONT %s", font_string);
|
g_snprintf(buf, sizeof(buf), "WXFONT %s", font_string.c_str());
|
||||||
tag = gtk_text_tag_table_lookup( gtk_text_buffer_get_tag_table( text_buffer ),
|
tag = gtk_text_tag_table_lookup( gtk_text_buffer_get_tag_table( text_buffer ),
|
||||||
buf );
|
buf );
|
||||||
if (!tag)
|
if (!tag)
|
||||||
@@ -80,7 +79,6 @@ static void wxGtkTextApplyTagsFromAttr(GtkTextBuffer *text_buffer,
|
|||||||
"font-desc", font_description,
|
"font-desc", font_description,
|
||||||
NULL );
|
NULL );
|
||||||
gtk_text_buffer_apply_tag (text_buffer, tag, start, end);
|
gtk_text_buffer_apply_tag (text_buffer, tag, start, end);
|
||||||
g_free (font_string);
|
|
||||||
|
|
||||||
if (attr.GetFont().GetUnderlined())
|
if (attr.GetFont().GetUnderlined())
|
||||||
{
|
{
|
||||||
@@ -787,13 +785,11 @@ wxString wxTextCtrl::GetValue() const
|
|||||||
gtk_text_buffer_get_start_iter( m_buffer, &start );
|
gtk_text_buffer_get_start_iter( m_buffer, &start );
|
||||||
GtkTextIter end;
|
GtkTextIter end;
|
||||||
gtk_text_buffer_get_end_iter( m_buffer, &end );
|
gtk_text_buffer_get_end_iter( m_buffer, &end );
|
||||||
gchar *text = gtk_text_buffer_get_text( m_buffer, &start, &end, TRUE );
|
wxGtkString text(gtk_text_buffer_get_text(m_buffer, &start, &end, true));
|
||||||
|
|
||||||
const wxWxCharBuffer buf = wxGTK_CONV_BACK(text);
|
const wxWxCharBuffer buf = wxGTK_CONV_BACK(text);
|
||||||
if ( buf )
|
if ( buf )
|
||||||
tmp = buf;
|
tmp = buf;
|
||||||
|
|
||||||
g_free( text );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -942,22 +938,22 @@ void wxTextCtrl::AppendText( const wxString &text )
|
|||||||
|
|
||||||
wxString wxTextCtrl::GetLineText( long lineNo ) const
|
wxString wxTextCtrl::GetLineText( long lineNo ) const
|
||||||
{
|
{
|
||||||
|
wxString result;
|
||||||
if ( IsMultiLine() )
|
if ( IsMultiLine() )
|
||||||
{
|
{
|
||||||
GtkTextIter line;
|
GtkTextIter line;
|
||||||
gtk_text_buffer_get_iter_at_line(m_buffer,&line,lineNo);
|
gtk_text_buffer_get_iter_at_line(m_buffer,&line,lineNo);
|
||||||
GtkTextIter end = line;
|
GtkTextIter end = line;
|
||||||
gtk_text_iter_forward_to_line_end(&end);
|
gtk_text_iter_forward_to_line_end(&end);
|
||||||
gchar *text = gtk_text_buffer_get_text(m_buffer,&line,&end,TRUE);
|
wxGtkString text(gtk_text_buffer_get_text(m_buffer, &line, &end, true));
|
||||||
wxString result(wxGTK_CONV_BACK(text));
|
result = wxGTK_CONV_BACK(text);
|
||||||
g_free(text);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (lineNo == 0) return GetValue();
|
if (lineNo == 0)
|
||||||
return wxEmptyString;
|
result = GetValue();
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextCtrl::OnDropFiles( wxDropFilesEvent &WXUNUSED(event) )
|
void wxTextCtrl::OnDropFiles( wxDropFilesEvent &WXUNUSED(event) )
|
||||||
|
Reference in New Issue
Block a user