diff options
| author | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2009-12-27 17:28:00 +0100 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2009-12-27 17:28:00 +0100 |
| commit | ff6b0244b39ccdb30a499038382d2676d9c278be (patch) | |
| tree | a966c4e951b61310e47f15ff85b3e80b5e5bc16e | |
| parent | 2e39205afb249626b24b1af2251297ff039a60ca (diff) | |
| download | tuxcmd-ff6b0244b39ccdb30a499038382d2676d9c278be.tar.xz | |
Kylix fixes, cleanup
| -rw-r--r-- | UCoreUtils.pas | 6 | ||||
| -rw-r--r-- | UCoreWorkers.pas | 86 | ||||
| -rw-r--r-- | UGnome.pas | 16 | ||||
| -rw-r--r-- | UMain.pas | 5 |
4 files changed, 59 insertions, 54 deletions
diff --git a/UCoreUtils.pas b/UCoreUtils.pas index c4e71a7..342d796 100644 --- a/UCoreUtils.pas +++ b/UCoreUtils.pas @@ -1124,7 +1124,11 @@ begin with Params[I] do case VType of vtPointer: begin - P := g_strdup_printf('%p', VPointer); + {$IFDEF CPU64} + P := g_strdup_printf('%.16p', VPointer); + {$ELSE} + P := g_strdup_printf('%.8p', VPointer); + {$ENDIF} Write(ErrOutput, P); g_free(P); end; diff --git a/UCoreWorkers.pas b/UCoreWorkers.pas index 97077aa..3fb394a 100644 --- a/UCoreWorkers.pas +++ b/UCoreWorkers.pas @@ -29,7 +29,6 @@ type TWorkerThreadJobType = (WORKER_JOB_DUMMY, WORKER_JOB_DELETE, WORKER_JOB_COP type TVFSCallbackThread = class(TThread) private FThreadID: __pthread_t; - FCopyProgressFunc: TEngineProgressFunc; FFinished: boolean; VFSCallbackEvent: TSimpleEvent; @@ -80,6 +79,8 @@ type TVFSCallbackThread = class(TThread) // Copy worker progress values FTotalSize, FTotalDone, FFileSize: cuLongLong; + FCopySkipAllErrors: boolean; + FCopyProgressFunc: TEngineProgressFunc; // Dialogs FCancelMessage: string; @@ -92,30 +93,31 @@ type TVFSCallbackThread = class(TThread) FGUIProgress1Pos, FGUIProgress2Pos, FGUIProgress1Max, FGUIProgress2Max: Int64; FGUIProgress1Text, FGUIProgress2Text, FGUILabel1Text, FGUILabel2Text: string; FGUIChanged: boolean; - procedure UpdateProgress1(const Progress: Int64; const ProgressText: string); - procedure UpdateProgress2(const Progress: Int64; const ProgressText: string); - procedure SetProgress1Params(const ProgressMax: Int64); - procedure SetProgress2Params(const ProgressMax: Int64); - procedure UpdateCaption1(const CaptionText: string); - procedure UpdateCaption2(const CaptionText: string); FDirDeleteButtonsType: TFDirDeleteButtonSet; FDirDeleteTitle, FDirDeleteFileName: string; FDirDeleteError: PGError; - function ShowDirDeleteDialog(ButtonsType: TFDirDeleteButtonSet; const Title, FileName: string; Error: PGError): integer; FOverwriteShowAppend: boolean; FOverwriteSourceItem, FOverwriteDestItem: PDataItem; FOverwriteSourceFile, FOverwriteDestFile, FOverwriteRenameStr: string; - function ShowOverwriteDialog(ShowAppend: boolean; SourceItem, DestItem: PDataItem; const SourceFile, DestFile: string; var RenameStr: string): integer; FNewDirCaption, FNewDirLabel, FNewDirEdit: string; - function ShowNewDirDialog(Caption, LabelCaption, Edit: string): integer; FMsgBoxText: string; FMsgBoxButtons: TMessageButtons; FMsgBoxStyle: TMessageStyle; FMsgBoxDefault, FMsgBoxEscape, FDialogResultMsgBox: TMessageButton; + + procedure UpdateProgress1(const Progress: Int64; const ProgressText: string); + procedure UpdateProgress2(const Progress: Int64; const ProgressText: string); + procedure SetProgress1Params(const ProgressMax: Int64); + procedure SetProgress2Params(const ProgressMax: Int64); + procedure UpdateCaption1(const CaptionText: string); + procedure UpdateCaption2(const CaptionText: string); + function ShowDirDeleteDialog(ButtonsType: TFDirDeleteButtonSet; const Title, FileName: string; Error: PGError): integer; + function ShowOverwriteDialog(ShowAppend: boolean; SourceItem, DestItem: PDataItem; const SourceFile, DestFile: string; var RenameStr: string): integer; + function ShowNewDirDialog(Caption, LabelCaption, Edit: string): integer; function ShowMessageBox(const Text: string; Buttons: TMessageButtons; Style: TMessageStyle; Default, Escape: TMessageButton): TMessageButton; @@ -140,8 +142,6 @@ type TVFSCallbackThread = class(TThread) CopyTargetPath: string; - FCopySkipAllErrors: boolean; - QuickRenameDataItem: PDataItem; ExtractFromVFSAll: boolean; @@ -262,11 +262,12 @@ begin if pthread_self = Application.ThreadID then begin DebugMsg(['!! (WARNING): vfs_ask_question_callback called from the main thread, expected spawn from a TVFSCallbackThread']); HandleVFSAskQuestionCallback(Thread.DialogsParentWindow.FWidget, AMessage, Choices, choice); - if (choice <> nil) then Thread.VFSCallbackCancelled := (choice^ < 0) or (choice^ = cancel_choice); + if (choice <> nil) then + Thread.VFSCallbackCancelled := (choice^ < 0) or (choice^ = cancel_choice); Exit; end; if pthread_self = Thread.FThreadID then begin - DebugMsg(['******* vfs_ask_question_callback spawned, user_data = 0x', IntToHex(QWord(user_data), 16), ', ThreadID = 0x', IntToHex(pthread_self, 16)]); + DebugMsg(['******* vfs_ask_question_callback spawned, user_data = ', user_data, ', ThreadID = ', pthread_self]); Thread.VFSAskQuestion_Message := AMessage; Thread.VFSAskQuestion_Choices := Choices; Thread.VFSAskQuestion_Choice := choice; @@ -274,7 +275,8 @@ begin Thread.VFSCallbackEvent.ResetEvent; Thread.VFSCallbackEvent.WaitFor(INFINITE); DebugMsg(['******* thread: resuming...']); - if (choice <> nil) then Thread.VFSCallbackCancelled := (choice^ < 0) or (choice^ = cancel_choice); + if (choice <> nil) then + Thread.VFSCallbackCancelled := (choice^ < 0) or (choice^ = cancel_choice); Exit; end; DebugMsg(['!! (ERROR): vfs_ask_question_callback spawned neither from the main thread nor from active TVFSCallbackThread, dropping the callback to prevent data corruption.']); @@ -336,7 +338,7 @@ begin Thread.VFSCallbackCancelled := Result = False; end else if pthread_self = Thread.FThreadID then begin - DebugMsg(['******* vfs_ask_password_callback spawned, user_data = 0x', IntToHex(QWord(user_data), 16), ', ThreadID = 0x', IntToHex(pthread_self, 16), ', Application.ThreadID = 0x', IntToHex(Application.ThreadID, 16)]); + DebugMsg(['******* vfs_ask_password_callback spawned, user_data = ', user_data, ', ThreadID = ', pthread_self, ', Application.ThreadID = ', Application.ThreadID]); Thread.VFSAskPassword_Message := AMessage; Thread.VFSAskPassword_default_user := default_user; Thread.VFSAskPassword_default_domain := default_domain; @@ -374,20 +376,6 @@ begin password_save^ := VFS_PASSWORD_SAVE_NEVER; end; -// Keep in sync with uVFSprototypes.pas/TVFSProgressCallback -function vfs_copy_progress_callback(position: guint64; error: PGError; user_data: Pointer): gboolean; cdecl; -begin -// DebugMsg(['VFSCopyCallBackFunc called (iPos = ', iPos, ', iMax = ', iMax, ')']); - Result := True; - if not Assigned(user_data) then Exit; - if Assigned(TVFSCallbackThread(user_data).FCopyProgressFunc) then - try - Result := TVFSCallbackThread(user_data).FCopyProgressFunc(user_data, position, error); - except - on E: Exception do DebugMsg(['*** Exception raised in vfs_copy_progress_callback(position=', position, ', user_data=', user_data, '): (', E.ClassName, '): ', E.Message]); - end; -end; - (********************************************************************************************************************************) (********************************************************************************************************************************) procedure TWorkerThread.Execute; @@ -425,6 +413,7 @@ begin FDialogShowMsgBox := False; ErrorHappened := False; FGUIChanged := False; + FCopyProgressFunc := nil; JobType := WORKER_JOB_DUMMY; // Defaults, keep in sync with class interface @@ -911,22 +900,35 @@ end; (********************************************************************************************************************************) (********************************************************************************************************************************) + + // Keep in sync with uVFSprototypes.pas/TVFSProgressCallback + function vfs_copy_progress_callback(position: guint64; error: PGError; user_data: Pointer): gboolean; cdecl; + begin + Result := True; + if not Assigned(user_data) then Exit; + if Assigned(TWorkerThread(user_data).FCopyProgressFunc) then + try + Result := TWorkerThread(user_data).FCopyProgressFunc(user_data, position, error); + except + on E: Exception do DebugMsg(['*** Exception raised in vfs_copy_progress_callback(position=', position, ', user_data=', user_data, '): (', E.ClassName, '): ', E.Message]); + end; + end; + // Keep in sync with UEngines.pas/TEngineProgressFunc function CopyFilesWorker_ProgressFunc(Sender: Pointer; BytesDone: Int64; Error: PGError): boolean; cdecl; begin Result := True; -// DebugMsg(['*** CopyFilesWorker: ProgressFunc called (Sender=', QWord(Sender), ', BytesDone=', BytesDone, ')']); try - if Assigned(Sender) and (TObject(Sender) is TWorkerThread) then - with TWorkerThread(Sender) do begin - if BytesDone = 0 then UpdateProgress1(0, '0%') - else UpdateProgress1(BytesDone, Format('%d%%', [Round(BytesDone / FFileSize * 100)])); - UpdateProgress2(FTotalDone + BytesDone, Format('%d%%', [Round((FTotalDone + BytesDone) / FTotalSize * 100)])); - Result := not FCancelled; - CommitGUIUpdate; - end else DebugMsg(['*** CopyFilesWorker: Sender is not TWorkerThread']); + if Assigned(Sender) and (TObject(Sender) is TWorkerThread) then + with TWorkerThread(Sender) do begin + if BytesDone = 0 then UpdateProgress1(0, '0%') + else UpdateProgress1(BytesDone, Format('%d%%', [Round(BytesDone / FFileSize * 100)])); + UpdateProgress2(FTotalDone + BytesDone, Format('%d%%', [Round((FTotalDone + BytesDone) / FTotalSize * 100)])); + Result := not FCancelled; + CommitGUIUpdate; + end else DebugMsg(['*** CopyFilesWorker: Sender is not TWorkerThread']); except - on E: Exception do DebugMsg(['*** Exception raised in ProgressFunc(Sender=', QWord(Sender), ', BytesDone=', BytesDone, '): (', E.ClassName, '): ', E.Message]); + on E: Exception do DebugMsg(['*** Exception raised in ProgressFunc(Sender=', Sender, ', BytesDone=', BytesDone, '): (', E.ClassName, '): ', E.Message]); end; end; @@ -1190,7 +1192,7 @@ var DefResponse: integer; // Global variables for this function end; // DebugMsg(['(II) CopyFilesWorker.DoOperation: finished']); except - on E: Exception do DebugMsg(['*** Exception raised in DoOperation(AFileRec=', QWord(AFileRec), ', Dst=', Dst, ', ErrorKind=', ErrorKind, ', Append=', Append, '): (', E.ClassName, '): ', E.Message]); + on E: Exception do DebugMsg(['*** Exception raised in DoOperation(AFileRec=', AFileRec, ', Dst=', Dst, ', ErrorKind=', ErrorKind, ', Append=', Append, '): (', E.ClassName, '): ', E.Message]); end; end; @@ -1354,7 +1356,7 @@ var DefResponse: integer; // Global variables for this function end; // DebugMsg(['(II) CopyFilesWorker.HandleCopy: finished']); except - on E: Exception do DebugMsg(['*** Exception raised in HandleCopy(AFileRec=', QWord(AFileRec), ', NewFilePath=', NewFilePath, '): (', E.ClassName, '): ', E.Message]); + on E: Exception do DebugMsg(['*** Exception raised in HandleCopy(AFileRec=', AFileRec, ', NewFilePath=', NewFilePath, '): (', E.ClassName, '): ', E.Message]); end; end; @@ -1566,7 +1566,7 @@ begin DebugMsg(['Initializing Gnome...']); g := gnome_program_init('TuxCommander', PChar(ConstAboutVersion), libgnomeui_module_info_get, GTKForms.argc, GTKForms.argv, 'show-crash-dialog', 0, nil); - DebugMsg([' *GnomeProgram = 0x', IntToHex(QWORD(g), 8)]); + DebugMsg([' *GnomeProgram = ', g]); end; except end; @@ -1594,7 +1594,7 @@ begin if libGlib2Handle <> nil then begin @g_filename_display_name := dlsym(libGlib2Handle, 'g_filename_display_name'); @g_mkdir_with_parents := dlsym(libGlib2Handle, 'g_mkdir_with_parents'); - DebugMsg(['libglib-2.0.so loaded, @g_filename_display_name = 0x', IntToHex(QWORD(@g_filename_display_name), 8)]); + DebugMsg(['libglib-2.0.so loaded, @g_filename_display_name = ', @g_filename_display_name]); end; libGtk2Handle := dlopen('libgtk-x11-2.0.so.0', RTLD_LAZY); if libGtk2Handle = nil then libGtk2Handle := dlopen('libgtk-x11-2.0.so', RTLD_LAZY); @@ -1603,15 +1603,15 @@ begin @gtk_icon_size_lookup_for_settings := dlsym(libGtk2Handle, 'gtk_icon_size_lookup_for_settings'); @gtk_window_set_icon_name := dlsym(libGtk2Handle, 'gtk_window_set_icon_name'); @gtk_message_dialog_new_with_markup := dlsym(libGtk2Handle, 'gtk_message_dialog_new_with_markup'); - DebugMsg(['libgtk-x11-2.0.so loaded, @gtk_event_box_set_visible_window = 0x', IntToHex(QWORD(@gtk_event_box_set_visible_window), 8), - ', @gtk_icon_size_lookup_for_settings = 0x', IntToHex(QWORD(@gtk_icon_size_lookup_for_settings), 8)]); + DebugMsg(['libgtk-x11-2.0.so loaded, @gtk_event_box_set_visible_window = ', @gtk_event_box_set_visible_window, + ', @gtk_icon_size_lookup_for_settings = ', @gtk_icon_size_lookup_for_settings]); end; libGnome2Handle := dlopen('libgnome-2.so.0', RTLD_LAZY); if libGnome2Handle = nil then libGnome2Handle := dlopen('libgnome-2.so', RTLD_LAZY); if libGnome2Handle <> nil then begin @gnome_program_init := dlsym(libGnome2Handle, 'gnome_program_init'); @libgnome_module_info_get := dlsym(libGnome2Handle, 'libgnome_module_info_get'); - DebugMsg(['libgnome-2.so loaded, @gnome_program_init = 0x', IntToHex(QWORD(@gnome_program_init), 8), ', @libgnome_module_info_get = 0x', IntToHex(QWORD(@libgnome_module_info_get), 8)]); + DebugMsg(['libgnome-2.so loaded, @gnome_program_init = ', @gnome_program_init, ', @libgnome_module_info_get = ', @libgnome_module_info_get]); end; libGnomeUI2Handle := dlopen('libgnomeui-2.so.0', RTLD_LAZY); if libGnomeUI2Handle = nil then libGnomeUI2Handle := dlopen('libgnomeui-2.so', RTLD_LAZY); @@ -1628,9 +1628,9 @@ begin @gnome_date_edit_new := dlsym(libGnomeUI2Handle, 'gnome_date_edit_new'); @gnome_date_edit_set_time := dlsym(libGnomeUI2Handle, 'gnome_date_edit_set_time'); @gnome_date_edit_get_time := dlsym(libGnomeUI2Handle, 'gnome_date_edit_get_time'); - DebugMsg(['libgnomeui-2.so loaded, @gnome_about_new = 0x', IntToHex(QWORD(@gnome_about_new), 8), ', @gnome_color_picker_new = 0x', IntToHex(QWORD(@gnome_color_picker_new), 8), - ', @gnome_icon_entry_new = 0x', IntToHex(QWORD(@gnome_icon_entry_new), 8), ', @gnome_date_edit_new = 0x', IntToHex(QWORD(@gnome_date_edit_new), 8), - ', @libgnomeui_module_info_get = 0x', IntToHex(QWORD(@libgnomeui_module_info_get), 8)]); + DebugMsg(['libgnomeui-2.so loaded, @gnome_about_new = ', @gnome_about_new, ', @gnome_color_picker_new = ', @gnome_color_picker_new, + ', @gnome_icon_entry_new = 0x', @gnome_icon_entry_new, ', @gnome_date_edit_new = ', @gnome_date_edit_new, + ', @libgnomeui_module_info_get = ', @libgnomeui_module_info_get]); end; SetupGnomeLibs; end; @@ -1759,7 +1759,6 @@ var ListView: TGTKListView; end; procedure DoThread; - var DialogParent: PGtkWidget; begin try OpenDirThread.AEngine := Engine; @@ -3189,7 +3188,7 @@ var LeftPanel, HasInitialCRC: boolean; AListView: TGTKListView; Engine: TPanelEngine; FilePath, s, TargetName: string; - TargetCRC: LongWord; + TargetCRC: Cardinal; TargetSize: Int64; AWorkingThread: TWorkerThread; begin @@ -4901,7 +4900,7 @@ procedure TFMain.FillMounterBar; {$IFDEF CPU64} Button.Tag := QWORD(MounterList[i]); {$ELSE} - Button.Tag := Longint(MounterList[i]); + Button.Tag := Cardinal(MounterList[i]); {$ENDIF} Button.Tooltip := Format(LANGMountPointDevice, [StrToUTF8(MountPath), StrToUTF8(Device)]); Button.BorderStyle := bsNone; |
