Skip to content

Commit

Permalink
Fix code relying on initialization order
Browse files Browse the repository at this point in the history
Allows Debug - LLVM to boot
  • Loading branch information
CookiePLMonster authored and Nekotekina committed Jan 31, 2020
1 parent aeebcfe commit 9f678cc
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Utilities/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ logs::file_listener::file_listener(const std::string& name)
ver.m.ch = nullptr;
ver.m.sev = level::always;
ver.stamp = 0;
ver.text = fmt::format("RPCS3 v%s | %s%s\n%s", rpcs3::version.to_string(), rpcs3::get_branch(), firmware_string, utils::get_system_info());
ver.text = fmt::format("RPCS3 v%s | %s%s\n%s", rpcs3::get_version().to_string(), rpcs3::get_branch(), firmware_string, utils::get_system_info());

file_writer::log(logs::level::always, ver.text.data(), ver.text.size());
file_writer::log(logs::level::always, "\n", 1);
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ int main(int argc, char** argv)
const bool use_cli_style = find_arg(arg_style, argc, argv) || find_arg(arg_stylesheet, argc, argv);

QScopedPointer<QCoreApplication> app(createApplication(argc, argv));
app->setApplicationVersion(qstr(rpcs3::version.to_string()));
app->setApplicationVersion(qstr(rpcs3::get_version().to_string()));
app->setApplicationName("RPCS3");

// Command line args
Expand Down
6 changes: 5 additions & 1 deletion rpcs3/rpcs3_version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,9 @@ namespace rpcs3

// TODO: Make this accessible from cmake and keep in sync with MACOSX_BUNDLE_BUNDLE_VERSION.
// Currently accessible by Windows and Linux build scripts, see implementations when doing MACOSX
const extern utils::version version{ 0, 0, 8, utils::version_type::alpha, 1, RPCS3_GIT_VERSION };
const utils::version& get_version()
{
static constexpr utils::version version{ 0, 0, 8, utils::version_type::alpha, 1, RPCS3_GIT_VERSION };
return version;
}
}
3 changes: 1 addition & 2 deletions rpcs3/rpcs3_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ namespace rpcs3
{
std::string get_branch();
std::pair<std::string, std::string> get_commit_and_hash();

extern const utils::version version;
const utils::version& get_version();
}
2 changes: 1 addition & 1 deletion rpcs3/rpcs3qt/about_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ about_dialog::about_dialog(QWidget* parent) : QDialog(parent), ui(new Ui::about_

ui->close->setDefault(true);

ui->version->setText(tr("RPCS3 Version: %1").arg(qstr(rpcs3::version.to_string())));
ui->version->setText(tr("RPCS3 Version: %1").arg(qstr(rpcs3::get_version().to_string())));

// Events
connect(ui->gitHub, &QPushButton::clicked, [] { QDesktopServices::openUrl(QUrl("https://www.github.com/RPCS3")); });
Expand Down
4 changes: 2 additions & 2 deletions rpcs3/rpcs3qt/gs_frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ gs_frame::gs_frame(const QString& title, const QRect& geometry, const QIcon& app
m_disable_mouse = gui_settings->GetValue(gui::gs_disableMouse).toBool();

// Get version by substringing VersionNumber-buildnumber-commithash to get just the part before the dash
std::string version = rpcs3::version.to_string();
std::string version = rpcs3::get_version().to_string();
version = version.substr(0 , version.find_last_of('-'));

// Add branch and commit hash to version on frame unless it's master.
if ((rpcs3::get_branch().compare("master") != 0) && (rpcs3::get_branch().compare("HEAD") != 0))
{
version = version + "-" + rpcs3::version.to_string().substr((rpcs3::version.to_string().find_last_of('-') + 1), 8) + "-" + rpcs3::get_branch();
version = version + "-" + rpcs3::get_version().to_string().substr((rpcs3::get_version().to_string().find_last_of('-') + 1), 8) + "-" + rpcs3::get_branch();
}

m_windowTitle += qstr(" | " + version);
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/rpcs3qt/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void main_window::Init()
CreateConnects();

setMinimumSize(350, minimumSizeHint().height()); // seems fine on win 10
setWindowTitle(QString::fromStdString("RPCS3 " + rpcs3::version.to_string()));
setWindowTitle(QString::fromStdString("RPCS3 " + rpcs3::get_version().to_string()));

Q_EMIT RequestGlobalStylesheetChange(guiSettings->GetCurrentStylesheetPath());
ConfigureGuiFromSettings(true);
Expand Down
8 changes: 4 additions & 4 deletions rpcs3/util/fixed_typemap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ namespace stx
// Destroy all objects and keep them in uninitialized state, must be called first
void reset() noexcept
{
const auto total_count = stx::typelist_v<typeinfo>.count();
const auto total_count = stx::typelist<typeinfo>().count();

if (!m_list)
{
Expand All @@ -96,13 +96,13 @@ namespace stx
void(*destroy)(void*& ptr) noexcept;
};

auto all_data = std::make_unique<destroy_info[]>(stx::typelist_v<typeinfo>.count());
auto all_data = std::make_unique<destroy_info[]>(stx::typelist<typeinfo>().count());

// Actual number of created objects
unsigned _max = 0;

// Create destroy list
for (auto& type : stx::typelist_v<typeinfo>)
for (auto& type : stx::typelist<typeinfo>())
{
if (m_order[type.index()] == 0)
{
Expand Down Expand Up @@ -136,7 +136,7 @@ namespace stx
// Default initialize all objects if possible and not already initialized
void init() noexcept
{
for (auto& type : stx::typelist_v<typeinfo>)
for (auto& type : stx::typelist<typeinfo>())
{
type.create(m_list[type.index()]);

Expand Down
13 changes: 9 additions & 4 deletions rpcs3/util/typeindices.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,21 @@ namespace stx

// Global typecounter instance
template <typename Info>
inline type_counter<Info> typelist_v{};
auto& typelist()
{
static type_counter<Info> typelist_v;
return typelist_v;
}

template <typename Info>
type_info<Info>::type_info(Info info, decltype(sizeof(int))) noexcept
: Info(info)
, type(typelist_v<Info>.count())
, type(typelist<Info>().count())
{
// Update linked list
typelist_v<Info>.next->next = this;
typelist_v<Info>.next = this;
auto& tl = typelist<Info>();
tl.next->next = this;
tl.next = this;
}

// Type index accessor
Expand Down

0 comments on commit 9f678cc

Please sign in to comment.