diff options
author | John Fultz <jfultz@wolfram.com> | 2023-07-18 00:44:06 -0500 |
---|---|---|
committer | John Fultz <jfultz@wolfram.com> | 2023-07-18 00:44:06 -0500 |
commit | 53f394839396edd537785fc40db3090839dd7c04 (patch) | |
tree | 4198dc35fd903fbd537d798a5de06afb2e7b3253 /quacker/quacker.cpp | |
parent | a68140dfb546b8a89c48bfe99d7b56d9c2908569 (diff) |
Fix Qt6 MOC compilation on some platforms.
That was super painful. It seems that some of the Quackle types that
have custom operator==() give fits to the MOC compiler when those
types are used as arguments for slots and/or signals (or maybe it's
only when they're connected in a certain way...frankly, I never did
figure this out precisely to my satisfaction). The compilers provide
very little help in resolving this problem.
Once I understood the problem, VS22 was giving me just the tiniest
morsel, enough that I could hunt down the offending slot/signal
(it wasn't even giving me the name of the slot/signal...just the type
it was trying to use). I've changed all offending functions to use
const pointers to types instead of const references, and this makes
Qt happy.
I couldn't find any info on the web directly about this, but here's
the closest I did find, which suggests that this is related to
increased functionality in Qt6 regarding reflection.
https://forum.qt.io/topic/141434/
This fixes my VC++22 x86-64 build. Hopefully it fixes all of the
others, too.
Diffstat (limited to 'quacker/quacker.cpp')
-rw-r--r-- | quacker/quacker.cpp | 60 |
1 files changed, 36 insertions, 24 deletions
diff --git a/quacker/quacker.cpp b/quacker/quacker.cpp index 7ab54c0..9e133c4 100644 --- a/quacker/quacker.cpp +++ b/quacker/quacker.cpp @@ -223,7 +223,7 @@ void TopLevel::commit() void TopLevel::pass() { Quackle::Move pass(Quackle::Move::createPassMove()); - setCandidateMove(pass); + setCandidateMove(&pass); } void TopLevel::overdraw() @@ -269,14 +269,14 @@ bool TopLevel::askToCarryOn(const QString &text) return QMessageBox::question(this, tr("Verify Play - Quackle"), dialogText(text), QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes; } -void TopLevel::setCandidateMove(const Quackle::Move &move, bool *carryOnPtr) +void TopLevel::setCandidateMove(const Quackle::Move *move, bool *carryOnPtr) { if (carryOnPtr != nullptr) *carryOnPtr = true; - if (!m_game->hasPositions() || (move.action == Quackle::Move::Place && move.tiles().empty())) + if (!m_game->hasPositions() || (move->action == Quackle::Move::Place && move->tiles().empty())) return; - Quackle::Move prettiedMove(move); + Quackle::Move prettiedMove(*move); m_game->currentPosition().ensureMoveTilesDoNotIncludePlayThru(prettiedMove); m_game->currentPosition().ensureMovePrettiness(prettiedMove); @@ -447,13 +447,13 @@ bool TopLevel::validifyMove(Quackle::Move &move) return true; } -void TopLevel::removeCandidateMoves(const Quackle::MoveList &moves) +void TopLevel::removeCandidateMoves(const Quackle::MoveList *moves) { if (!m_game->hasPositions()) return; - const Quackle::MoveList::const_iterator end(moves.end()); - for (Quackle::MoveList::const_iterator it = moves.begin(); it != end; ++it) + const Quackle::MoveList::const_iterator end(moves->end()); + for (Quackle::MoveList::const_iterator it = moves->begin(); it != end; ++it) m_game->currentPosition().removeMove(*it); ensureUpToDateSimulatorMoveList(); @@ -492,7 +492,7 @@ void TopLevel::setNote(const UVString ¬e) setModified(true); } -void TopLevel::goToHistoryLocation(const Quackle::HistoryLocation &location) +void TopLevel::goToHistoryLocation(const Quackle::HistoryLocation *location) { if (!m_game->hasPositions()) return; @@ -507,7 +507,7 @@ void TopLevel::goToHistoryLocation(const Quackle::HistoryLocation &location) stopEverything(); stopOutcraftyingCurrentPlayer(); - m_game->setCurrentPosition(location); + m_game->setCurrentPosition(*location); showToHuman(); } @@ -571,7 +571,7 @@ void TopLevel::updateAllViews() void TopLevel::updatePositionViews() { - emit positionChanged(m_game->currentPosition()); + emit positionChanged(&m_game->currentPosition()); m_simulateAction->setEnabled(!m_game->currentPosition().moves().empty()); m_simulateDetailsAction->setEnabled(!m_game->currentPosition().moves().empty()); @@ -621,9 +621,15 @@ void TopLevel::updatePositionViews() void TopLevel::updateMoveViews() { if (m_simulator->hasSimulationResults()) - emit movesChanged(m_simulator->moves(/* prune */ true, /* sort by win */ true)); + { + const Quackle::MoveList& moveList = m_simulator->moves(/* prune */ true, /* sort by win */ true); + emit movesChanged(&moveList); + } else - emit movesChanged(m_game->currentPosition().moves()); + { + const Quackle::MoveList moveList = m_game->currentPosition().moves(); + emit movesChanged(&moveList); + } m_simulateAction->setEnabled(!m_game->currentPosition().moves().empty()); m_simulateDetailsAction->setEnabled(!m_game->currentPosition().moves().empty()); @@ -635,7 +641,7 @@ void TopLevel::updateHistoryViews() emit historyChanged(m_game->history()); } -void TopLevel::initializeGame(const Quackle::PlayerList &players) +void TopLevel::initializeGame(const Quackle::PlayerList *players) { stopEverything(); @@ -644,10 +650,10 @@ void TopLevel::initializeGame(const Quackle::PlayerList &players) m_logania = 0; setModified(false); - if (players.empty()) + if (players->empty()) return; - Quackle::PlayerList newPlayers(players); + Quackle::PlayerList newPlayers(*players); // shuffle so same person doesn't go first twice in a row, // if there are multiple players in the game @@ -768,8 +774,11 @@ void TopLevel::newGame() switch (newGameDialog.exec()) { case QDialog::Accepted: - initializeGame(newGameDialog.players()); + { + const Quackle::PlayerList &players = newGameDialog.players(); + initializeGame(&players); break; + } case QDialog::Rejected: break; @@ -823,8 +832,8 @@ void TopLevel::plugIntoMatrix(View *view) { plugIntoBaseMatrix(view); - connect(view, SIGNAL(setCandidateMove(const Quackle::Move &, bool *)), this, SLOT(setCandidateMove(const Quackle::Move &, bool *))); - connect(view, SIGNAL(removeCandidateMoves(const Quackle::MoveList &)), this, SLOT(removeCandidateMoves(const Quackle::MoveList &))); + connect(view, SIGNAL(setCandidateMove(const Quackle::Move *, bool *)), this, SLOT(setCandidateMove(const Quackle::Move *, bool *))); + connect(view, SIGNAL(removeCandidateMoves(const Quackle::MoveList *)), this, SLOT(removeCandidateMoves(const Quackle::MoveList *))); connect(view, SIGNAL(commit()), this, SLOT(commit())); connect(view, SIGNAL(setRack(const Quackle::Rack &)), this, SLOT(setRack(const Quackle::Rack &))); connect(view, SIGNAL(setNote(const UVString &)), this, SLOT(setNote(const UVString &))); @@ -832,19 +841,19 @@ void TopLevel::plugIntoMatrix(View *view) void TopLevel::plugIntoPositionMatrix(View *view) { - connect(this, SIGNAL(positionChanged(const Quackle::GamePosition &)), view, SLOT(positionChanged(const Quackle::GamePosition &))); + connect(this, SIGNAL(positionChanged(const Quackle::GamePosition *)), view, SLOT(positionChanged(const Quackle::GamePosition *))); } void TopLevel::plugIntoMoveMatrix(View *view) { - connect(this, SIGNAL(movesChanged(const Quackle::MoveList &)), view, SLOT(movesChanged(const Quackle::MoveList &))); + connect(this, SIGNAL(movesChanged(const Quackle::MoveList *)), view, SLOT(movesChanged(const Quackle::MoveList *))); } void TopLevel::plugIntoHistoryMatrix(HistoryView *view) { plugIntoBaseMatrix(view); - connect(view, SIGNAL(goToHistoryLocation(const Quackle::HistoryLocation &)), this, SLOT(goToHistoryLocation(const Quackle::HistoryLocation &))); + connect(view, SIGNAL(goToHistoryLocation(const Quackle::HistoryLocation *)), this, SLOT(goToHistoryLocation(const Quackle::HistoryLocation *))); connect(this, SIGNAL(historyChanged(const Quackle::History &)), view, SLOT(historyChanged(const Quackle::History &))); } @@ -991,7 +1000,8 @@ void TopLevel::firstPosition() const Quackle::GamePosition &firstPozzy = m_game->history().firstPosition(&exists); if (exists) { - goToHistoryLocation(firstPozzy.location()); + const Quackle::HistoryLocation &location = firstPozzy.location(); + goToHistoryLocation(&location); } } @@ -1001,7 +1011,8 @@ void TopLevel::nextPosition() const Quackle::GamePosition &nextPozzy = m_game->history().nextPosition(&exists); if (exists) { - goToHistoryLocation(nextPozzy.location()); + const Quackle::HistoryLocation &location = nextPozzy.location(); + goToHistoryLocation(&location); } } @@ -1011,7 +1022,8 @@ void TopLevel::previousPosition() const Quackle::GamePosition &previousPozzy = m_game->history().previousPosition(&exists); if (exists) { - goToHistoryLocation(previousPozzy.location()); + const Quackle::HistoryLocation &location = previousPozzy.location(); + goToHistoryLocation(&location); } } |