ShowImage: fix saving
As investigated and suggested by jackburton in ticket #14693: outTranslator wasn't initialized correctly (due to type mismatch on 64 bit platform). Also set the image's file name as default in the save dialog. Fixes #14693 Change-Id: I741e3616b935315a707ea3949a330d41d577fd91 Reviewed-on: https://review.haiku-os.org/c/haiku/+/7102 Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
@@ -1182,10 +1182,9 @@ void
|
||||
ShowImageWindow::_SaveAs(BMessage* message)
|
||||
{
|
||||
// Read the translator and output type the user chose
|
||||
translator_id outTranslator;
|
||||
int32 outTranslator;
|
||||
uint32 outType;
|
||||
if (message->FindInt32(kTranslatorField,
|
||||
reinterpret_cast<int32 *>(&outTranslator)) != B_OK
|
||||
if (message->FindInt32(kTranslatorField, &outTranslator) != B_OK
|
||||
|| message->FindInt32(kTypeField,
|
||||
reinterpret_cast<int32 *>(&outType)) != B_OK)
|
||||
return;
|
||||
@@ -1200,6 +1199,7 @@ ShowImageWindow::_SaveAs(BMessage* message)
|
||||
BMessenger target(this);
|
||||
fSavePanel = new (std::nothrow) BFilePanel(B_SAVE_PANEL,
|
||||
&target, NULL, 0, false, &panelMsg);
|
||||
|
||||
if (!fSavePanel)
|
||||
return;
|
||||
|
||||
@@ -1211,6 +1211,12 @@ ShowImageWindow::_SaveAs(BMessage* message)
|
||||
settings->Unlock();
|
||||
}
|
||||
|
||||
// Prefill current image's file name in save dialog
|
||||
BEntry entry = fImageView->Image();
|
||||
BPath path(&entry);
|
||||
const char* filename = path.Leaf();
|
||||
fSavePanel->SetSaveText(filename);
|
||||
|
||||
fSavePanel->Window()->SetWorkspaces(B_CURRENT_WORKSPACE);
|
||||
fSavePanel->Show();
|
||||
}
|
||||
@@ -1230,10 +1236,9 @@ ShowImageWindow::_SaveToFile(BMessage* message)
|
||||
|
||||
// Read in the translator and type to be used
|
||||
// to save the output image
|
||||
translator_id outTranslator;
|
||||
int32 outTranslator;
|
||||
uint32 outType;
|
||||
if (message->FindInt32(kTranslatorField,
|
||||
reinterpret_cast<int32 *>(&outTranslator)) != B_OK
|
||||
if (message->FindInt32(kTranslatorField, &outTranslator) != B_OK
|
||||
|| message->FindInt32(kTypeField,
|
||||
reinterpret_cast<int32 *>(&outType)) != B_OK)
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user