From 18123c80568c0f68b829ca1d2ebe57ec7ff75abd Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 21 Jan 2023 16:50:07 +0200 Subject: [PATCH 20/20] 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 | 4 ++-- client/gui-qt/mapview.cpp | 1 - client/gui-qt/menu.cpp | 2 -- client/gui-qt/messagedlg.cpp | 7 +++---- client/gui-qt/repodlgs.cpp | 1 - client/gui-qt/themes.cpp | 3 +-- 8 files changed, 11 insertions(+), 15 deletions(-) diff --git a/client/gui-qt/chatline.cpp b/client/gui-qt/chatline.cpp index ba6e8708bb..7de086f5ba 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) @@ -740,6 +739,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); @@ -751,6 +751,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 5851e405ae..21ec20fb79 100644 --- a/client/gui-qt/citydlg.cpp +++ b/client/gui-qt/citydlg.cpp @@ -64,9 +64,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 @@ -4062,7 +4062,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 f55dae1d67..4d64655be5 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,6 @@ extern "C" { typedef advance *p_advance; typedef city *p_city; -extern QApplication *qapp; /************************************************************************//** Constructor for diplomacy widget @@ -1088,7 +1088,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 f595365234..b1eb255ced 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 c3c092f211..1bee4cee97 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 fe109cfee9..0558ac94ec 100644 --- a/client/gui-qt/messagedlg.cpp +++ b/client/gui-qt/messagedlg.cpp @@ -15,7 +15,6 @@ #include #endif - // Qt #include #include @@ -29,10 +28,10 @@ // gui-qt #include "fc_client.h" +#include "gui_main.h" #include "messagedlg.h" -extern QApplication *qapp; /**********************************************************************//** Message widget constructor **************************************************************************/ @@ -84,8 +83,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 7acc770946..7999c209cf 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 0de230a458..5ad4b6f8bd 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