Skip to content

Commit

Permalink
fix crash when get resource string in background thread
Browse files Browse the repository at this point in the history
  • Loading branch information
duchuule committed Oct 6, 2015
1 parent 95bc35d commit c2b9ac2
Show file tree
Hide file tree
Showing 16 changed files with 100 additions and 86 deletions.
2 changes: 1 addition & 1 deletion CheatPane.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ void CheatPane::addButton_Click(Platform::Object^ sender, Windows::UI::Xaml::Rou

bool CheatPane::CheckCodeFormat(Platform::String ^codeText, void(*messageCallback)(Platform::String ^))
{
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForCurrentView();
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForViewIndependentUse();


if (codeText == nullptr || codeText->IsEmpty())
Expand Down
2 changes: 1 addition & 1 deletion DirectXPage.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ DirectXPage::DirectXPage():
// Declare the top level nav items
navlist = ref new Vector<NavMenuItem^>();

auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForCurrentView();
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForViewIndependentUse();
navlist->Append(
ref new NavMenuItem(
loader->GetString("HomeText"),
Expand Down
4 changes: 2 additions & 2 deletions ExportPage.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void ExportPage::SignInbtn_Click(Platform::Object^ sender, Windows::UI::Xaml::Ro

void ExportPage::signin_Completed(bool isLoggedIn)
{
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForCurrentView();
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForViewIndependentUse();

if (isLoggedIn)
{
Expand Down Expand Up @@ -136,7 +136,7 @@ void ExportPage::signin_Completed(bool isLoggedIn)

void ExportPage::exportOneDrivebtn_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForCurrentView();
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForViewIndependentUse();

//get a list of rom
Vector<Platform::String ^> ^romNames = ref new Vector<Platform::String ^>();
Expand Down
8 changes: 4 additions & 4 deletions FileBrowserPane.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void FileBrowserPane::fileList_SelectionChanged(Platform::Object^ sender, Window
if (this->loading)
return;

auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForCurrentView();
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForViewIndependentUse();

OneDriveFileItem ^ item = (OneDriveFileItem ^)(this->fileList->SelectedItem);
if (item == nullptr)
Expand Down Expand Up @@ -339,7 +339,7 @@ task<size_t> FileBrowserPane::DownloadFile(OneDriveFileItem^ item, CreationColli

void FileBrowserPane::closeBtn_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForCurrentView();
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForViewIndependentUse();

//check to see if any thing is downloading
for (unsigned int i = 0; i < this->fileVector->Size; i++)
Expand All @@ -363,7 +363,7 @@ void FileBrowserPane::closeBtn_Click(Platform::Object^ sender, Windows::UI::Xaml

void FileBrowserPane::OnNavigatingFrom(Windows::UI::Xaml::Navigation::NavigatingCancelEventArgs^ e)
{
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForCurrentView();
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForViewIndependentUse();

for (unsigned int i = 0; i < this->fileVector->Size; i++)
{
Expand Down Expand Up @@ -420,7 +420,7 @@ void FileBrowserPane::backBtn_Click(Platform::Object^ sender, Windows::UI::Xaml:
return;
}

auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForCurrentView();
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForViewIndependentUse();

//check to see if any thing is downloading
for (unsigned int i = 0; i < this->fileVector->Size; i++)
Expand Down
4 changes: 2 additions & 2 deletions HIDGamepadConfig.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ HIDGamepadConfig::HIDGamepadConfig() :
void HIDGamepadConfig::OnNavigatedTo(NavigationEventArgs^ /* e */)
{
navigatedAway = false;
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForCurrentView();
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForViewIndependentUse();
if (!EventHandlerForDevice::Current->IsDeviceConnected) //connection failed
{
//this->txtNotification->Visibility = Windows::UI::Xaml::Visibility::Visible;
Expand Down Expand Up @@ -231,7 +231,7 @@ void HIDGamepadConfig::OnInputReportEvent(HidDevice^ sender, HidInputReportRecei
//check buttons
auto bcontrols = inputReport->ActivatedBooleanControls;

auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForCurrentView();
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForViewIndependentUse();

if (configureStage == 0) //record start button and default value of numeric buttons
{
Expand Down
2 changes: 1 addition & 1 deletion HelpPage.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ HelpPage::HelpPage()
auto myPackage = Windows::ApplicationModel::Package::Current;
auto version = myPackage->Id->Version;

auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForCurrentView();
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForViewIndependentUse();

versionBlock->Text = loader->GetString("VersionText") + version.Major + "." + version.Minor + "." + version.Build + "." + version.Revision;

Expand Down
6 changes: 3 additions & 3 deletions ImportPage.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ ImportPage::ImportPage()

void ImportPage::chooseFolderbtn_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForCurrentView();
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForViewIndependentUse();

FolderPicker ^picker = ref new FolderPicker();

Expand Down Expand Up @@ -264,7 +264,7 @@ void ImportPage::importSavbtn_Click(Platform::Object^ sender, Windows::UI::Xaml:

picker->ViewMode = PickerViewMode::List;
//picker->CommitButtonText = "Select";
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForCurrentView();
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForViewIndependentUse();


task<void> t = create_task(picker->PickSingleFileAsync()).then([this, loader](StorageFile ^file)
Expand Down Expand Up @@ -354,7 +354,7 @@ void ImportPage::SignInbtn_Click(Platform::Object^ sender, Windows::UI::Xaml::Ro

void ImportPage::signin_Completed(bool isLoggedIn)
{
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForCurrentView();
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForViewIndependentUse();

if (isLoggedIn)
{
Expand Down
4 changes: 2 additions & 2 deletions PurchasePage.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void PurchasePage::ButtonBuyNow_Clicked(Platform::Object^ sender, Windows::UI::X

if (CurrentApp::LicenseInformation->ProductLicenses->Lookup(key)->IsActive)
{
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForCurrentView();
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForViewIndependentUse();

//prompt user to restart app if it's ad removal
if (key == "removeads" || key == "noads_premium")
Expand Down Expand Up @@ -113,7 +113,7 @@ void PurchasePage::loadProductsBtn_Click(Platform::Object^ sender, Windows::UI::
{
try
{
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForCurrentView();
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForViewIndependentUse();

ListingInformation^ li = tli.get();

Expand Down
6 changes: 3 additions & 3 deletions SelectFilesPane.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ SelectFilesPane::SelectFilesPane(IVector<Platform::String^>^ list, Platform::Str
{
this->fileList->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
this->txtNoFile->Visibility = Windows::UI::Xaml::Visibility::Visible;
this->txtNoFile->Text = ResourceLoader::GetForCurrentView()->GetString("NoSupportedFileText");
this->txtNoFile->Text = ResourceLoader::GetForViewIndependentUse()->GetString("NoSupportedFileText");
}
initdone = true;

Expand All @@ -60,15 +60,15 @@ void SelectFilesPane::OkBtn_Click(Platform::Object^ sender, Windows::UI::Xaml::R
{
if (this->fileList->SelectedItems->Size == 0)
{
MessageDialog ^dialog = ref new MessageDialog(ResourceLoader::GetForCurrentView()->GetString("NoFileSelectedText"));
MessageDialog ^dialog = ref new MessageDialog(ResourceLoader::GetForViewIndependentUse()->GetString("NoFileSelectedText"));
dialog->ShowAsync();
return;
}

this->fileList->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
this->txtNoFile->Visibility = Windows::UI::Xaml::Visibility::Visible;
this->OkBtn->IsEnabled = false;
this->txtNoFile->Text = ResourceLoader::GetForCurrentView()->GetString("ProcessingText");
this->txtNoFile->Text = ResourceLoader::GetForViewIndependentUse()->GetString("ProcessingText");


Vector<int>^ selectedIndices = ref new Vector<int> ();
Expand Down
8 changes: 4 additions & 4 deletions SelectROMPane.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ void SelectROMPane::saveBtn_Click(Platform::Object^ sender, Windows::UI::Xaml::R
}
else
{
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForCurrentView();
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForViewIndependentUse();

MessageDialog ^dialog = ref new MessageDialog(loader->GetString("OverwriteSaveConfirmText"),loader->GetString("OverwriteAsk"));
UICommand ^confirm = ref new UICommand(loader->GetString("YesText"),
Expand Down Expand Up @@ -344,7 +344,7 @@ void SelectROMPane::loadBtn_Click(Platform::Object^ sender, Windows::UI::Xaml::R
}
else
{
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForCurrentView();
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForViewIndependentUse();


MessageDialog ^dialog = ref new MessageDialog(loader->GetString("LoadConfirmPrompt"), loader->GetString("WarningText"));
Expand Down Expand Up @@ -381,7 +381,7 @@ void SelectROMPane::loadBtn_Click(Platform::Object^ sender, Windows::UI::Xaml::R

void SelectROMPane::resetBtn_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForCurrentView();
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForViewIndependentUse();

MessageDialog ^dialog = ref new MessageDialog(loader->GetString("ResetConfirmPrompt"), loader->GetString("WarningText"));
UICommand ^confirm = ref new UICommand(loader->GetString("YesText"),
Expand Down Expand Up @@ -500,7 +500,7 @@ void VBA10::SelectROMPane::lbAllROMMainGrid_RightTapped(Platform::Object^ sender

void SelectROMPane::ShowContextMenu(ROMDBEntry^ entry, Windows::Foundation::Rect rect)
{
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForCurrentView();
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForViewIndependentUse();

auto menu = ref new PopupMenu();
menu->Commands->Append(ref new UICommand(loader->GetString("DeleteText"), ref new UICommandInvokedHandler([this, entry, loader](IUICommand^ command)
Expand Down
2 changes: 1 addition & 1 deletion SelectStatePane.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ SelectStatePane::SelectStatePane(int selectedSlot):initdone(false)

void SelectStatePane::Init(void)
{
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForCurrentView();
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForViewIndependentUse();

this->savestateVector = ref new Platform::Collections::Vector<Platform::String ^>();
this->savestateVector->Append(loader->GetString("Savestate0Text"));
Expand Down
68 changes: 42 additions & 26 deletions SettingsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
>
<StackPanel Orientation="Vertical" x:Name="InputStackPanel"
HorizontalAlignment="Left"
MaxWidth="500"
MaxWidth="440"
Margin="12,0">
<StackPanel.Resources>
<CollectionViewSource x:Name="vsControllerList"/>
Expand All @@ -51,23 +51,28 @@
x:Name="runBuyNotice"/>
</TextBlock>

<StackPanel Orientation="Horizontal"
Margin="0,0,0,8"
x:Name="panelGamepadActivate">
<Grid Margin="0,0,0,8"
x:Name="panelGamepadActivate">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="8" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>

<Button x:Name="purchaseBtn" Content="**Buy"
Click="purchaseBtn_Click"
Width="120"
Click="purchaseBtn_Click"
x:Uid="BuyBtn"
Margin =" 0, 0, 8, 0"/>
HorizontalAlignment="Stretch"
/>

<Button x:Name="watchVideoBtn" Content="**Watch Video"
Width="120"
Margin =" 0, 0, 0, 0"
Click="watchVideobtn_Click"
x:Uid="WatchVideoBtn"/>
Click="watchVideobtn_Click"
x:Uid="WatchVideoBtn"
HorizontalAlignment="Stretch"
Grid.Column="2"/>


</StackPanel>
</Grid>

<TextBlock TextWrapping="Wrap"
Text="txtControllerStatus - set by cpp"
Expand All @@ -76,7 +81,13 @@
Margin="0,0,0,8"
>
</TextBlock>


<Button x:Name="ConfigureXboxBtn" Content="**Configure"
x:Uid="ConfigureBtn"
HorizontalAlignment="Stretch"
Margin="0,0,0,12"
/>

<StackPanel x:Name="panelHIDGamepad" >
<TextBlock Text="txtHIDGamepad - set by cpp"
Foreground="Blue"
Expand All @@ -100,23 +111,28 @@
</ListBox.ItemTemplate>
</ListBox>

<StackPanel Orientation="Horizontal"
Margin =" 0, 0, 0, 12"
<Grid Margin =" 0, 0, 0, 12"
x:Name="panelHIDConnect">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="8" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>

<Button x:Name="ConfigureBtn" Content="**Configure"
Width="120"
Margin =" 0, 0, 8, 0"
x:Uid="ConfigureBtn"
Click="ConfigureBtn_Click"/>
Click="ConfigureBtn_Click"
HorizontalAlignment="Stretch"
/>

<Button x:Name="ConnectBtn" Content="**Connect"
x:Uid="ConnectBtn"
Width="120"
Margin =" 0, 0, 0, 0"
Click="ConnectBtn_Click"/>
<Button x:Name="ConnectBtn" Content="**Connect"
x:Uid="ConnectBtn"
Click="ConnectBtn_Click"
HorizontalAlignment="Stretch"
Grid.Column="2"/>


</StackPanel>
</Grid>
</StackPanel>

<ComboBox Name="cboTurboBehavior"
Expand Down Expand Up @@ -404,7 +420,7 @@
>
<StackPanel Orientation="Vertical"
HorizontalAlignment="Left"
MaxWidth="500"
MaxWidth="440"
Margin="12,0">
<!--<ToggleSwitch Toggled="hzToggle_Toggled" Header="30 Hz mode for displays with 30 Hz" Name="hzToggle" IsOn="True" HorizontalAlignment="Stretch" VerticalAlignment="Top"/>-->

Expand Down Expand Up @@ -571,7 +587,7 @@
>
<StackPanel Orientation="Vertical"
HorizontalAlignment="Left"
MaxWidth="500"
MaxWidth="440"
Margin="12,0">


Expand Down
Loading

0 comments on commit c2b9ac2

Please sign in to comment.