From 335c96ccb66d62024fe14c7eacfc6f1c84153a85 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 11 Jan 2021 13:48:23 +0100 Subject: Use C++-style casts in C++ code --- src/gtk2_in_qt5.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'src/gtk2_in_qt5.cpp') diff --git a/src/gtk2_in_qt5.cpp b/src/gtk2_in_qt5.cpp index 69b4dce..a5c98f1 100644 --- a/src/gtk2_in_qt5.cpp +++ b/src/gtk2_in_qt5.cpp @@ -54,21 +54,21 @@ struct SuilGtk2InQt5Wrapper { static void on_size_request(GtkWidget*, GtkRequisition* requisition, gpointer user_data) { - auto* const wrap = (QWidget*)user_data; + auto* const wrap = static_cast(user_data); wrap->setMinimumSize(requisition->width, requisition->height); } static void on_size_allocate(GtkWidget*, GdkRectangle* allocation, gpointer user_data) { - auto* const wrap = (QWidget*)user_data; + auto* const wrap = static_cast(user_data); wrap->resize(allocation->width, allocation->height); } static void wrapper_free(SuilWrapper* wrapper) { - auto* impl = (SuilGtk2InQt5Wrapper*)wrapper->impl; + auto* impl = static_cast(wrapper->impl); if (impl->window) { impl->window->setParent(nullptr); @@ -87,17 +87,19 @@ wrapper_free(SuilWrapper* wrapper) static int wrapper_wrap(SuilWrapper* wrapper, SuilInstance* instance) { - auto* const impl = (SuilGtk2InQt5Wrapper*)wrapper->impl; + auto* const impl = static_cast(wrapper->impl); auto* const wrap = new QWidget(nullptr, Qt::Window); GtkWidget* const plug = gtk_plug_new(0); - auto* const widget = (GtkWidget*)instance->ui_widget; + auto* const widget = static_cast(instance->ui_widget); gtk_container_add(GTK_CONTAINER(plug), widget); gtk_widget_show_all(plug); - const WId wid = (WId)gtk_plug_get_id((GtkPlug*)plug); - QWindow* window = QWindow::fromWinId(wid); - QWidget* container = + const WId wid = + static_cast(gtk_plug_get_id(reinterpret_cast(plug))); + + QWindow* window = QWindow::fromWinId(wid); + QWidget* container = QWidget::createWindowContainer(window, wrap, Qt::WindowFlags()); auto* layout = new QVBoxLayout(); @@ -155,9 +157,9 @@ suil_wrapper_new(SuilHost* host, /* Create wrapper implementation. */ auto* const impl = - (SuilGtk2InQt5Wrapper*)calloc(1, sizeof(SuilGtk2InQt5Wrapper)); + static_cast(calloc(1, sizeof(SuilGtk2InQt5Wrapper))); - auto* wrapper = (SuilWrapper*)calloc(1, sizeof(SuilWrapper)); + auto* wrapper = static_cast(calloc(1, sizeof(SuilWrapper))); wrapper->wrap = wrapper_wrap; wrapper->free = wrapper_free; wrapper->impl = impl; -- cgit v1.2.1