Fixed up: Move file-static RenderWindow and RenderTexture instances inside functions to fix GL race condition on startup (#682)
This commit is contained in:
@@ -14,7 +14,6 @@ namespace x11 {
|
||||
x11::Cursor ibeam; // = XCreateFontCursor(NULL, XC_xterm);
|
||||
|
||||
// extern cursor_type current_cursor;
|
||||
extern sf::RenderWindow mainPtr;
|
||||
|
||||
Cursor::Cursor(fs::path imgPath, float hotSpotX, float hotSpotY)
|
||||
: ptr(nullptr) {
|
||||
|
@@ -5,7 +5,6 @@
|
||||
#include <SFML/Graphics/RenderWindow.hpp>
|
||||
#include "res_cursor.hpp"
|
||||
|
||||
extern sf::RenderWindow mainPtr;
|
||||
|
||||
// This function adapted from <http://www.codeproject.com/Articles/5220/Creating-a-color-cursor-from-a-bitmap>
|
||||
static void GetMaskBitmaps(const sf::Image& srcImage, HBITMAP& hAndMaskBitmap, HBITMAP& hXorMaskBitmap) {
|
||||
|
@@ -12,12 +12,15 @@
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <SFML/Window.hpp>
|
||||
#include <SFML/Graphics/Image.hpp>
|
||||
#include <SFML/Graphics/RenderWindow.hpp>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "prefs.hpp"
|
||||
#include "mathutil.hpp"
|
||||
|
||||
sf::RenderWindow& mainPtr();
|
||||
|
||||
char keyToChar(sf::Keyboard::Key key, bool isShift);
|
||||
|
||||
void makeFrontWindow(sf::Window& win);
|
||||
|
@@ -13,7 +13,6 @@
|
||||
|
||||
#include "dialogxml/dialogs/dialog.hpp"
|
||||
|
||||
extern sf::RenderWindow mainPtr;
|
||||
extern void showError(std::string str1, std::string str2, cDialog* parent = nullptr);
|
||||
|
||||
extern void play_sound(snd_num_t which, sf::Time delay = sf::Time());
|
||||
|
@@ -213,7 +213,6 @@ NSOpenPanel* dlg_get_rsrc;
|
||||
NSSavePanel* dlg_put_scen;
|
||||
NSSavePanel* dlg_put_game;
|
||||
NSSavePanel* dlg_put_rsrc;
|
||||
extern sf::RenderWindow mainPtr;
|
||||
|
||||
void init_fileio(){
|
||||
dlg_get_scen = [NSOpenPanel openPanel];
|
||||
@@ -256,7 +255,7 @@ void init_fileio(){
|
||||
|
||||
fs::path nav_get_scenario() {
|
||||
bool gotFile = [dlg_get_scen runModal] != NSFileHandlingPanelCancelButton;
|
||||
makeFrontWindow(mainPtr);
|
||||
makeFrontWindow(mainPtr());
|
||||
if(gotFile) {
|
||||
return fs::path([[[dlg_get_scen URL] path] fileSystemRepresentation]);
|
||||
}
|
||||
@@ -270,7 +269,7 @@ fs::path nav_put_scenario(fs::path def) {
|
||||
[dlg_put_scen setDirectoryURL:[NSURL fileURLWithPath:[NSString stringWithUTF8String: def.parent_path().c_str()]]];
|
||||
}
|
||||
bool gotFile = [dlg_put_scen runModal] != NSFileHandlingPanelCancelButton;
|
||||
makeFrontWindow(mainPtr);
|
||||
makeFrontWindow(mainPtr());
|
||||
if(gotFile)
|
||||
return fs::path([[[dlg_put_scen URL] path] fileSystemRepresentation]);
|
||||
return "";
|
||||
@@ -278,7 +277,7 @@ fs::path nav_put_scenario(fs::path def) {
|
||||
|
||||
fs::path nav_get_party() {
|
||||
bool gotFile = [dlg_get_game runModal] != NSFileHandlingPanelCancelButton;
|
||||
makeFrontWindow(mainPtr);
|
||||
makeFrontWindow(mainPtr());
|
||||
if(gotFile)
|
||||
return fs::path([[[dlg_get_game URL] path] fileSystemRepresentation]);
|
||||
return "";
|
||||
@@ -291,7 +290,7 @@ fs::path nav_put_party(fs::path def) {
|
||||
[dlg_put_game setDirectoryURL:[NSURL fileURLWithPath:[NSString stringWithUTF8String: def.parent_path().c_str()]]];
|
||||
}
|
||||
bool gotFile = [dlg_put_game runModal] != NSFileHandlingPanelCancelButton;
|
||||
makeFrontWindow(mainPtr);
|
||||
makeFrontWindow(mainPtr());
|
||||
if(gotFile)
|
||||
return fs::path([[[dlg_put_game URL] path] fileSystemRepresentation]);
|
||||
return "";
|
||||
|
@@ -7,7 +7,6 @@
|
||||
#include <sstream>
|
||||
#include <cmath>
|
||||
|
||||
extern sf::RenderWindow mainPtr;
|
||||
OPENFILENAMEA getParty, getScen, getRsrc, putParty, putScen, putRsrc;
|
||||
|
||||
// TODO: I'm sure there's a better way to do this (maybe one that's keyboard layout agnostic)
|
||||
@@ -163,7 +162,7 @@ void init_fileio() {
|
||||
memset(&base_dlg, 0, sizeof(OPENFILENAMEA));
|
||||
// Common values
|
||||
base_dlg.lStructSize = sizeof(OPENFILENAMEA);
|
||||
base_dlg.hwndOwner = mainPtr.getSystemHandle();
|
||||
base_dlg.hwndOwner = mainPtr().getSystemHandle();
|
||||
base_dlg.nFilterIndex = 1;
|
||||
base_dlg.Flags = OFN_DONTADDTORECENT | OFN_ENABLESIZING | OFN_EXPLORER | OFN_HIDEREADONLY | OFN_NOCHANGEDIR;
|
||||
getParty = getScen = getRsrc = putParty = putScen = putRsrc = base_dlg;
|
||||
@@ -296,7 +295,7 @@ fs::path nav_put_rsrc(std::initializer_list<std::string> extensions, fs::path de
|
||||
|
||||
void set_clipboard(std::string text) {
|
||||
if(text.empty()) return;
|
||||
if(!OpenClipboard(mainPtr.getSystemHandle())) return;
|
||||
if(!OpenClipboard(mainPtr().getSystemHandle())) return;
|
||||
HGLOBAL hData = (char*) GlobalAlloc(GMEM_MOVEABLE, text.length() + 1);
|
||||
char* data = (char*)GlobalLock(hData);
|
||||
std::copy(text.c_str(), text.c_str() + text.length(), data);
|
||||
@@ -351,7 +350,7 @@ void set_clipboard_img(sf::Image& img) {
|
||||
info->bV5BlueMask = 0x00ff0000;
|
||||
info->bV5AlphaMask = 0xff000000;
|
||||
std::copy_n(img.getPixelsPtr(), pxSize, reinterpret_cast<sf::Uint8*>(info + 1));
|
||||
if(!OpenClipboard(mainPtr.getSystemHandle())) {
|
||||
if(!OpenClipboard(mainPtr().getSystemHandle())) {
|
||||
printErr("Error opening clipboard");
|
||||
GlobalFree(data);
|
||||
return;
|
||||
@@ -450,7 +449,7 @@ ModalSession::~ModalSession() {
|
||||
int getMenubarHeight() {
|
||||
MENUBARINFO info;
|
||||
info.cbSize = sizeof(MENUBARINFO);
|
||||
if(GetMenuBarInfo(mainPtr.getSystemHandle(), OBJID_MENU, 0, &info)) {
|
||||
if(GetMenuBarInfo(mainPtr().getSystemHandle(), OBJID_MENU, 0, &info)) {
|
||||
return info.rcBar.bottom - info.rcBar.top;
|
||||
} else {
|
||||
return GetSystemMetrics(SM_CYMENU);
|
||||
@@ -473,5 +472,5 @@ void adjust_window_for_menubar(int mode, unsigned int width, unsigned int height
|
||||
}
|
||||
|
||||
height += getMenubarHeight();
|
||||
mainPtr.setSize({ width, height });
|
||||
mainPtr().setSize({ width, height });
|
||||
}
|
||||
|
Reference in New Issue
Block a user