mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
Fix crash when right click floating card info window (#5773)
This commit is contained in:
parent
5af71d1c2e
commit
08f3a56285
3 changed files with 20 additions and 1 deletions
|
|
@ -51,6 +51,8 @@
|
|||
#flow_widget = false
|
||||
#flow_widget.size = false
|
||||
|
||||
# card_info_picture_widget = false
|
||||
|
||||
# pixel_map_generator = false
|
||||
|
||||
# filter_string = false
|
||||
|
|
|
|||
|
|
@ -312,11 +312,26 @@ QMenu *CardInfoPictureWidget::createViewRelatedCardsMenu()
|
|||
return viewRelatedCards;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the single instance of the MainWindow in this application.
|
||||
*/
|
||||
static MainWindow *findMainWindow()
|
||||
{
|
||||
for (auto widget : QApplication::topLevelWidgets()) {
|
||||
if (auto mainWindow = qobject_cast<MainWindow *>(widget)) {
|
||||
return mainWindow;
|
||||
}
|
||||
}
|
||||
// This code should be unreachable
|
||||
qCritical() << "Could not find MainWindow in QApplication::topLevelWidgets";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QMenu *CardInfoPictureWidget::createAddToOpenDeckMenu()
|
||||
{
|
||||
auto addToOpenDeckMenu = new QMenu(tr("Add card to deck"));
|
||||
|
||||
auto *mainWindow = qobject_cast<MainWindow *>(window());
|
||||
auto mainWindow = findMainWindow();
|
||||
QList<AbstractTabDeckEditor *> deckEditorTabs = mainWindow->getTabSupervisor()->getDeckEditorTabs();
|
||||
|
||||
if (deckEditorTabs.isEmpty()) {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
#include <QTimer>
|
||||
#include <QWidget>
|
||||
|
||||
inline Q_LOGGING_CATEGORY(CardInfoPictureWidgetLog, "card_info_picture_widget");
|
||||
|
||||
class AbstractCardItem;
|
||||
class QMenu;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue