From 17ab6b3e14601b392efb7cc9a256283fcdc2db91 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 21 Jan 2023 16:56:21 +0200 Subject: [PATCH 3/3] Qt: Don't try to refer to qapp outside gui_main.cpp It's local (static) to the module. Attempt to use it by declaring it 'extern' in other modules caused linking to fail with msys2 clang64 toolchain. See osdn #46575 Signed-off-by: Marko Lindqvist --- client/gui-qt/chatline.cpp | 4 +++- client/gui-qt/citydlg.cpp | 4 ++-- client/gui-qt/diplodlg.cpp | 5 +++-- client/gui-qt/mapview.cpp | 1 - client/gui-qt/menu.cpp | 2 -- client/gui-qt/messagedlg.cpp | 9 +++++---- client/gui-qt/repodlgs.cpp | 1 - client/gui-qt/themes.cpp | 3 +-- 8 files changed, 14 insertions(+), 15 deletions(-) diff --git a/client/gui-qt/chatline.cpp b/client/gui-qt/chatline.cpp index 0928c3117b..8ae436306f 100644 --- a/client/gui-qt/chatline.cpp +++ b/client/gui-qt/chatline.cpp @@ -46,7 +46,6 @@ #include "gui_main.h" #include "qtg_cxxside.h" -extern QApplication *qapp; static bool is_plain_public_message(QString s); FC_CPP_DECLARE_LISTENER(chat_listener) @@ -741,6 +740,7 @@ void qtg_real_output_window_append(const char *astring, { QString str; QString wakeup; + QApplication *qapp; str = QString::fromUtf8(astring); gui()->set_status_bar(str); @@ -752,6 +752,8 @@ void qtg_real_output_window_append(const char *astring, wakeup = wakeup.arg(client.conn.username); } + qapp = current_app(); + if (str.contains(client.conn.username)) { qapp->alert(gui()->central_wdg); } diff --git a/client/gui-qt/citydlg.cpp b/client/gui-qt/citydlg.cpp index e55894a7f9..2030f79490 100644 --- a/client/gui-qt/citydlg.cpp +++ b/client/gui-qt/citydlg.cpp @@ -65,9 +65,9 @@ #include "citydlg.h" #include "colors.h" #include "fc_client.h" +#include "gui_main.h" #include "hudwidget.h" -extern QApplication *qapp; static bool city_dlg_created = false; /** defines if dialog for city has been * already created. It's created only * once per client @@ -3976,7 +3976,7 @@ void city_production_delegate::paint(QPainter *painter, QPixmap pix_dec(option.rect.width(), option.rect.height()); QStyleOptionViewItem opt; color col; - QIcon icon = qapp->style()->standardIcon(QStyle::SP_DialogCancelButton); + QIcon icon = current_app()->style()->standardIcon(QStyle::SP_DialogCancelButton); bool free_sprite = false; struct unit_class *pclass; diff --git a/client/gui-qt/diplodlg.cpp b/client/gui-qt/diplodlg.cpp index 17b31b3e47..62661e3dba 100644 --- a/client/gui-qt/diplodlg.cpp +++ b/client/gui-qt/diplodlg.cpp @@ -37,6 +37,7 @@ #include "colors.h" #include "diplodlg.h" #include "fc_client.h" +#include "gui_main.h" #include "sidebar.h" extern "C" { @@ -46,7 +47,7 @@ extern "C" { typedef advance *p_advance; typedef city *p_city; -extern QApplication *qapp; + /**************************************************************************** Constructor for diplomacy widget ****************************************************************************/ @@ -1049,7 +1050,7 @@ void close_all_diplomacy_dialogs(void) diplo_dlg *dd; QWidget *w; - qapp->alert(gui()->central_wdg); + current_app()->alert(gui()->central_wdg); if (!gui()->is_repo_dlg_open("DDI")) { return; } diff --git a/client/gui-qt/mapview.cpp b/client/gui-qt/mapview.cpp index f8e24b316e..5c20565b94 100644 --- a/client/gui-qt/mapview.cpp +++ b/client/gui-qt/mapview.cpp @@ -53,7 +53,6 @@ const char *get_timeout_label_text(); static int mapview_frozen_level = 0; extern void destroy_city_dialog(); extern struct canvas *canvas; -extern QApplication *qapp; #define MAX_DIRTY_RECTS 20 static int num_dirty_rects = 0; diff --git a/client/gui-qt/menu.cpp b/client/gui-qt/menu.cpp index 84bc3bc49e..5a7d79d463 100644 --- a/client/gui-qt/menu.cpp +++ b/client/gui-qt/menu.cpp @@ -60,8 +60,6 @@ #include "menu.h" -extern QApplication *qapp; - static void enable_interface(bool enable); /************************************************************************** diff --git a/client/gui-qt/messagedlg.cpp b/client/gui-qt/messagedlg.cpp index ec7812fa2c..e39bb8e7b4 100644 --- a/client/gui-qt/messagedlg.cpp +++ b/client/gui-qt/messagedlg.cpp @@ -1,4 +1,4 @@ -/********************************************************************** +/*********************************************************************** Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,9 +29,10 @@ // gui-qt #include "fc_client.h" +#include "gui_main.h" + #include "messagedlg.h" -extern QApplication *qapp; /************************************************************************** Message widget constructor **************************************************************************/ @@ -83,8 +84,8 @@ message_dlg::message_dlg() fill_data(); margins = msgtab->contentsMargins(); len = msgtab->horizontalHeader()->length() + margins.left() - + margins.right() - + qapp->style()->pixelMetric(QStyle::PM_ScrollBarExtent); + + margins.right() + + current_app()->style()->pixelMetric(QStyle::PM_ScrollBarExtent); msgtab->setFixedWidth(len); msgtab->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); but1->setFixedWidth(len / 3); diff --git a/client/gui-qt/repodlgs.cpp b/client/gui-qt/repodlgs.cpp index d514a64bb4..e94850a55e 100644 --- a/client/gui-qt/repodlgs.cpp +++ b/client/gui-qt/repodlgs.cpp @@ -60,7 +60,6 @@ extern QString cut_helptext(QString text); extern QString get_tooltip_improvement(impr_type *building, struct city *pcity, bool ext); extern QString get_tooltip_unit(struct unit_type *unit, bool ext); -extern QApplication *qapp; units_reports* units_reports::m_instance = 0; diff --git a/client/gui-qt/themes.cpp b/client/gui-qt/themes.cpp index 08e3b33f4d..a847ea30f9 100644 --- a/client/gui-qt/themes.cpp +++ b/client/gui-qt/themes.cpp @@ -32,9 +32,8 @@ // gui-qt #include "fc_client.h" +#include "gui_main.h" -extern QApplication *current_app(); -extern QApplication *qapp; extern QString current_theme; static QString def_app_style; static QString stylestring; -- 2.39.0