From 4c08121fe55032baf51ce80ba1234225b48773ce Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 21 Jan 2023 16:53:23 +0200 Subject: [PATCH 14/14] 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 | 6 +++--- client/gui-qt/repodlgs.cpp | 1 - client/gui-qt/themes.cpp | 3 +-- 8 files changed, 12 insertions(+), 14 deletions(-) diff --git a/client/gui-qt/chatline.cpp b/client/gui-qt/chatline.cpp index d2bae867b0..139d8577a6 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 b0e0fb4e4c..b82f65aa76 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 @@ -3987,7 +3987,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 8542aa1b2e..7d18b02811 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 ****************************************************************************/ @@ -1074,7 +1075,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 a36df25fc5..00a199690a 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 6ba913e560..668b50d1d4 100644 --- a/client/gui-qt/menu.cpp +++ b/client/gui-qt/menu.cpp @@ -61,8 +61,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 18f35fc13f..fd4e775063 100644 --- a/client/gui-qt/messagedlg.cpp +++ b/client/gui-qt/messagedlg.cpp @@ -29,10 +29,10 @@ // gui-qt #include "fc_client.h" +#include "gui_main.h" #include "messagedlg.h" -extern QApplication *qapp; /************************************************************************** Message widget constructor **************************************************************************/ @@ -84,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 8fb5c7b093..d97310de88 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