From d5027818a42043052ac375b1a0ba30fac491ddc4 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Thu, 7 Jun 2012 05:18:30 +0000 Subject: [PATCH] fix warnings about conversion to bool, closes #14381 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71685 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/app.cpp | 2 +- src/gtk/button.cpp | 2 +- src/gtk/checkbox.cpp | 6 +++--- src/gtk/checklst.cpp | 2 +- src/gtk/clipbrd.cpp | 2 +- src/gtk/dataview.cpp | 24 ++++++++++-------------- src/gtk/filectrl.cpp | 2 +- src/gtk/listbox.cpp | 2 +- src/gtk/menu.cpp | 2 +- src/gtk/radiobox.cpp | 6 +++--- src/gtk/region.cpp | 4 ++-- src/gtk/spinctrl.cpp | 2 +- src/gtk/textctrl.cpp | 2 +- src/gtk/textentry.cpp | 2 +- src/gtk/toplevel.cpp | 2 +- src/gtk/window.cpp | 7 ++++--- src/msw/ole/uuid.cpp | 2 +- 17 files changed, 34 insertions(+), 37 deletions(-) diff --git a/src/gtk/app.cpp b/src/gtk/app.cpp index ebe21af..318952f 100644 --- a/src/gtk/app.cpp +++ b/src/gtk/app.cpp @@ -368,7 +368,7 @@ bool wxApp::Initialize(int& argc_, wxChar **argv_) init_result = true; // is there a _check() version of this? gpe_application_init( &argcGTK, &argvGTK ); #else - init_result = gtk_init_check( &argcGTK, &argvGTK ); + init_result = gtk_init_check( &argcGTK, &argvGTK ) != 0; #endif wxUpdateLocaleIsUtf8(); diff --git a/src/gtk/button.cpp b/src/gtk/button.cpp index cf3fb8b..d668fb6 100644 --- a/src/gtk/button.cpp +++ b/src/gtk/button.cpp @@ -295,7 +295,7 @@ wxSize wxButton::DoGetBestSize() const // extra border around it, but we don't want to take it into account in // our size calculations (otherwise the result is visually ugly), so // always return the size of non default button from here - const bool isDefault = gtk_widget_has_default(m_widget); + const bool isDefault = gtk_widget_has_default(m_widget) != 0; if ( isDefault ) { // temporarily unset default flag diff --git a/src/gtk/checkbox.cpp b/src/gtk/checkbox.cpp index f7dc166..f793ad7 100644 --- a/src/gtk/checkbox.cpp +++ b/src/gtk/checkbox.cpp @@ -44,8 +44,8 @@ static void gtk_checkbox_toggled_callback(GtkWidget *widget, wxCheckBox *cb) { // The 3 states cycle like this when clicked: // checked -> undetermined -> unchecked -> checked -> ... - bool active = gtk_toggle_button_get_active(toggle); - bool inconsistent = gtk_toggle_button_get_inconsistent(toggle); + bool active = gtk_toggle_button_get_active(toggle) != 0; + bool inconsistent = gtk_toggle_button_get_inconsistent(toggle) != 0; cb->GTKDisableEvents(); @@ -177,7 +177,7 @@ bool wxCheckBox::GetValue() const { wxCHECK_MSG( m_widgetCheckbox != NULL, false, wxT("invalid checkbox") ); - return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_widgetCheckbox)); + return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_widgetCheckbox)) != 0; } void wxCheckBox::DoSet3StateValue(wxCheckBoxState state) diff --git a/src/gtk/checklst.cpp b/src/gtk/checklst.cpp index a75aebf..e082643 100644 --- a/src/gtk/checklst.cpp +++ b/src/gtk/checklst.cpp @@ -121,7 +121,7 @@ bool wxCheckListBox::IsChecked(unsigned int index) const 0, //column &value); - return g_value_get_boolean(&value) == TRUE ? true : false; + return g_value_get_boolean(&value) != 0; } void wxCheckListBox::Check(unsigned int index, bool check) diff --git a/src/gtk/clipbrd.cpp b/src/gtk/clipbrd.cpp index fa9c32b..aeb6af2 100644 --- a/src/gtk/clipbrd.cpp +++ b/src/gtk/clipbrd.cpp @@ -507,7 +507,7 @@ bool wxClipboard::SetSelectionOwner(bool set) set ? m_clipboardWidget : NULL, GTKGetClipboardAtom(), (guint32)GDK_CURRENT_TIME - ); + ) != 0; if ( !rc ) { diff --git a/src/gtk/dataview.cpp b/src/gtk/dataview.cpp index 01fad1c..8a6dba4 100644 --- a/src/gtk/dataview.cpp +++ b/src/gtk/dataview.cpp @@ -2257,12 +2257,10 @@ static void wxGtkToggleRendererToggledCallback( GtkCellRendererToggle *renderer, GValue gvalue = { 0, }; g_value_init( &gvalue, G_TYPE_BOOLEAN ); g_object_get_property( G_OBJECT(renderer), "active", &gvalue ); - bool tmp = g_value_get_boolean( &gvalue ); - g_value_unset( &gvalue ); // invert it - tmp = !tmp; + wxVariant value = !g_value_get_boolean( &gvalue ); + g_value_unset( &gvalue ); - wxVariant value = tmp; if (!cell->Validate( value )) return; @@ -2320,11 +2318,9 @@ bool wxDataViewToggleRenderer::GetValue( wxVariant &value ) const GValue gvalue = { 0, }; g_value_init( &gvalue, G_TYPE_BOOLEAN ); g_object_get_property( G_OBJECT(m_renderer), "active", &gvalue ); - bool tmp = g_value_get_boolean( &gvalue ); + value = g_value_get_boolean( &gvalue ) != 0; g_value_unset( &gvalue ); - value = tmp; - return true; } @@ -2625,7 +2621,7 @@ wxDataViewChoiceRenderer::wxDataViewChoiceRenderer( const wxArrayString &choices "has-entry", FALSE, NULL); - bool editable = (mode & wxDATAVIEW_CELL_EDITABLE); + bool editable = (mode & wxDATAVIEW_CELL_EDITABLE) != 0; g_object_set (m_renderer, "editable", editable, NULL); SetAlignment(alignment); @@ -3143,19 +3139,19 @@ void wxDataViewColumn::SetSortable( bool sortable ) bool wxDataViewColumn::IsSortable() const { GtkTreeViewColumn *column = GTK_TREE_VIEW_COLUMN(m_column); - return gtk_tree_view_column_get_clickable( column ); + return gtk_tree_view_column_get_clickable( column ) != 0; } bool wxDataViewColumn::IsSortKey() const { GtkTreeViewColumn *column = GTK_TREE_VIEW_COLUMN(m_column); - return gtk_tree_view_column_get_sort_indicator( column ); + return gtk_tree_view_column_get_sort_indicator( column ) != 0; } bool wxDataViewColumn::IsResizeable() const { GtkTreeViewColumn *column = GTK_TREE_VIEW_COLUMN(m_column); - return gtk_tree_view_column_get_resizable( column ); + return gtk_tree_view_column_get_resizable( column ) != 0; } bool wxDataViewColumn::IsHidden() const @@ -3225,7 +3221,7 @@ void wxDataViewColumn::SetReorderable( bool reorderable ) bool wxDataViewColumn::IsReorderable() const { - return gtk_tree_view_column_get_reorderable( GTK_TREE_VIEW_COLUMN(m_column) ); + return gtk_tree_view_column_get_reorderable( GTK_TREE_VIEW_COLUMN(m_column) ) != 0; } //----------------------------------------------------------------------------- @@ -4811,7 +4807,7 @@ bool wxDataViewCtrl::IsExpanded( const wxDataViewItem & item ) const GtkTreeIter iter; iter.user_data = item.GetID(); wxGtkTreePath path(m_internal->get_path( &iter )); - return gtk_tree_view_row_expanded( GTK_TREE_VIEW(m_treeview), path ); + return gtk_tree_view_row_expanded( GTK_TREE_VIEW(m_treeview), path ) != 0; } wxDataViewItem wxDataViewCtrl::DoGetCurrentItem() const @@ -4996,7 +4992,7 @@ bool wxDataViewCtrl::IsSelected( const wxDataViewItem & item ) const iter.stamp = m_internal->GetGtkModel()->stamp; iter.user_data = (gpointer) item.GetID(); - return gtk_tree_selection_iter_is_selected( selection, &iter ); + return gtk_tree_selection_iter_is_selected( selection, &iter ) != 0; } void wxDataViewCtrl::SelectAll() diff --git a/src/gtk/filectrl.cpp b/src/gtk/filectrl.cpp index 4c0d97b..70cd51a 100644 --- a/src/gtk/filectrl.cpp +++ b/src/gtk/filectrl.cpp @@ -88,7 +88,7 @@ bool wxGtkFileChooser::SetPath( const wxString& path ) if ( path.empty() ) return true; - return gtk_file_chooser_set_filename( m_widget, path.utf8_str() ); + return gtk_file_chooser_set_filename( m_widget, path.utf8_str() ) != 0; } bool wxGtkFileChooser::SetDirectory( const wxString& dir ) diff --git a/src/gtk/listbox.cpp b/src/gtk/listbox.cpp index b6945a5..621f019 100644 --- a/src/gtk/listbox.cpp +++ b/src/gtk/listbox.cpp @@ -729,7 +729,7 @@ bool wxListBox::IsSelected( int n ) const GtkTreeIter iter; wxCHECK_MSG( GTKGetIteratorFor(n, &iter), false, wxT("Invalid index") ); - return gtk_tree_selection_iter_is_selected(selection, &iter); + return gtk_tree_selection_iter_is_selected(selection, &iter) != 0; } void wxListBox::DoSetSelection( int n, bool select ) diff --git a/src/gtk/menu.cpp b/src/gtk/menu.cpp index f0dbd47..b19352d 100644 --- a/src/gtk/menu.cpp +++ b/src/gtk/menu.cpp @@ -434,7 +434,7 @@ bool wxMenuBar::IsEnabledTop(size_t pos) const wxCHECK_MSG( node, false, wxS("invalid index in IsEnabledTop") ); wxMenu* const menu = node->GetData(); wxCHECK_MSG( menu->m_owner, true, wxS("no menu owner?") ); - return gtk_widget_get_sensitive( menu->m_owner ); + return gtk_widget_get_sensitive( menu->m_owner ) != 0; } wxString wxMenuBar::GetMenuLabel( size_t pos ) const diff --git a/src/gtk/radiobox.cpp b/src/gtk/radiobox.cpp index eace0af..db1bc95 100644 --- a/src/gtk/radiobox.cpp +++ b/src/gtk/radiobox.cpp @@ -88,7 +88,7 @@ static gint gtk_radiobox_keypress_callback( GtkWidget *widget, GdkEventKey *gdk_ // GDK reports GDK_ISO_Left_Tab for SHIFT-TAB new_event.SetDirection( (gdk_event->keyval == GDK_Tab) ); // CTRL-TAB changes the (parent) window, i.e. switch notebook page - new_event.SetWindowChange( (gdk_event->state & GDK_CONTROL_MASK) ); + new_event.SetWindowChange( (gdk_event->state & GDK_CONTROL_MASK) != 0 ); new_event.SetCurrentFocus( rb ); return rb->GetParent()->HandleWindowEvent(new_event); } @@ -475,7 +475,7 @@ bool wxRadioBox::IsItemEnabled(unsigned int item) const // don't use GTK_WIDGET_IS_SENSITIVE() here, we want to return true even if // the parent radiobox is disabled - return gtk_widget_get_sensitive(GTK_WIDGET(button)); + return gtk_widget_get_sensitive(GTK_WIDGET(button)) != 0; } bool wxRadioBox::Show(unsigned int item, bool show) @@ -506,7 +506,7 @@ bool wxRadioBox::IsItemShown(unsigned int item) const GtkButton *button = GTK_BUTTON( node->GetData()->button ); - return gtk_widget_get_visible(GTK_WIDGET(button)); + return gtk_widget_get_visible(GTK_WIDGET(button)) != 0; } unsigned int wxRadioBox::GetCount() const diff --git a/src/gtk/region.cpp b/src/gtk/region.cpp index 92ec47f..1e1cb84 100644 --- a/src/gtk/region.cpp +++ b/src/gtk/region.cpp @@ -137,7 +137,7 @@ wxGDIRefData *wxRegion::CloneGDIRefData(const wxGDIRefData *data) const bool wxRegion::DoIsEqual(const wxRegion& region) const { return gdk_region_equal(M_REGIONDATA->m_region, - M_REGIONDATA_OF(region)->m_region); + M_REGIONDATA_OF(region)->m_region) != 0; } // ---------------------------------------------------------------------------- @@ -292,7 +292,7 @@ bool wxRegion::IsEmpty() const if (!m_refData) return true; - return gdk_region_empty( M_REGIONDATA->m_region ); + return gdk_region_empty( M_REGIONDATA->m_region ) != 0; } wxRegionContain wxRegion::DoContainsPoint( wxCoord x, wxCoord y ) const diff --git a/src/gtk/spinctrl.cpp b/src/gtk/spinctrl.cpp index f35eca8..8a7e864 100644 --- a/src/gtk/spinctrl.cpp +++ b/src/gtk/spinctrl.cpp @@ -195,7 +195,7 @@ bool wxSpinCtrlGTKBase::GetSnapToTicks() const { wxCHECK_MSG(m_widget, false, "invalid spin button"); - return gtk_spin_button_get_snap_to_ticks( GTK_SPIN_BUTTON(m_widget) ); + return gtk_spin_button_get_snap_to_ticks( GTK_SPIN_BUTTON(m_widget) ) != 0; } void wxSpinCtrlGTKBase::SetValue( const wxString& value ) diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index ac60261..12d35c4 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -1599,7 +1599,7 @@ bool wxTextCtrl::IsEditable() const if ( IsMultiLine() ) { - return gtk_text_view_get_editable(GTK_TEXT_VIEW(m_text)); + return gtk_text_view_get_editable(GTK_TEXT_VIEW(m_text)) != 0; } else { diff --git a/src/gtk/textentry.cpp b/src/gtk/textentry.cpp index d631d58..7d54373 100644 --- a/src/gtk/textentry.cpp +++ b/src/gtk/textentry.cpp @@ -279,7 +279,7 @@ bool wxTextEntry::DoAutoCompleteStrings(const wxArrayString& choices) bool wxTextEntry::IsEditable() const { - return gtk_editable_get_editable(GetEditable()); + return gtk_editable_get_editable(GetEditable()) != 0; } void wxTextEntry::SetEditable(bool editable) diff --git a/src/gtk/toplevel.cpp b/src/gtk/toplevel.cpp index 0545234..0dd59d4 100644 --- a/src/gtk/toplevel.cpp +++ b/src/gtk/toplevel.cpp @@ -1433,7 +1433,7 @@ bool wxTopLevelWindowGTK::CanSetTransparent() #if GTK_CHECK_VERSION(2,10,0) if (!gtk_check_version(2,10,0)) { - return (gtk_widget_is_composited (m_widget)); + return gtk_widget_is_composited(m_widget) != 0; } else #endif // In case of lower versions than gtk+-2.10.0 we could look for _NET_WM_CM_Sn ourselves diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 4f9ce50..4178edd 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -923,7 +923,8 @@ gtk_window_key_press_callback( GtkWidget *WXUNUSED(widget), // We should let GTK+ IM filter key event first. According to GTK+ 2.0 API // docs, if IM filter returns true, no further processing should be done. // we should send the key_down event anyway. - bool intercepted_by_IM = gtk_im_context_filter_keypress(win->m_imData->context, gdk_event); + bool intercepted_by_IM = + gtk_im_context_filter_keypress(win->m_imData->context, gdk_event) != 0; win->m_imData->lastKeyEvent = NULL; if (intercepted_by_IM) { @@ -3417,7 +3418,7 @@ bool wxWindowGTK::DoNavigateIn(int flags) gboolean rc; g_signal_emit_by_name(parent->m_widget, "focus", dir, &rc); - return rc == TRUE; + return rc != 0; } } @@ -3883,7 +3884,7 @@ void wxWindowGTK::SetDoubleBuffered( bool on ) bool wxWindowGTK::IsDoubleBuffered() const { - return gtk_widget_get_double_buffered( m_wxwindow ); + return gtk_widget_get_double_buffered( m_wxwindow ) != 0; } void wxWindowGTK::ClearBackground() diff --git a/src/msw/ole/uuid.cpp b/src/msw/ole/uuid.cpp index d407980..2153a25 100644 --- a/src/msw/ole/uuid.cpp +++ b/src/msw/ole/uuid.cpp @@ -86,7 +86,7 @@ bool Uuid::operator==(const Uuid& uuid) const { // IsEqualGUID() returns BOOL and not bool so use an explicit comparison to // avoid MSVC warnings about int->bool conversion - return IsEqualGUID(m_uuid, uuid.m_uuid) == TRUE; + return IsEqualGUID(m_uuid, uuid.m_uuid) != 0; } // dtor -- 2.7.4